signed_form-simple_form 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +12 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/lib/signed_form/simple_form.rb +7 -0
- data/lib/signed_form/simple_form/action_view/form_helper.rb +19 -0
- data/lib/signed_form/simple_form/form_builder.rb +18 -0
- data/lib/signed_form/simple_form/version.rb +5 -0
- data/signed_form-simple_form.gemspec +27 -0
- data/spec/form_builder_spec.rb +22 -0
- data/spec/spec_helper.rb +37 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 13710f3f96b69417c951cd9fe0677a4998477452
|
4
|
+
data.tar.gz: 5e30cdec9b55497d2d95f47aa0260138b0a97f7a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c2ec7239b6d8c851b1e6085ddc3b3df43be3c7a801c810fddbab7f0b569656032315d18cae2600e20187f99688f2f4391c5fb4d67b0c21700066dcbda67d958
|
7
|
+
data.tar.gz: c0652c9c8ee0baedced43a9025ed135d02675e0edcf8f5dee71828c7bcc1f96555e42d351833c02b68b104f0a6d50c586d7e3fa0e7904618ebec387e0a9ed5a3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in signed_form-simple_form.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
simple_form_version = ENV['SIMPLE_FORM_VERSION'] || 'v2.1'
|
7
|
+
|
8
|
+
case simple_form_version
|
9
|
+
when 'v2.0' then
|
10
|
+
gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.0'
|
11
|
+
when 'v2.1' then
|
12
|
+
gem 'simple_form', github: 'plataformatec/simple_form', branch: 'v2.1'
|
13
|
+
end
|
14
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Erich Menge
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# SignedForm for SimpleForm
|
2
|
+
|
3
|
+
This gem provides an adapter for SimpleForm so that you may sign those forms as well.
|
4
|
+
|
5
|
+
Please see the [SignedForm GitHub repo](https://github.com/erichmenge/signed_form) for more information on
|
6
|
+
SignedForm.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'signed_form-simple_form', require: 'signed_form/simple_form'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
``` erb
|
21
|
+
<%= signed_simple_form_for(@user) do |f| %>
|
22
|
+
<%= f.input :name %>
|
23
|
+
<% end %>
|
24
|
+
```
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module SignedForm
|
2
|
+
module SimpleForm
|
3
|
+
module ActionView
|
4
|
+
module FormHelper
|
5
|
+
def signed_simple_form_for(record, options = {}, &block)
|
6
|
+
options[:builder] ||= SignedForm::SimpleForm::FormBuilder
|
7
|
+
|
8
|
+
simple_form_for(record, options) do |f|
|
9
|
+
output = capture(f, &block)
|
10
|
+
f.form_signature_tag + output
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
ActionView::Base.send :include, SignedForm::SimpleForm::ActionView::FormHelper
|
19
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module SignedForm
|
2
|
+
module SimpleForm
|
3
|
+
class FormBuilder < ::SimpleForm::FormBuilder
|
4
|
+
include SignedForm::FormBuilder::Methods
|
5
|
+
|
6
|
+
def input(attribute_name, options = {}, &block)
|
7
|
+
add_signed_fields attribute_name
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def input_field(attribute_name, options = {})
|
12
|
+
add_signed_fields attribute_name
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'signed_form/simple_form/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "signed_form-simple_form"
|
8
|
+
spec.version = SignedForm::SimpleForm::VERSION
|
9
|
+
spec.authors = ["Erich Menge"]
|
10
|
+
spec.email = ["erich.menge@me.com"]
|
11
|
+
spec.description = %q{SimpleForm adapter for SignedForm}
|
12
|
+
spec.summary = %q{SimpleForm adapter for SignedForm}
|
13
|
+
spec.homepage = "https://github.com/erichmenge/signed_form-simple_form"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "signed_form", "< 0.2"
|
22
|
+
spec.add_dependency "simple_form", ">= 2.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec", "~> 2.13"
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SignedForm::SimpleForm::FormBuilder do
|
4
|
+
include ViewHelper
|
5
|
+
|
6
|
+
before { SignedForm::HMAC.secret_key = "abc123" }
|
7
|
+
after { SignedForm::HMAC.secret_key = nil }
|
8
|
+
|
9
|
+
it 'should build a signed form' do
|
10
|
+
content = signed_simple_form_for(:user) do |f|
|
11
|
+
f.input :name
|
12
|
+
f.input_field :bar
|
13
|
+
end
|
14
|
+
|
15
|
+
content.should =~ /form_signature/
|
16
|
+
|
17
|
+
data = get_data_from_form(content)
|
18
|
+
data.should include(:user)
|
19
|
+
data[:user].should include(:name, :bar)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'signed_form/simple_form'
|
2
|
+
|
3
|
+
module ViewHelper
|
4
|
+
include ActionView::Helpers::FormHelper
|
5
|
+
include SignedForm::ActionView::FormHelper
|
6
|
+
include SimpleForm::ActionViewExtensions::FormHelper
|
7
|
+
include SignedForm::SimpleForm::ActionView::FormHelper
|
8
|
+
|
9
|
+
attr_accessor :output_buffer
|
10
|
+
|
11
|
+
def controller(*)
|
12
|
+
double('controller', action_name: 'bar')
|
13
|
+
end
|
14
|
+
|
15
|
+
def _routes(*)
|
16
|
+
double('routes', url_for: '')
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_url_options
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
|
23
|
+
def protect_against_forgery?
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_data_from_form(content)
|
28
|
+
Marshal.load Base64.strict_decode64(content.match(/name="form_signature" value="(.*)--/)[1])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec.configure do |config|
|
33
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
34
|
+
config.run_all_when_everything_filtered = true
|
35
|
+
config.order = 'random'
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: signed_form-simple_form
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erich Menge
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: signed_form
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - <
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - <
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simple_form
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.13'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.13'
|
83
|
+
description: SimpleForm adapter for SignedForm
|
84
|
+
email:
|
85
|
+
- erich.menge@me.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- .travis.yml
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/signed_form/simple_form.rb
|
98
|
+
- lib/signed_form/simple_form/action_view/form_helper.rb
|
99
|
+
- lib/signed_form/simple_form/form_builder.rb
|
100
|
+
- lib/signed_form/simple_form/version.rb
|
101
|
+
- signed_form-simple_form.gemspec
|
102
|
+
- spec/form_builder_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/erichmenge/signed_form-simple_form
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.0.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: SimpleForm adapter for SignedForm
|
128
|
+
test_files:
|
129
|
+
- spec/form_builder_spec.rb
|
130
|
+
- spec/spec_helper.rb
|