formie 0.5.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.
Files changed (46) hide show
  1. data/.rspec +2 -0
  2. data/.watchr +56 -0
  3. data/Gemfile +15 -0
  4. data/Gemfile.lock +134 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +77 -0
  7. data/Rakefile +30 -0
  8. data/config/initializers/formie.rb +1 -0
  9. data/formie.gemspec +27 -0
  10. data/lib/formie/engine.rb +4 -0
  11. data/lib/formie/version.rb +3 -0
  12. data/lib/formie.rb +65 -0
  13. data/spec/controllers/orders_spec.rb +11 -0
  14. data/spec/dummy/Rakefile +7 -0
  15. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  16. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  17. data/spec/dummy/app/controllers/orders_controller.rb +16 -0
  18. data/spec/dummy/app/formies/application/copyright.html.erb +3 -0
  19. data/spec/dummy/app/formies/forms/builtins.html.erb +7 -0
  20. data/spec/dummy/app/formies/forms/l_field.html.erb +4 -0
  21. data/spec/dummy/app/models/order.rb +10 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +12 -0
  23. data/spec/dummy/app/views/orders/_form.html.erb +7 -0
  24. data/spec/dummy/app/views/orders/_new.html.erb +1 -0
  25. data/spec/dummy/app/views/orders/index.html.erb +1 -0
  26. data/spec/dummy/app/views/orders/new.html.erb +3 -0
  27. data/spec/dummy/app/views/orders/show.html.erb +3 -0
  28. data/spec/dummy/config/application.rb +49 -0
  29. data/spec/dummy/config/boot.rb +9 -0
  30. data/spec/dummy/config/database.yml +22 -0
  31. data/spec/dummy/config/environment.rb +5 -0
  32. data/spec/dummy/config/environments/development.rb +30 -0
  33. data/spec/dummy/config/environments/production.rb +60 -0
  34. data/spec/dummy/config/environments/test.rb +40 -0
  35. data/spec/dummy/config/initializers/secret_token.rb +1 -0
  36. data/spec/dummy/config/initializers/session_store.rb +8 -0
  37. data/spec/dummy/config/routes.rb +4 -0
  38. data/spec/dummy/config.ru +4 -0
  39. data/spec/dummy/db/migrate/001_create_orders.rb +10 -0
  40. data/spec/dummy/db/schema.rb +23 -0
  41. data/spec/dummy/db/seeds.rb +7 -0
  42. data/spec/dummy/public/favicon.ico +0 -0
  43. data/spec/dummy/script/rails +6 -0
  44. data/spec/integration/order_spec.rb +32 -0
  45. data/spec/spec_helper.rb +63 -0
  46. metadata +158 -0
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour --drb
2
+ #--format=documentation
data/.watchr ADDED
@@ -0,0 +1,56 @@
1
+ def run(cmd)
2
+ puts "***** #{cmd}"
3
+ system "/usr/bin/time --format 'Elapsed time %E' #{cmd}"
4
+ end
5
+
6
+ def run_without(list)
7
+ all = Dir.glob("spec/**/*_spec.rb")
8
+ res = []
9
+ list.each { |str|
10
+ files = Dir.glob("spec/**/#{str}/*_spec.rb")
11
+ res << files
12
+ }
13
+ run "rspec #{(all - res.flatten).sort.uniq.join(' ')}"
14
+ end
15
+
16
+ def run_matching(name)
17
+ arr = name.gsub('_', '/').split('/')
18
+ bool = false
19
+ arr.each { |str|
20
+ files = Dir.glob("spec/**/#{str}_spec.rb")
21
+ files.each { |file|
22
+ bool = true
23
+ run "rspec #{file}"
24
+ }
25
+ }
26
+ puts "***** Changed #{name}; not yet done" unless bool
27
+ end
28
+
29
+
30
+ watch('spec/.*/*_spec\.rb') { |match| run "rspec #{match[0]}" }
31
+ watch('spec/.*/.*/*_spec\.rb') { |match| run "rspec #{match[0]}" }
32
+
33
+ watch('app/(.*)?\.rb') { |match|
34
+ puts "** touched #{match[1]}"
35
+ file = "spec/#{match[1]}_spec.rb"
36
+ if File.exists?(file)
37
+ run "rspec #{file}"
38
+ else
39
+ run_matching match[1]
40
+ end
41
+ }
42
+
43
+ watch('app/views/(.*)?\.erb') { |match|
44
+ puts "** touched #{match[1]}"
45
+ run_without ['models']
46
+ }
47
+
48
+
49
+ # Ctrl-\ or ctrl-4
50
+ Signal.trap('QUIT') do
51
+ puts "\n--- Running all tests ---\n"
52
+ run 'rake spec'
53
+ end
54
+
55
+ # Ctrl-C
56
+ Signal.trap('INT') { abort("Interrupted\n") }
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", '3.1.0'
4
+ gem 'jquery-rails'
5
+
6
+ group :test do
7
+ gem "capybara"
8
+ gem 'rspec-rails'
9
+ end
10
+
11
+ group :development, :test do
12
+ gem "sqlite3"
13
+ gem 'watchr'
14
+ gem 'spork'
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,134 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.0)
5
+ actionpack (= 3.1.0)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.0)
8
+ activemodel (= 3.1.0)
9
+ activesupport (= 3.1.0)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.2)
14
+ rack-cache (~> 1.0.3)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.0)
18
+ activemodel (3.1.0)
19
+ activesupport (= 3.1.0)
20
+ bcrypt-ruby (~> 3.0.0)
21
+ builder (~> 3.0.0)
22
+ i18n (~> 0.6)
23
+ activerecord (3.1.0)
24
+ activemodel (= 3.1.0)
25
+ activesupport (= 3.1.0)
26
+ arel (~> 2.2.1)
27
+ tzinfo (~> 0.3.29)
28
+ activeresource (3.1.0)
29
+ activemodel (= 3.1.0)
30
+ activesupport (= 3.1.0)
31
+ activesupport (3.1.0)
32
+ multi_json (~> 1.0)
33
+ arel (2.2.1)
34
+ bcrypt-ruby (3.0.1)
35
+ builder (3.0.0)
36
+ capybara (1.1.2)
37
+ mime-types (>= 1.16)
38
+ nokogiri (>= 1.3.3)
39
+ rack (>= 1.0.0)
40
+ rack-test (>= 0.5.4)
41
+ selenium-webdriver (~> 2.0)
42
+ xpath (~> 0.1.4)
43
+ childprocess (0.3.0)
44
+ ffi (~> 1.0.6)
45
+ diff-lcs (1.1.3)
46
+ erubis (2.7.0)
47
+ ffi (1.0.11)
48
+ hike (1.2.1)
49
+ i18n (0.6.0)
50
+ jquery-rails (1.0.19)
51
+ railties (~> 3.0)
52
+ thor (~> 0.14)
53
+ json (1.6.4)
54
+ mail (2.3.0)
55
+ i18n (>= 0.4.0)
56
+ mime-types (~> 1.16)
57
+ treetop (~> 1.4.8)
58
+ mime-types (1.17.2)
59
+ multi_json (1.0.4)
60
+ nokogiri (1.5.0)
61
+ polyglot (0.3.3)
62
+ rack (1.3.6)
63
+ rack-cache (1.0.3)
64
+ rack (>= 0.4)
65
+ rack-mount (0.8.3)
66
+ rack (>= 1.0.0)
67
+ rack-ssl (1.3.2)
68
+ rack
69
+ rack-test (0.6.1)
70
+ rack (>= 1.0)
71
+ rails (3.1.0)
72
+ actionmailer (= 3.1.0)
73
+ actionpack (= 3.1.0)
74
+ activerecord (= 3.1.0)
75
+ activeresource (= 3.1.0)
76
+ activesupport (= 3.1.0)
77
+ bundler (~> 1.0)
78
+ railties (= 3.1.0)
79
+ railties (3.1.0)
80
+ actionpack (= 3.1.0)
81
+ activesupport (= 3.1.0)
82
+ rack-ssl (~> 1.3.2)
83
+ rake (>= 0.8.7)
84
+ rdoc (~> 3.4)
85
+ thor (~> 0.14.6)
86
+ rake (0.9.2.2)
87
+ rdoc (3.12)
88
+ json (~> 1.4)
89
+ rspec (2.8.0)
90
+ rspec-core (~> 2.8.0)
91
+ rspec-expectations (~> 2.8.0)
92
+ rspec-mocks (~> 2.8.0)
93
+ rspec-core (2.8.0)
94
+ rspec-expectations (2.8.0)
95
+ diff-lcs (~> 1.1.2)
96
+ rspec-mocks (2.8.0)
97
+ rspec-rails (2.8.1)
98
+ actionpack (>= 3.0)
99
+ activesupport (>= 3.0)
100
+ railties (>= 3.0)
101
+ rspec (~> 2.8.0)
102
+ rubyzip (0.9.5)
103
+ selenium-webdriver (2.16.0)
104
+ childprocess (>= 0.2.5)
105
+ ffi (~> 1.0.9)
106
+ multi_json (~> 1.0.4)
107
+ rubyzip
108
+ spork (0.8.5)
109
+ sprockets (2.0.3)
110
+ hike (~> 1.2)
111
+ rack (~> 1.0)
112
+ tilt (~> 1.1, != 1.3.0)
113
+ sqlite3 (1.3.5)
114
+ thor (0.14.6)
115
+ tilt (1.3.3)
116
+ treetop (1.4.10)
117
+ polyglot
118
+ polyglot (>= 0.3.1)
119
+ tzinfo (0.3.31)
120
+ watchr (0.7)
121
+ xpath (0.1.4)
122
+ nokogiri (~> 1.3)
123
+
124
+ PLATFORMS
125
+ ruby
126
+
127
+ DEPENDENCIES
128
+ capybara
129
+ jquery-rails
130
+ rails (= 3.1.0)
131
+ rspec-rails
132
+ spork
133
+ sqlite3
134
+ watchr
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Dittmar Krall - http://matique.de
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.md ADDED
@@ -0,0 +1,77 @@
1
+ Formie
2
+ ======
3
+
4
+ Tired of programming each HTML tag? Are you in search of DRYness for Rails
5
+ views? May be Formie can help you.
6
+
7
+ Formie is a low level template-based rendering engine. It injects
8
+ the formies into the ActionView module. The form-bounded as well as
9
+ the unbounded templates are supported. Still, the ActionView
10
+ functionality (e.g. text_field) is kept untouched.
11
+ In short, Formie is like a helper using the notation of a partial.
12
+
13
+ Templates for Formie are hosted in:
14
+
15
+ - app/formies/forms (bounded to form)
16
+ - app/formies/application (free standing)
17
+
18
+ Inside a formie the following locals (as delivered by the
19
+ controller) are available:
20
+
21
+ - action_name
22
+ - args remainings after extracting options/locals
23
+ - block block passed to the formie
24
+ - controller_name
25
+ - form (available inside form_for (similar to fields_for))
26
+ - form.object
27
+ - params
28
+
29
+ Locals are passed by a hash.
30
+ The controller attributes are available as usual.
31
+
32
+ To avoid a server restart during development of formies you may add to:
33
+
34
+ # app/controllers/application_controller.rb
35
+
36
+ before_filter do
37
+ Formie.reload if 'development' == Rails.env
38
+ end
39
+
40
+
41
+ Examples
42
+ ========
43
+
44
+ <%= copyright %>
45
+ <%= back %>
46
+ <%= show :obj => @order %>
47
+
48
+ <%= form_for :order do |f| %>
49
+ <%= f.who %>
50
+ <%= f.amount %>
51
+ <% end %>
52
+
53
+ In directory app/formies :
54
+
55
+ # application/copyright.html.erb
56
+ <div class="copyright"> Copyright (c) 2009 </div>
57
+
58
+ # application/back.html.erb
59
+ <a href="<%= "/#{h(controller_name)}" %>"> Back </a>
60
+
61
+ # application/show.html.erb
62
+ <a href="<%= "/#{h(controller_name)}/#{obj.id}" %>"> Show </a>
63
+
64
+ # forms/who.html.erb
65
+ <%= form.labelled_field :field => :who %>
66
+
67
+ # forms/amount.html.erb
68
+ <%= form.labelled_field :field => :amount %>
69
+
70
+ # forms/labelled_field.html.erb
71
+ <label style="width: 8em; display: block; float: left;">
72
+ <%= field.to_s.capitalize %>
73
+ </label>
74
+ <%= form.text_field field %> <br />
75
+
76
+
77
+ Copyright (c) 2009..2012 Dittmar Krall, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+
3
+ begin
4
+ require 'bundler'
5
+ require 'bundler/setup'
6
+ rescue LoadError
7
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
8
+ end
9
+
10
+ require 'rspec/core'
11
+ require 'rspec/core/rake_task'
12
+
13
+ Bundler::GemHelper.install_tasks
14
+ RSpec::Core::RakeTask.new(:spec)
15
+
16
+ task :default => :spec
17
+
18
+
19
+ desc "Clean automatically generated files"
20
+ task :clean do
21
+ FileUtils.rm_rf "pkg"
22
+ end
23
+
24
+ desc "Check syntax"
25
+ task :syntax do
26
+ Dir["**/*.rb"].each do |file|
27
+ print "#{file}: "
28
+ system("ruby -c #{file}")
29
+ end
30
+ end
@@ -0,0 +1 @@
1
+ Formie.reload
data/formie.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
4
+ require 'formie/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "formie"
8
+ s.version = Formie::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = "Like a helper, but based on html."
11
+ s.description = "app/formies/labelled_field.html.erb"
12
+ s.authors = ['Dittmar Krall']
13
+ s.email = ['dittmar.krall@matique.de']
14
+ s.homepage = 'http://matique.de'
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ # specify any dependencies here; for example:
21
+ # s.add_development_dependency "rspec"
22
+ # s.add_runtime_dependency "rest-client"
23
+
24
+ s.add_development_dependency "sqlite3" # for testing
25
+ s.add_development_dependency "rspec-rails"
26
+ s.add_development_dependency "capybara"
27
+ end
@@ -0,0 +1,4 @@
1
+ module Formie
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Formie
2
+ VERSION = '0.5.2'
3
+ end
data/lib/formie.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'formie/engine.rb'
2
+
3
+ module Formie
4
+
5
+ def self.reload
6
+ now = Time.now
7
+ @last_update ||= Time.new(0)
8
+ self.load_formies(::ActionView::Helpers::FormBuilder, 'app/formies/forms')
9
+ self.load_formies(::ActionView::Helpers::TextHelper, 'app/formies/application')
10
+ @last_update = now
11
+ end
12
+
13
+ def self.define_formie(where, name, txt)
14
+ formiename = name
15
+
16
+ where.send(:define_method, formiename, lambda {|*args, &block|
17
+ #p "** called #{where} #{formiename}", args, block
18
+ params = args.extract_options!
19
+ options = {}
20
+ options[:inline] = txt
21
+ options[:locals] = {}
22
+ options[:locals].update params
23
+ options[:locals].update :formiename => formiename,
24
+ :block => block, :form => self, :args => args
25
+ (@template && @template.render(options)) ||
26
+ controller.render_to_body(options)
27
+ })
28
+ #p "** defined #{where} #{formiename}"
29
+ end
30
+
31
+
32
+ private
33
+ def self.load_formies(where, dir)
34
+ dir = "#{::Rails.root.to_s}/#{dir}"
35
+ raise "Missing Formie directory '#{dir}'" unless File.exists?(dir)
36
+ Dir.chdir(dir) {|current_dir|
37
+ Dir.glob('**/*.html.erb').each {|path|
38
+ next if File.new(path).mtime < @last_update
39
+
40
+ name = File.basename(path, '.html.erb')
41
+ self.inject(where, name, File.open(path).read)
42
+ }
43
+ }
44
+ end
45
+
46
+ def self.inject(where, name, txt)
47
+ #puts "** loading formie '#{where}' - '#{name}'"
48
+ txt = txt.force_encoding('UTF-8') if txt.respond_to?(:force_encoding)
49
+ where.define_formie name, txt
50
+ end
51
+
52
+ end
53
+
54
+
55
+ module ActionView::Helpers::TextHelper
56
+ def self.define_formie(name, txt)
57
+ Formie.define_formie(self, name, txt)
58
+ end
59
+ end
60
+
61
+ class ActionView::Helpers::FormBuilder
62
+ def self.define_formie(name, txt)
63
+ Formie.define_formie(self, name, txt)
64
+ end
65
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe OrdersController, ':' do
4
+ render_views
5
+
6
+ it 'checking formie copyright' do
7
+ get :index
8
+ response.body.should =~ /copyright/
9
+ end
10
+
11
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,8 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+
4
+ before_filter do
5
+ Formie.reload if 'development' == Rails.env
6
+ end
7
+
8
+ end
@@ -0,0 +1,16 @@
1
+ class OrdersController < ApplicationController
2
+
3
+ def index
4
+ @orders = Order.all
5
+ end
6
+
7
+ def new
8
+ @order = Order.new
9
+ end
10
+
11
+ def show
12
+ Order.create :name => 'hugo'
13
+ @order = Order.find(params[:id])
14
+ end
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ <% year ||= args.first || Time.now.year %>
2
+
3
+ <div class="copyright"> Copyright (c) <%= year %> </div>
@@ -0,0 +1,7 @@
1
+ action_name <%= action_name %> <br/>
2
+ args <%= args %> <br/>
3
+ block <%= block.call(3) %> <br/>
4
+ controller_name <%= controller_name %> <br/>
5
+ form <%= form.class.name %> <br/>
6
+ form.object <%= form.object.class.name %> <br/>
7
+ params <%= params[:action] %> <br/>
@@ -0,0 +1,4 @@
1
+ <p class="labelled">
2
+ <label> <%= field %> </label>
3
+ <%= form.text_field(field) %>
4
+ </p>
@@ -0,0 +1,10 @@
1
+ class Order < ActiveRecord::Base
2
+
3
+ before_save do |row|
4
+ return true unless row.name == 'error'
5
+
6
+ row.errors.add :base, 'panic'
7
+ return false
8
+ end
9
+
10
+ end
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%#= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+ <%= yield %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,7 @@
1
+ <%
2
+ # This is a typical form
3
+ # Requires f
4
+ %>
5
+
6
+ <%= f.l_field :field => :name %>
7
+ <%= f.l_field :field => :qty %>
@@ -0,0 +1 @@
1
+ <%= f.builtins(123, 456) {|n| n + 1 } %>
@@ -0,0 +1 @@
1
+ <%= copyright(2000) %>
@@ -0,0 +1,3 @@
1
+ <%= form_for @order do |f| %>
2
+ <%= render 'new', :f => f %>
3
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <%= form_for @order do |f| %>
2
+ <%= render 'form', :f => f %>
3
+ <% end %>
@@ -0,0 +1,49 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+ require 'formie'
5
+
6
+ if defined?(Bundler)
7
+ # If you precompile assets before deploying to production, use this line
8
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
9
+ # If you want your assets lazily compiled in production, use this line
10
+ # Bundler.require(:default, :assets, Rails.env)
11
+ end
12
+
13
+ module Dummy
14
+ class Application < Rails::Application
15
+ # Settings in config/environments/* take precedence over those specified here.
16
+ # Application configuration should go into files in config/initializers
17
+ # -- all .rb files in that directory are automatically loaded.
18
+
19
+ # Custom directories with classes and modules you want to be autoloadable.
20
+ # config.autoload_paths += %W(#{config.root}/extras)
21
+
22
+ # Only load the plugins named here, in the order given (default is alphabetical).
23
+ # :all can be used as a placeholder for all plugins not explicitly named.
24
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
25
+
26
+ # Activate observers that should always be running.
27
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
28
+
29
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
30
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
31
+ # config.time_zone = 'Central Time (US & Canada)'
32
+
33
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
34
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
35
+ # config.i18n.default_locale = :de
36
+
37
+ # Configure the default encoding used in templates for Ruby 1.9.
38
+ config.encoding = "utf-8"
39
+
40
+ # Configure sensitive parameters which will be filtered from the log file.
41
+ config.filter_parameters += [:password]
42
+
43
+ # Enable the asset pipeline
44
+ config.assets.enabled = true
45
+
46
+ # Version of your assets, change this if you want to expire all your assets
47
+ config.assets.version = '1.0'
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ #ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
6
+
7
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
8
+
9
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,22 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ development:
4
+ adapter: sqlite3
5
+ database: db/development.sqlite3
6
+ pool: 5
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as "test" will be erased and
10
+ # re-generated from your development database when you run "rake".
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ pool: 5
16
+ timeout: 5000
17
+
18
+ production:
19
+ adapter: sqlite3
20
+ database: db/production.sqlite3
21
+ pool: 5
22
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = false
30
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end
@@ -0,0 +1,40 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ #DK config.cache_classes = true
9
+ config.cache_classes = false
10
+
11
+ # Configure static asset server for tests with Cache-Control for performance
12
+ config.serve_static_assets = true
13
+ config.static_cache_control = "public, max-age=3600"
14
+
15
+ # Log error messages when you accidentally call methods on nil
16
+ config.whiny_nils = true
17
+
18
+ # Show full error reports and disable caching
19
+ config.consider_all_requests_local = true
20
+ config.action_controller.perform_caching = false
21
+
22
+ # Raise exceptions instead of rendering exception templates
23
+ config.action_dispatch.show_exceptions = false
24
+
25
+ # Disable request forgery protection in test environment
26
+ config.action_controller.allow_forgery_protection = false
27
+
28
+ # Tell Action Mailer not to deliver emails to the real world.
29
+ # The :test delivery method accumulates sent emails in the
30
+ # ActionMailer::Base.deliveries array.
31
+ config.action_mailer.delivery_method = :test
32
+
33
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
34
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
35
+ # like if you have constraints or database-specific column types
36
+ # config.active_record.schema_format = :sql
37
+
38
+ # Print deprecation notices to the stderr
39
+ config.active_support.deprecation = :stderr
40
+ end
@@ -0,0 +1 @@
1
+ Dummy::Application.config.secret_token = '937a92d6932bff76ce073df95330b64d1df95bb11505bc24ebda6f103ca567a0fedf45811d459ac97b24901f0650da5280cdf82e7de21e86ebfc35586bb06f32'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_hugo_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,4 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :orders
3
+ root :to => 'orders#index'
4
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,10 @@
1
+ class CreateOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :orders do |t|
4
+ t.string :name
5
+ t.string :qty
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 1) do
15
+
16
+ create_table "orders", :force => true do |t|
17
+ t.string "name"
18
+ t.string "qty"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Formie" do
4
+ before do
5
+ Order.delete_all
6
+ Order.create :name => 'Rumpelstilzchen'
7
+ end
8
+
9
+ it 'should display copyright' do
10
+ visit "/orders"
11
+ page.should have_content("Copyright")
12
+ end
13
+
14
+ it 'should list one order' do
15
+ order = Order.all.first
16
+
17
+ visit "/orders/#{order.id}"
18
+ page.find('form p input').value.should == order.name
19
+ end
20
+
21
+ it 'builtins' do
22
+ visit "/orders/new"
23
+ page.should have_content("action_name new")
24
+ page.should have_content("args [123, 456]")
25
+ page.should have_content("block 4")
26
+ page.should have_content("controller_name orders")
27
+ page.should have_content("form ActionView::Helpers::FormBuilder")
28
+ page.should have_content("form.object Order")
29
+ page.should have_content("params new")
30
+ end
31
+
32
+ end
@@ -0,0 +1,63 @@
1
+ require 'rubygems'
2
+ require 'spork'
3
+
4
+ Spork.prefork do
5
+ # Loading more in this block will cause your tests to run faster. However,
6
+ # if you change any configuration or code from libraries loaded here, you'll
7
+ # need to restart spork for it take effect.
8
+
9
+ ENV["RAILS_ENV"] = "test"
10
+
11
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
12
+ require "rails/test_help"
13
+ require "rspec/rails"
14
+
15
+ # ActionMailer::Base.delivery_method = :test
16
+ # ActionMailer::Base.perform_deliveries = true
17
+ # ActionMailer::Base.default_url_options[:host] = "test.com"
18
+
19
+ Rails.backtrace_cleaner.remove_silencers!
20
+
21
+ # Configure capybara for integration testing
22
+ require "capybara/rails"
23
+ Capybara.default_driver = :rack_test
24
+ Capybara.default_selector = :css
25
+
26
+ # Run any available migration
27
+ ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
28
+
29
+ # Load support files
30
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
31
+
32
+ RSpec.configure do |config|
33
+ # Remove this line if you don't want RSpec's should and should_not
34
+ # methods or matchers
35
+ require 'rspec/expectations'
36
+ config.include RSpec::Matchers
37
+
38
+ # == Mock Framework
39
+ config.mock_with :rspec
40
+ end
41
+ end
42
+
43
+
44
+ Spork.each_run do
45
+ # This code will be run each time you run your specs.
46
+ Dir["#{File.dirname(__FILE__)}/../lib/controllers/*.rb"].each { |f| load f }
47
+
48
+ unless ENV['COVERAGE'].nil?
49
+ require 'simplecov'
50
+ SimpleCov.start 'rails' do
51
+ coverage_dir 'coverage'
52
+ end
53
+ end
54
+ end
55
+
56
+
57
+ # --- Instructions ---
58
+ # - Sort through your spec_helper file. Place as much environment loading
59
+ # code that you don't normally modify during development in the
60
+ # Spork.prefork block.
61
+ # - Place the rest under Spork.each_run block
62
+ # - Any code that is left outside of the blocks will be ran during preforking
63
+ # and during each_run!
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: formie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dittmar Krall
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-17 00:00:00.000000000 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: sqlite3
17
+ requirement: &70343920 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *70343920
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec-rails
28
+ requirement: &70343710 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70343710
37
+ - !ruby/object:Gem::Dependency
38
+ name: capybara
39
+ requirement: &70343500 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70343500
48
+ description: app/formies/labelled_field.html.erb
49
+ email:
50
+ - dittmar.krall@matique.de
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .rspec
56
+ - .watchr
57
+ - Gemfile
58
+ - Gemfile.lock
59
+ - MIT-LICENSE
60
+ - README.md
61
+ - Rakefile
62
+ - config/initializers/formie.rb
63
+ - formie.gemspec
64
+ - lib/formie.rb
65
+ - lib/formie/engine.rb
66
+ - lib/formie/version.rb
67
+ - spec/controllers/orders_spec.rb
68
+ - spec/dummy/Rakefile
69
+ - spec/dummy/app/assets/javascripts/application.js
70
+ - spec/dummy/app/controllers/application_controller.rb
71
+ - spec/dummy/app/controllers/orders_controller.rb
72
+ - spec/dummy/app/formies/application/copyright.html.erb
73
+ - spec/dummy/app/formies/forms/builtins.html.erb
74
+ - spec/dummy/app/formies/forms/l_field.html.erb
75
+ - spec/dummy/app/models/order.rb
76
+ - spec/dummy/app/views/layouts/application.html.erb
77
+ - spec/dummy/app/views/orders/_form.html.erb
78
+ - spec/dummy/app/views/orders/_new.html.erb
79
+ - spec/dummy/app/views/orders/index.html.erb
80
+ - spec/dummy/app/views/orders/new.html.erb
81
+ - spec/dummy/app/views/orders/show.html.erb
82
+ - spec/dummy/config.ru
83
+ - spec/dummy/config/application.rb
84
+ - spec/dummy/config/boot.rb
85
+ - spec/dummy/config/database.yml
86
+ - spec/dummy/config/environment.rb
87
+ - spec/dummy/config/environments/development.rb
88
+ - spec/dummy/config/environments/production.rb
89
+ - spec/dummy/config/environments/test.rb
90
+ - spec/dummy/config/initializers/secret_token.rb
91
+ - spec/dummy/config/initializers/session_store.rb
92
+ - spec/dummy/config/routes.rb
93
+ - spec/dummy/db/migrate/001_create_orders.rb
94
+ - spec/dummy/db/schema.rb
95
+ - spec/dummy/db/seeds.rb
96
+ - spec/dummy/public/favicon.ico
97
+ - spec/dummy/script/rails
98
+ - spec/integration/order_spec.rb
99
+ - spec/spec_helper.rb
100
+ has_rdoc: true
101
+ homepage: http://matique.de
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.6.2
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Like a helper, but based on html.
125
+ test_files:
126
+ - spec/controllers/orders_spec.rb
127
+ - spec/dummy/Rakefile
128
+ - spec/dummy/app/assets/javascripts/application.js
129
+ - spec/dummy/app/controllers/application_controller.rb
130
+ - spec/dummy/app/controllers/orders_controller.rb
131
+ - spec/dummy/app/formies/application/copyright.html.erb
132
+ - spec/dummy/app/formies/forms/builtins.html.erb
133
+ - spec/dummy/app/formies/forms/l_field.html.erb
134
+ - spec/dummy/app/models/order.rb
135
+ - spec/dummy/app/views/layouts/application.html.erb
136
+ - spec/dummy/app/views/orders/_form.html.erb
137
+ - spec/dummy/app/views/orders/_new.html.erb
138
+ - spec/dummy/app/views/orders/index.html.erb
139
+ - spec/dummy/app/views/orders/new.html.erb
140
+ - spec/dummy/app/views/orders/show.html.erb
141
+ - spec/dummy/config.ru
142
+ - spec/dummy/config/application.rb
143
+ - spec/dummy/config/boot.rb
144
+ - spec/dummy/config/database.yml
145
+ - spec/dummy/config/environment.rb
146
+ - spec/dummy/config/environments/development.rb
147
+ - spec/dummy/config/environments/production.rb
148
+ - spec/dummy/config/environments/test.rb
149
+ - spec/dummy/config/initializers/secret_token.rb
150
+ - spec/dummy/config/initializers/session_store.rb
151
+ - spec/dummy/config/routes.rb
152
+ - spec/dummy/db/migrate/001_create_orders.rb
153
+ - spec/dummy/db/schema.rb
154
+ - spec/dummy/db/seeds.rb
155
+ - spec/dummy/public/favicon.ico
156
+ - spec/dummy/script/rails
157
+ - spec/integration/order_spec.rb
158
+ - spec/spec_helper.rb