json_form_fields 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b61ed2181a1b510d31ec7f06d9a1805c63c0478f
4
+ data.tar.gz: a951d299e770397a8d452809409cf980cb7076e9
5
+ SHA512:
6
+ metadata.gz: c61ad918396b72d92ae57c9d6f7a68f6d22eb502d8ce50b8b67a87f9452455384a4e25258033816f981b0f74d74a53110b6151124efa5596c5d5bccca50ed86b
7
+ data.tar.gz: fdca574e145db27ea87e929f81f6c1b53da437895fcf80604049357321b211a01e13de65369e9acf38759b9f06884a69fc41d1307c66b5e4c320e96ba7593d56
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Lucas Oliveira
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,36 @@
1
+ # Json Form Fields
2
+
3
+ This gem generates form inputs from JSON documents.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'json_form_fields'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install json_form_fields
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ JsonFormFields::Generator.generate_inputs({ method: ["GET", "POST"] })
25
+ ```
26
+
27
+ Will generate a select with GET and POST options. Works also with
28
+ password, email and text inputs.
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it ( https://github.com/Lucasosf/json_form_fields/fork )
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create a new Pull Request
@@ -0,0 +1,24 @@
1
+ module JsonFormFields
2
+ class Generator
3
+ def self.generate_inputs(json)
4
+ json = JSON.parse(json)
5
+ str = ''
6
+ json.keys.each do |key|
7
+ if json[key].kind_of?(Array)
8
+ str += "<select id=\"#{key}\">"
9
+ json[key].each do |option|
10
+ str += "<option value=\"#{option}\">#{option}</option>"
11
+ end
12
+ str += "</select>"
13
+ elsif /password.*/ === key
14
+ str += "<input type=\"password\" id=\"#{key}\">"
15
+ elsif /email.*/ === key
16
+ str += "<input type=\"email\" id=\"#{key}\">"
17
+ else
18
+ str += "<input type=\"text\" id=\"#{key}\">"
19
+ end
20
+ end
21
+ str
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module JsonFormFields
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "json_form_fields/version"
2
+ require 'json'
3
+
4
+ module JsonFormFields
5
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json_form_fields
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Lucas Oliveira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A gem to write form fields from JSON documents
42
+ email:
43
+ - loslucassilva@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - lib/json_form_fields.rb
51
+ - lib/json_form_fields/generator.rb
52
+ - lib/json_form_fields/version.rb
53
+ homepage: https://github.com/Lucasosf/json_form_fields
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: A gem to write form fields from JSON documents
77
+ test_files: []
78
+ has_rdoc: