Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
vergilet committed Jan 25, 2019
1 parent 8fb6d29 commit b6f369b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
repost (0.2.1)
repost (0.2.2)

GEM
remote: https://rubygems.org/
Expand Down
81 changes: 77 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
6 changes: 0 additions & 6 deletions repost.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit b6f369b

Please sign in to comment.