polymer_form 0.0.2

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: 2c2c85e03c8d1ab9b45276164365c86fbe6cfd4a
4
+ data.tar.gz: dfcbfe1b73670706dfe89357b2a6ddc1e75ddb8b
5
+ SHA512:
6
+ metadata.gz: da7419e46bf7ac0b68cfa81448741906a131c36144cf7e45b01f858547d8bc3265552a9356642b0447bac362bfb057ffb9a5a4e1b488694ce8cfb47353f6962f
7
+ data.tar.gz: c509bc7c2e2e08cb41efa4fff09e45023a6104c0f99b99d7ef09cb8d6e1f7c60ffa72891b4d5cc0ba788aabca396b77f52c03ae16b916742339ef7d694d81012
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in polymer_form.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alessandro Rodi
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,40 @@
1
+ # PolymerForm
2
+
3
+ Very Super Mega Alpha Stage
4
+ This Gem would like to provide Polymer FormHelpers for Rails
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'polymer-rails', '~> 1.0'
11
+ gem 'polymer-elements-rails'
12
+ gem 'polymer_form'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install polymer_form
21
+
22
+ ## Components Provided
23
+
24
+ * paper_input
25
+ * paper_textarea
26
+
27
+ ## Usage
28
+
29
+ = polymer_form_for User.new do |f|
30
+ = f.paper_input :first_name, label: 'First Name'
31
+ = f.paper_input :last_name, label: 'Last Name'
32
+ = f.paper_textarea :description, label: 'Description'
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it ( https://github.com/[my-github-username]/polymer_form/fork )
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,5 @@
1
+ require "polymer_form/version"
2
+ require 'polymer_form/railtie' if defined?(Rails)
3
+ module PolymerForm
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,30 @@
1
+ module ActionView
2
+ module Helpers
3
+ module Tags
4
+ class PaperInput < Base
5
+
6
+ def render
7
+ options = @options.stringify_keys
8
+ options["size"] = options["maxlength"] unless options.key?("size")
9
+ options["type"] ||= field_type
10
+ options["value"] = options.fetch("value") { value_before_type_cast(object) } unless field_type == "file"
11
+ yield options if block_given?
12
+ add_default_name_and_id(options)
13
+ content_tag('paper-input', {}, options)
14
+ end
15
+
16
+ class << self
17
+ def field_type
18
+ @field_type ||= self.name.split("::").last.downcase
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def field_type
25
+ self.class.field_type
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,30 @@
1
+ module ActionView
2
+ module Helpers
3
+ module Tags
4
+ class PaperTextarea < Base
5
+ def render
6
+ options = @options.stringify_keys
7
+ add_default_name_and_id(options)
8
+
9
+ if size = options.delete('size')
10
+ options['cols'], options['rows'] = size.split('x') if size.respond_to?(:split)
11
+ end
12
+
13
+ content_tag('paper-textarea', options.delete('value') { value_before_type_cast(object) }, options)
14
+ end
15
+
16
+ class << self
17
+ def field_type
18
+ @field_type ||= self.name.split("::").last.downcase
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def field_type
25
+ self.class.field_type
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ class PolymerFormBuilder < ActionView::Helpers::FormBuilder
2
+ def paper_input(method, options = {})
3
+ @template.send(
4
+ "paper_input",
5
+ @object_name,
6
+ method,
7
+ objectify_options(options))
8
+ end
9
+
10
+ def paper_textarea(method, options = {})
11
+ @template.send(
12
+ 'paper_textarea',
13
+ @object_name,
14
+ method,
15
+ objectify_options(options))
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'polymer_form/action_view/helpers/tags/paper_input'
2
+ require 'polymer_form/action_view/helpers/tags/paper_textarea'
3
+
4
+ module PolymerHelper
5
+ def paper_input(object_name, method, options = {})
6
+ ActionView::Helpers::Tags::PaperInput.new(object_name, method, self, options).render
7
+ end
8
+
9
+ def paper_textarea(object_name, method, options = {})
10
+ ActionView::Helpers::Tags::PaperTextarea.new(object_name, method, self, options).render
11
+ end
12
+
13
+ def polymer_form_for(object, *args, &block)
14
+ options = args.extract_options!
15
+ form_for(object, *(args << options.merge(builder: PolymerFormBuilder)), &block)
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require 'polymer_form/polymer_helper'
2
+ require 'polymer_form/polymer_form_builder'
3
+ module PolymerForm
4
+ class Railtie < Rails::Railtie
5
+ initializer 'polymer_form.view_helpers' do
6
+ ActionView::Base.send :include, PolymerHelper
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module PolymerForm
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'polymer_form/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "polymer_form"
8
+ spec.version = PolymerForm::VERSION
9
+ spec.authors = ["Alessandro Rodi"]
10
+ spec.email = ["coorasse@gmail.com"]
11
+ spec.summary = %q{Build awesome forms with Polymer and Rails}
12
+ spec.description = %q{Build awesome forms with Polymer and Rails}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: polymer_form
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Alessandro Rodi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 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: Build awesome forms with Polymer and Rails
42
+ email:
43
+ - coorasse@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/polymer_form.rb
54
+ - lib/polymer_form/action_view/helpers/tags/paper_input.rb
55
+ - lib/polymer_form/action_view/helpers/tags/paper_textarea.rb
56
+ - lib/polymer_form/polymer_form_builder.rb
57
+ - lib/polymer_form/polymer_helper.rb
58
+ - lib/polymer_form/railtie.rb
59
+ - lib/polymer_form/version.rb
60
+ - polymer_form.gemspec
61
+ homepage: ''
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.4.5
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Build awesome forms with Polymer and Rails
85
+ test_files: []