yaml_form_helper 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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,34 @@
1
+ YamlFormHelper
2
+ ==============
3
+
4
+ The YamlFormHelper is a Rails Plugin that extends the FormBuilder Class with methods to create form tags for the HTML/CSS Framework YAML (http://www.yaml.de/)
5
+
6
+ You might want to check out my compass plugin cyaml at https://github.com/servasat/cyaml
7
+
8
+
9
+ Installation
10
+ ============
11
+
12
+ Add this to your Gemfile
13
+
14
+ gem 'yaml_form_helper', :git => 'git://github.com/servasat/yaml_form_helper.git'
15
+
16
+ and run bundle install
17
+
18
+ Now include it in your Helpers
19
+
20
+ module ApplicationHelper
21
+ include YamlFormHelper
22
+ end
23
+
24
+
25
+ Example
26
+ =======
27
+
28
+ <%= yaml_form_for(@bird) do |f| %>
29
+ <%= f.yaml_text_field :name %>
30
+ <%= f.yaml_submit %>
31
+ <% end %>
32
+
33
+
34
+ Copyright (c) 2011 Michael Gerber, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,24 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rdoc/task'
4
+ require 'bundler/gem_tasks'
5
+
6
+ desc 'Default: run unit tests.'
7
+ task :default => :test
8
+
9
+ desc 'Test the yaml_form_helper plugin.'
10
+ Rake::TestTask.new(:test) do |t|
11
+ t.libs << 'lib'
12
+ t.libs << 'test'
13
+ t.pattern = 'test/**/*_test.rb'
14
+ t.verbose = true
15
+ end
16
+
17
+ desc 'Generate documentation for the yaml_form_helper plugin.'
18
+ RDoc::Task.new(:rdoc) do |rdoc|
19
+ rdoc.rdoc_dir = 'rdoc'
20
+ rdoc.title = 'YamlFormHelper'
21
+ rdoc.options << '--line-numbers' << '--inline-source'
22
+ rdoc.rdoc_files.include('README')
23
+ rdoc.rdoc_files.include('lib/**/*.rb')
24
+ end
@@ -0,0 +1,7 @@
1
+ module YamlFormHelper
2
+ def yaml_form_for(record, type = 'full', form_options = {}, &proc)
3
+ form_options[:html] = {} if ! form_options[:html]
4
+ form_options[:html].merge!(:class => "yform #{type}")
5
+ form_for(record, {}, form_options, &proc)
6
+ end
7
+ end
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,54 @@
1
+ ActionView::Helpers::FormBuilder.class_eval do
2
+ # YAML TAGS
3
+ # generates form tags that work with the YAML CSS-Framework
4
+ def yaml_text_field(attr, label = attr)
5
+ yaml_tag self.text_field(attr), self.label(attr, label), has_errors(attr)
6
+ end
7
+
8
+ def yaml_file_field(attr, label = attr)
9
+ yaml_tag self.file_field(attr), self.label(attr, label), has_errors(attr)
10
+ end
11
+
12
+ def yaml_number_field(attr, label = attr)
13
+ yaml_tag self.number_field(attr), self.label(attr, label), has_errors(attr)
14
+ end
15
+
16
+ def yaml_text_area(attr, params = {}, label = attr )
17
+ yaml_tag self.text_area(attr, params), self.label(attr, label), has_errors(attr)
18
+ end
19
+
20
+ def yaml_password_field(attr, label = attr)
21
+ yaml_tag self.password_field(attr), self.label(attr, label), has_errors(attr)
22
+ end
23
+
24
+ def yaml_checkbox(attr, f, label = attr )
25
+ yaml_tag self.password_field(attr), self.label(attr, label), has_errors(attr), 'check'
26
+ end
27
+
28
+ def yaml_select(attr, f, options, tag_options = {}, label = attr )
29
+ yaml_tag self.select(attr, options, tag_options), self.label(attr, label), has_errors(attr), 'select'
30
+ end
31
+
32
+ def yaml_multi_select(attr, select_options, options = {}, tag_options = {}, label = attr )
33
+ options.merge!({:selected => f.object.send(attr+"_ids")})
34
+ tag_options.merge!({:multiple=>true, :size=>6, :name => "#{f.object.class.to_s.downcase}[#{attr}_ids][]"})
35
+ yaml_tag collection_select(self.object.class.to_s.downcase, attr.pluralize, select_options, :id, :to_s, options, tag_options ), self.label(attr, label), has_errors(attr), 'select'
36
+ end
37
+
38
+ def yaml_submit(name = "Submit")
39
+ "<div class='type-button'>
40
+ #{self.submit name, :class => 'submit' }
41
+ </div>".html_safe
42
+ end
43
+
44
+ def yaml_tag(tag, label, error = false, type = 'text')
45
+ "<div class='type-#{type} #{ 'error' if error }'>
46
+ #{label}
47
+ #{tag}
48
+ </div>".html_safe
49
+ end
50
+
51
+ def has_errors(attr)
52
+ return !self.object.errors[attr].empty?
53
+ end
54
+ end
@@ -0,0 +1,9 @@
1
+ # YamlFormHelper
2
+ require "yaml_form_helper/form_builder_ext"
3
+
4
+ %w{ helpers }.each do |dir|
5
+ path = File.join(File.dirname(__FILE__), 'app', dir)
6
+ $LOAD_PATH << path
7
+ ActiveSupport::Dependencies.autoload_paths << path
8
+ ActiveSupport::Dependencies.autoload_once_paths.delete(path)
9
+ end
data/rails/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require 'yaml_form_helper'
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_support'
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class YamlFormHelperTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yaml_form_helper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Michael Gerber
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-09 00:00:00 Z
19
+ dependencies: []
20
+
21
+ description: The YamlFormHelper is a Rails Plugin that extends the FormBuilder Class with methods to create form tags for the HTML/CSS Framework YAML (http://www.yaml.de/)
22
+ email:
23
+ - mike@citrin.ch
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - MIT-LICENSE
32
+ - README
33
+ - Rakefile
34
+ - app/helpers/yaml_form_helper.rb
35
+ - install.rb
36
+ - lib/yaml_form_helper.rb
37
+ - lib/yaml_form_helper/form_builder_ext.rb
38
+ - rails/init.rb
39
+ - test/test_helper.rb
40
+ - test/yaml_form_helper_test.rb
41
+ - uninstall.rb
42
+ homepage: https://github.com/servasat/yaml_form_helper
43
+ licenses: []
44
+
45
+ post_install_message:
46
+ rdoc_options: []
47
+
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project: yaml_form_helper
71
+ rubygems_version: 1.8.7
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Rails Plugin for YAML Forms
75
+ test_files:
76
+ - test/test_helper.rb
77
+ - test/yaml_form_helper_test.rb