mustache_form 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6a3874eb1b2b591a7d98fc14b476ab3f16b8477
4
+ data.tar.gz: 033d6ccab29e0813f1162a7f41308dec88135aa9
5
+ SHA512:
6
+ metadata.gz: 003fa3e0f7f3532f118c0e3144ed216d2f6e176f676d3462f8473dfc428938d862dd415b2c65bbd6750b30ed8647c5aa084de9022dfff1138c0fc7bd1b0dfc3f
7
+ data.tar.gz: e2b812055d236b4ad71e49cca805c91dc969067f76e7ecfb636f11c20c66884a66f5cca3e6c06f641069027836a6bf073ebb5b9739eea2c0db2f80638079c593
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ mustache_form
@@ -0,0 +1 @@
1
+ ruby-2.2.2
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mustache_form.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ # MustacheForm
2
+
3
+ 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/mustache_form`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'mustache_form'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mustache_form
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mustache_form.
36
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mustache_form"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ require "mustache_form/version"
2
+ #
3
+ require File.dirname(__FILE__) + '/mustache_form/form_helper'
4
+ require File.dirname(__FILE__) + '/mustache_form/railtie' if defined? ::Rails::Railtie
5
+ #
6
+ module MustacheForm
7
+ class Config
8
+ attr_accessor :simple_form_enabled
9
+ end
10
+
11
+ def self.config
12
+ @@config ||= Config.new
13
+ end
14
+
15
+ def self.configure
16
+ yield self.config
17
+ end
18
+ end
@@ -0,0 +1,68 @@
1
+ require 'mustache'
2
+ #
3
+ module MustacheForm
4
+ module FormHelper
5
+
6
+ def custom_form_tag(url: nil, html: nil)
7
+ # When the Mustache variable is a callable object, such as a function or lambda, the
8
+ # object will be invoked and passed the block of text. hence we then yield to the
9
+ # standard ruby form_for to build our form and then have Mustache render each key value pair
10
+ lambda do |text|
11
+ form_tag(url: url, html: html) do |f|
12
+ obj = FormedMustache.new(yield(f))
13
+ Mustache.render(text, obj).html_safe
14
+ end
15
+ end
16
+ end
17
+
18
+ def custom_form_for(object, url: nil, html: nil)
19
+ # When the Mustache variable is a callable object, such as a function or lambda, the
20
+ # object will be invoked and passed the block of text. hence we then yield to the
21
+ # standard ruby form_for to build our form and then have Mustache render each key value pair
22
+ lambda do |text|
23
+ form_for(object, url: url, html: html) do |f|
24
+ obj = FormedMustache.new(yield(f))
25
+ Mustache.render(text, obj).html_safe
26
+ end
27
+ end
28
+ end
29
+
30
+ def custom_simple_form_tag(url: nil, html: nil)
31
+ # When the Mustache variable is a callable object, such as a function or lambda, the
32
+ # object will be invoked and passed the block of text. hence we then yield to the
33
+ # standard ruby form_for to build our form and then have Mustache render each key value pair
34
+ lambda do |text|
35
+ simple_form_tag(url: url, html: html) do |f|
36
+ obj = FormedMustache.new(yield(f))
37
+ Mustache.render(text, obj).html_safe
38
+ end
39
+ end
40
+ end
41
+
42
+ def custom_simple_form_for(object, url: nil, html: nil)
43
+ # When the Mustache variable is a callable object, such as a function or lambda, the
44
+ # object will be invoked and passed the block of text. hence we then yield to the
45
+ # standard ruby form_for to build our form and then have Mustache render each key value pair
46
+ lambda do |text|
47
+ simple_form_for(object, url: url, html: html) do |f|
48
+ obj = FormedMustache.new(yield(f))
49
+ Mustache.render(text, obj).html_safe
50
+ end
51
+ end
52
+ end
53
+ end
54
+ #
55
+ class FormedMustache < Mustache
56
+
57
+ def initialize(data)
58
+ data.each_pair do |key, value|
59
+ #puts "\n\nFormedMustache k:#{key}, v: #{value}\n\n"
60
+ FormedMustache.send(:define_method, key, proc{value})
61
+ end
62
+ end
63
+
64
+ def escapeHTML(str)
65
+ str
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,19 @@
1
+ #
2
+ module MustacheForm
3
+ class Railtie < Rails::Railtie
4
+ #
5
+ # enable namespaced configuration in Rails environments
6
+ config.mustache_form = ActiveSupport::OrderedOptions.new
7
+ #
8
+ initializer :after_initialize do |app|
9
+ #
10
+ MustacheForm.configure do |config|
11
+ config.simple_form_enabled = app.config.mustache_form[:simple_form_enabled]
12
+ end
13
+ #
14
+ # dynamically load the client rails app module that has the stuff
15
+ #LoadLists.load
16
+ end
17
+ end
18
+ end
19
+ #
@@ -0,0 +1,3 @@
1
+ module MustacheForm
2
+ VERSION = "0.1.1"
3
+ end
File without changes
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mustache_form/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mustache_form"
8
+ spec.version = MustacheForm::VERSION
9
+ spec.authors = ["Steve Forkin"]
10
+ spec.email = ["steve.forkin@gmail.com"]
11
+
12
+ spec.summary = %q{small library to handle integrated mustache and rails form helpers}
13
+ spec.description = %q{Also support for simple_form gem included}
14
+ spec.homepage = "http://github.com/netflakes/mustache_form"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ # Development dependencies
22
+ #
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "coveralls"
26
+ #
27
+ # - gem related ones
28
+ spec.add_development_dependency 'mustache'
29
+ spec.add_development_dependency 'rack'
30
+ spec.add_development_dependency 'rspec'
31
+ spec.add_development_dependency 'rspec-given'
32
+ spec.add_development_dependency 'rspec-collection_matchers'
33
+ spec.add_development_dependency 'rspec-rails'
34
+ #
35
+ # Runtime dependencies
36
+ #
37
+ spec.add_runtime_dependency 'rails', '>= 4.1.1'
38
+ end
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mustache_form
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Steve Forkin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-30 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mustache
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: rack
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-given
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-collection_matchers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-rails
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rails
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 4.1.1
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 4.1.1
153
+ description: Also support for simple_form gem included
154
+ email:
155
+ - steve.forkin@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".ruby-gemset"
163
+ - ".ruby-version"
164
+ - ".travis.yml"
165
+ - Gemfile
166
+ - README.md
167
+ - Rakefile
168
+ - bin/console
169
+ - bin/setup
170
+ - lib/mustache_form.rb
171
+ - lib/mustache_form/form_helper.rb
172
+ - lib/mustache_form/railtie.rb
173
+ - lib/mustache_form/version.rb
174
+ - log/test.log
175
+ - mustache_form.gemspec
176
+ homepage: http://github.com/netflakes/mustache_form
177
+ licenses: []
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.4.5
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: small library to handle integrated mustache and rails form helpers
199
+ test_files: []