From b6f369b269e098fa83229a2211145d2fdfe16e49 Mon Sep 17 00:00:00 2001 From: YaroslavO <yoslavskiy@innocode.no> Date: Fri, 25 Jan 2019 13:24:08 +0200 Subject: [PATCH] Readme update --- Gemfile.lock | 2 +- README.md | 81 +++++++++++++++++++++++++++++++++++++++++++++++--- repost.gemspec | 6 ---- 3 files changed, 78 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 37cd823..374935c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - repost (0.2.1) + repost (0.2.2) GEM remote: https://rubygems.org/ diff --git a/README.md b/README.md index a780afb..01bf978 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Repost -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/repost`. To experiment with that code, run `bin/console` for an interactive prompt. - -TODO: Delete this and the text above, and describe your gem +Gem implements Redirect using POST method ## Installation @@ -22,7 +20,82 @@ Or install it yourself as: ## Usage -TODO: Write usage instructions here +If you use Rails, gem automatically includes helper methods to your controllers: + +```ruby +repost(*SOME_SETTINGS*) +``` +and, as an alias + +```ruby +redirect_post(*SOME_SETTINGS*) +``` + +*Under the hood it calls `render` method of current controller with `html:`.* + + + +# + +If you use Sinatra or etc., you need to require it first somewhere in you project: + +```ruby +require 'repost' +``` + +Then ask your senpai to generate a string with html: + + +```ruby +Repost::Senpai.perform(*SOME_SETTINGS*) +``` + +Example in Sinatra app: + +```ruby +class MyController < Sinatra::Base + get '/' do + Repost::Senpai.perform(*SOME_SETTINGS*) + end +end +``` + +## \*Some Settings\* section + +*Reminder:* + +*In Rails app you can use `repost` or `redirect_post` method in your controller which performs 'redirect' when it is called.* + +*In Sinatra app or if you need to have just html - call Senpai* + + +### Dafaq iz dis: + +```ruby +Repost::Senpai.perform('http://examp.io/endpoint', # URL, looks understandable + params: {a: 1, b: 2, c: '3', d: "4"}, # Your request body + options: { + method: :post, # OPTIONAL - DEFAULT is :post, but you can use others if needed + form_id: 'CustomFormID', # OPTIONAL - DEFAULT is autogenerated + autosubmit: false, # OPTIONAL - DEFAULT is true, if you want to get a confirmation for redirect + decor: { # If autosubmit is turned off or Javascript is disabled on client + section: { # ... you can decorate confirmation section and button + classes: 'red-bg red-text', # OPTIONAL - <DIV> section, set classNames, separate with space + html: '<h1>Press this button, dude!</h1>' # OPTIONAL - Any html, which will appear before submit button + }, + submit: { + classes: 'button-decorated round-border', # OPTIONAL - <Input> with type submit, set classNames, separate with space + text: 'c0n71nue ...' # OPTIONAL - DEFAULT is 'Continue' + } + } + } +) + +``` + + + + ## Development diff --git a/repost.gemspec b/repost.gemspec index a97b8c7..5e3e450 100644 --- a/repost.gemspec +++ b/repost.gemspec @@ -26,12 +26,6 @@ Gem::Specification.new do |spec| "public gem pushes." end - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - # spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } - # end - # spec.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.rdoc'] spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }