Permalink
Browse files

Whitespace Cleanup

  • Loading branch information...
mjonuschat committed Sep 27, 2010
1 parent 39b1e42 commit 433dae255534795e1ac9cbd41c7a2752446af996
Showing with 537 additions and 514 deletions.
  1. +2 −1 formtastic.gemspec
  2. +16 −16 generators/form/form_generator.rb
  3. +8 −6 generators/formtastic/formtastic_generator.rb
  4. +2 −0 generators/formtastic/templates/formtastic.rb
  5. +3 −1 install.rb
  6. +64 −64 lib/formtastic.rb
  7. +8 −6 lib/formtastic/i18n.rb
  8. +6 −4 lib/formtastic/layout_helper.rb
  9. +3 −1 lib/formtastic/railtie.rb
  10. +2 −0 lib/formtastic/util.rb
  11. +1 −1 lib/generators/formtastic/install/install_generator.rb
  12. +1 −1 spec/buttons_spec.rb
  13. +21 −21 spec/commit_button_spec.rb
  14. +12 −12 spec/custom_builder_spec.rb
  15. +7 −7 spec/defaults_spec.rb
  16. +8 −8 spec/error_proc_spec.rb
  17. +18 −18 spec/errors_spec.rb
  18. +6 −6 spec/form_helper_spec.rb
  19. +5 −5 spec/helpers/layout_helper_spec.rb
  20. +27 −27 spec/i18n_spec.rb
  21. +2 −2 spec/include_blank_spec.rb
  22. +18 −18 spec/input_spec.rb
  23. +5 −5 spec/inputs/boolean_input_spec.rb
  24. +18 −18 spec/inputs/check_boxes_input_spec.rb
  25. +29 −29 spec/inputs/country_input_spec.rb
  26. +40 −40 spec/inputs/datetime_input_spec.rb
  27. +3 −3 spec/inputs/file_input_spec.rb
  28. +9 −9 spec/inputs/hidden_input_spec.rb
  29. +6 −6 spec/inputs/numeric_input_spec.rb
  30. +5 −5 spec/inputs/password_input_spec.rb
  31. +14 −14 spec/inputs/radio_input_spec.rb
  32. +27 −27 spec/inputs/select_input_spec.rb
  33. +8 −8 spec/inputs/string_input_spec.rb
  34. +6 −6 spec/inputs/text_input_spec.rb
  35. +25 −25 spec/inputs/time_input_spec.rb
  36. +8 −8 spec/inputs/time_zone_input_spec.rb
  37. +17 −17 spec/inputs_spec.rb
  38. +2 −2 spec/label_spec.rb
  39. +4 −4 spec/semantic_fields_for_spec.rb
  40. +20 −20 spec/spec_helper.rb
  41. +45 −43 spec/support/custom_macros.rb
  42. +2 −0 spec/support/output_buffer.rb
  43. +2 −0 spec/support/test_environment.rb
  44. +2 −0 uninstall.rb
View
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
Gem::Specification.new do |s|
s.name = %q{formtastic}
s.version = "1.1.0"
@@ -40,4 +42,3 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<rspec_tag_matchers>, [">= 1.0.0"])
end
-
@@ -15,27 +15,27 @@
end
class FormGenerator < Rails::Generator::NamedBase
-
+
default_options :haml => false,
:partial => false
-
+
VIEWS_PATH = File.join('app', 'views').freeze
IGNORED_COLUMNS = [:updated_at, :created_at].freeze
-
+
attr_reader :controller_file_name,
:controller_class_path,
:controller_class_nesting,
:controller_class_nesting_depth,
:controller_class_name,
:template_type
-
+
def initialize(runtime_args, runtime_options = {})
super
base_name, @controller_class_path = extract_modules(@name.pluralize)
controller_class_name_without_nesting, @controller_file_name = inflect_names(base_name)
@template_type = options[:haml] ? :haml : :erb
end
-
+
def manifest
record do |m|
if options[:partial]
@@ -49,7 +49,7 @@ def manifest
template = File.read(File.join(source_root, "view__form.html.#{template_type}"))
erb = ERB.new(template, nil, '-')
generated_code = erb.result(binding).strip rescue nil
-
+
# Print the result, and copy to clipboard
puts "# ---------------------------------------------------------"
puts "# GENERATED FORMTASTIC CODE"
@@ -62,9 +62,9 @@ def manifest
end
end
end
-
+
protected
-
+
# Save to lipboard with multiple OS support.
def save_to_clipboard(data)
return unless data
@@ -83,38 +83,38 @@ def save_to_clipboard(data)
true
end
end
-
+
# Add additional model attributes if specified in args - probably not that common scenario.
def attributes
# Get columns for the requested model.
existing_attributes = @class_name.constantize.content_columns.reject { |column| IGNORED_COLUMNS.include?(column.name.to_sym) }
@args = super + existing_attributes
end
-
+
def add_options!(opt)
opt.separator ''
opt.separator 'Options:'
-
+
# Allow option to generate HAML views instead of ERB.
opt.on('--haml',
"Generate HAML output instead of the default ERB.") do |v|
options[:haml] = v
end
-
+
# Allow option to generate to partial in model's views path, instead of printing out in terminal.
opt.on('--partial',
"Save generated output directly to a form partial (app/views/{resource}/_form.html.*).") do |v|
options[:partial] = v
end
-
+
opt.on('--controller CONTROLLER_PATH',
"Specify a non-standard controller for the specified model (e.g. admin/posts).") do |v|
options[:controller] = v if v.present?
end
end
-
+
def banner
"Usage: #{$0} form ExistingModelName [--haml] [--partial]"
end
-
-end
+
+end
@@ -1,9 +1,11 @@
+# encoding: utf-8
+
class FormtasticGenerator < Rails::Generator::Base
-
+
def initialize(*runtime_args)
super
end
-
+
def manifest
record do |m|
m.directory File.join('config', 'initializers')
@@ -14,11 +16,11 @@ def manifest
m.template 'formtastic_changes.css', File.join('public', 'stylesheets', 'formtastic_changes.css')
end
end
-
+
protected
-
+
def banner
%{Usage: #{$0} #{spec.name}\nCopies formtastic.css and formtastic_changes.css to public/stylesheets/ and a config initializer to config/initializers/formtastic.rb}
end
-
-end
+
+end
@@ -1,3 +1,5 @@
+# encoding: utf-8
+
# Set the default text field size when input is a string. Default is 50.
# Formtastic::SemanticFormBuilder.default_text_field_size = 50
View
@@ -1,2 +1,4 @@
+# encoding: utf-8
+
puts "Run `./script/generate formtastic` if you want (copies optional config file and some stylesheets into your app)"
-puts "Run `./script/generate form MODEL_NAME` to generate some semantic form markup for any existing model(s) (optional)"
+puts "Run `./script/generate form MODEL_NAME` to generate some semantic form markup for any existing model(s) (optional)"
Oops, something went wrong.

0 comments on commit 433dae2

Please sign in to comment.