view_mapper 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/README.rdoc +4 -2
  2. data/VERSION +1 -1
  3. data/generators/scaffold_for_view/scaffold_for_view_generator.rb +2 -6
  4. data/generators/view_for/view_for_generator.rb +1 -5
  5. data/lib/view_mapper/{has_many_view.rb → has_many_child_models.rb} +33 -37
  6. data/lib/view_mapper/model_info.rb +8 -0
  7. data/lib/view_mapper/view_mapper.rb +15 -2
  8. data/lib/view_mapper/views/auto_complete/auto_complete_view.rb +77 -0
  9. data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/controller.rb +3 -1
  10. data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/layout.html.erb +0 -0
  11. data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/view_edit.html.erb +1 -1
  12. data/lib/view_mapper/{auto_complete_templates → views/auto_complete/templates}/view_new.html.erb +1 -1
  13. data/lib/view_mapper/views/has_many/has_many_view.rb +28 -0
  14. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/helper.rb +0 -0
  15. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/layout.html.erb +0 -0
  16. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/model.rb +0 -0
  17. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/nested_attributes.js +0 -0
  18. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/style.css +0 -0
  19. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_child_form.html.erb +0 -0
  20. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_edit.html.erb +0 -0
  21. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_form.html.erb +0 -0
  22. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_new.html.erb +0 -0
  23. data/lib/view_mapper/{has_many_templates → views/has_many/templates}/view_show.html.erb +0 -0
  24. data/lib/view_mapper/{paperclip_view.rb → views/paperclip/paperclip_view.rb} +6 -2
  25. data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/migration.rb +1 -1
  26. data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/model.rb +0 -0
  27. data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_edit.html.erb +0 -0
  28. data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_new.html.erb +0 -0
  29. data/lib/view_mapper/{paperclip_templates → views/paperclip/templates}/view_show.html.erb +0 -0
  30. data/lib/view_mapper.rb +4 -3
  31. data/test/{fake → generators/fake}/fake_generator.rb +0 -0
  32. data/test/generators/fake/templates/fake_template1.html.erb +1 -0
  33. data/test/generators/fake/templates/fake_template2.html.erb +1 -0
  34. data/test/{scaffold_for_view_generator_test.rb → generators/scaffold_for_view/scaffold_for_view_generator_test.rb} +2 -2
  35. data/test/{view_for_generator_test.rb → generators/view_for/view_for_generator_test.rb} +0 -0
  36. data/test/model_info_test.rb +12 -3
  37. data/test/test_helper.rb +12 -8
  38. data/test/view_mapper_test.rb +13 -2
  39. data/test/{auto_complete_test.rb → views/auto_complete/auto_complete_test.rb} +63 -40
  40. data/test/{expected_templates/auto_complete/index.html.erb → views/auto_complete/expected_templates/actual_index} +2 -0
  41. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/edit.html.erb +7 -3
  42. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/expected_routes.rb +0 -0
  43. data/test/{expected_templates/paperclip → views/auto_complete/expected_templates}/index.html.erb +3 -1
  44. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/new.html.erb +7 -3
  45. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/show.html.erb +6 -1
  46. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/standard_routes.rb +0 -0
  47. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/testies.html.erb +0 -0
  48. data/test/{expected_templates/auto_complete → views/auto_complete/expected_templates}/testies_controller.rb +2 -1
  49. data/test/views/fake/fake_view.rb +7 -0
  50. data/test/views/fake/templates/fake_template1.html.erb +1 -0
  51. data/test/{expected_templates/has_many → views/has_many/expected_templates}/_form.html.erb +0 -0
  52. data/test/{expected_templates/has_many → views/has_many/expected_templates}/_person.html.erb +4 -0
  53. data/test/{expected_templates/has_many → views/has_many/expected_templates}/create_parents.rb +4 -3
  54. data/test/{expected_templates/has_many → views/has_many/expected_templates}/edit.html.erb +0 -0
  55. data/test/{expected_templates/has_many → views/has_many/expected_templates}/index.html.erb +1 -1
  56. data/test/{expected_templates/has_many → views/has_many/expected_templates}/new.html.erb +0 -0
  57. data/test/{expected_templates/has_many → views/has_many/expected_templates}/parent.rb +2 -1
  58. data/test/{expected_templates/has_many → views/has_many/expected_templates}/show.html.erb +4 -0
  59. data/test/{has_many_view_test.rb → views/has_many/has_many_view_test.rb} +17 -17
  60. data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/create_testies.rb +4 -3
  61. data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/edit.html.erb +4 -0
  62. data/test/views/paperclip/expected_templates/index.html.erb +26 -0
  63. data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/new.html.erb +4 -0
  64. data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/show.html.erb +5 -0
  65. data/test/{expected_templates/paperclip → views/paperclip/expected_templates}/testy.rb +0 -0
  66. data/test/{paperclip_view_test.rb → views/paperclip/paperclip_view_test.rb} +17 -9
  67. data/view_mapper.gemspec +77 -124
  68. metadata +72 -120
  69. data/lib/view_mapper/auto_complete_templates/functional_test.rb +0 -45
  70. data/lib/view_mapper/auto_complete_templates/helper.rb +0 -2
  71. data/lib/view_mapper/auto_complete_templates/helper_test.rb +0 -4
  72. data/lib/view_mapper/auto_complete_templates/style.css +0 -54
  73. data/lib/view_mapper/auto_complete_templates/view_index.html.erb +0 -24
  74. data/lib/view_mapper/auto_complete_templates/view_show.html.erb +0 -10
  75. data/lib/view_mapper/auto_complete_view.rb +0 -44
  76. data/lib/view_mapper/has_many_templates/controller.rb +0 -85
  77. data/lib/view_mapper/has_many_templates/fixtures.yml +0 -19
  78. data/lib/view_mapper/has_many_templates/functional_test.rb +0 -45
  79. data/lib/view_mapper/has_many_templates/helper_test.rb +0 -4
  80. data/lib/view_mapper/has_many_templates/migration.rb +0 -16
  81. data/lib/view_mapper/has_many_templates/unit_test.rb +0 -8
  82. data/lib/view_mapper/has_many_templates/view_index.html.erb +0 -24
  83. data/lib/view_mapper/paperclip_templates/controller.rb +0 -85
  84. data/lib/view_mapper/paperclip_templates/fixtures.yml +0 -19
  85. data/lib/view_mapper/paperclip_templates/functional_test.rb +0 -45
  86. data/lib/view_mapper/paperclip_templates/helper.rb +0 -2
  87. data/lib/view_mapper/paperclip_templates/helper_test.rb +0 -4
  88. data/lib/view_mapper/paperclip_templates/layout.html.erb +0 -17
  89. data/lib/view_mapper/paperclip_templates/style.css +0 -54
  90. data/lib/view_mapper/paperclip_templates/unit_test.rb +0 -8
  91. data/lib/view_mapper/paperclip_templates/view_index.html.erb +0 -24
  92. data/test/database.yml +0 -3
  93. data/test/fake_view.rb +0 -7
  94. data/test/rails_generator/base.rb +0 -266
  95. data/test/rails_generator/commands.rb +0 -621
  96. data/test/rails_generator/generated_attribute.rb +0 -46
  97. data/test/rails_generator/generators/components/model/model_generator.rb +0 -45
  98. data/test/rails_generator/generators/components/scaffold/scaffold_generator.rb +0 -102
  99. data/test/rails_generator/lookup.rb +0 -249
  100. data/test/rails_generator/manifest.rb +0 -53
  101. data/test/rails_generator/options.rb +0 -150
  102. data/test/rails_generator/scripts/destroy.rb +0 -29
  103. data/test/rails_generator/scripts/generate.rb +0 -7
  104. data/test/rails_generator/scripts/update.rb +0 -12
  105. data/test/rails_generator/scripts.rb +0 -89
  106. data/test/rails_generator/secret_key_generator.rb +0 -24
  107. data/test/rails_generator/simple_logger.rb +0 -46
  108. data/test/rails_generator/spec.rb +0 -44
@@ -1,89 +0,0 @@
1
- require File.dirname(__FILE__) + '/options'
2
-
3
- module Rails
4
- module Generator
5
- module Scripts
6
-
7
- # Generator scripts handle command-line invocation. Each script
8
- # responds to an invoke! class method which handles option parsing
9
- # and generator invocation.
10
- class Base
11
- include Options
12
- default_options :collision => :ask, :quiet => false
13
-
14
- # Run the generator script. Takes an array of unparsed arguments
15
- # and a hash of parsed arguments, takes the generator as an option
16
- # or first remaining argument, and invokes the requested command.
17
- def run(args = [], runtime_options = {})
18
- begin
19
- parse!(args.dup, runtime_options)
20
- rescue OptionParser::InvalidOption => e
21
- # Don't cry, script. Generators want what you think is invalid.
22
- end
23
-
24
- # Generator name is the only required option.
25
- unless options[:generator]
26
- usage if args.empty?
27
- options[:generator] ||= args.shift
28
- end
29
-
30
- # Look up generator instance and invoke command on it.
31
- Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke!
32
- rescue => e
33
- puts e
34
- puts " #{e.backtrace.join("\n ")}\n" if options[:backtrace]
35
- raise SystemExit
36
- end
37
-
38
- protected
39
- # Override with your own script usage banner.
40
- def banner
41
- "Usage: #{$0} generator [options] [args]"
42
- end
43
-
44
- def usage_message
45
- usage = "\nInstalled Generators\n"
46
- Rails::Generator::Base.sources.inject([]) do |mem, source|
47
- # Using an association list instead of a hash to preserve order,
48
- # for aesthetic reasons more than anything else.
49
- label = source.label.to_s.capitalize
50
- pair = mem.assoc(label)
51
- mem << (pair = [label, []]) if pair.nil?
52
- pair[1] |= source.names
53
- mem
54
- end.each do |label, names|
55
- usage << " #{label}: #{names.join(', ')}\n" unless names.empty?
56
- end
57
-
58
- usage << <<end_blurb
59
-
60
- More are available at http://wiki.rubyonrails.org/rails/pages/AvailableGenerators
61
- 1. Download, for example, login_generator.zip
62
- 2. Unzip to directory #{Dir.user_home}/.rails/generators/login
63
- to use the generator with all your Rails apps
64
- end_blurb
65
-
66
- if Object.const_defined?(:RAILS_ROOT)
67
- usage << <<end_blurb
68
- or to #{File.expand_path(RAILS_ROOT)}/lib/generators/login
69
- to use with this app only.
70
- end_blurb
71
- end
72
-
73
- usage << <<end_blurb
74
- 3. Run generate with no arguments for usage information
75
- #{$0} login
76
-
77
- Generator gems are also available:
78
- 1. gem search -r generator
79
- 2. gem install login_generator
80
- 3. #{$0} login
81
-
82
- end_blurb
83
- return usage
84
- end
85
- end # Base
86
-
87
- end
88
- end
89
- end
@@ -1,24 +0,0 @@
1
- require 'active_support/deprecation'
2
-
3
- module Rails
4
- # A class for creating random secret keys. This class will do its best to create a
5
- # random secret key that's as secure as possible, using whatever methods are
6
- # available on the current platform. For example:
7
- #
8
- # generator = Rails::SecretKeyGenerator("some unique identifier, such as the application name")
9
- # generator.generate_secret # => "f3f1be90053fa851... (some long string)"
10
- #
11
- # This class is *deprecated* in Rails 2.2 in favor of ActiveSupport::SecureRandom.
12
- # It is currently a wrapper around ActiveSupport::SecureRandom.
13
- class SecretKeyGenerator
14
- def initialize(identifier)
15
- end
16
-
17
- # Generate a random secret key with the best possible method available on
18
- # the current platform.
19
- def generate_secret
20
- ActiveSupport::SecureRandom.hex(64)
21
- end
22
- deprecate :generate_secret=>"You should use ActiveSupport::SecureRandom.hex(64)"
23
- end
24
- end
@@ -1,46 +0,0 @@
1
- module Rails
2
- module Generator
3
- class SimpleLogger # :nodoc:
4
- attr_reader :out
5
- attr_accessor :quiet
6
-
7
- def initialize(out = $stdout)
8
- @out = out
9
- @quiet = false
10
- @level = 0
11
- end
12
-
13
- def log(status, message, &block)
14
- @out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet
15
- indent(&block) if block_given?
16
- end
17
-
18
- def indent(&block)
19
- @level += 1
20
- if block_given?
21
- begin
22
- block.call
23
- ensure
24
- outdent
25
- end
26
- end
27
- end
28
-
29
- def outdent
30
- @level -= 1
31
- if block_given?
32
- begin
33
- block.call
34
- ensure
35
- indent
36
- end
37
- end
38
- end
39
-
40
- private
41
- def method_missing(method, *args, &block)
42
- log(method.to_s, args.first, &block)
43
- end
44
- end
45
- end
46
- end
@@ -1,44 +0,0 @@
1
- module Rails
2
- module Generator
3
- # A spec knows where a generator was found and how to instantiate it.
4
- # Metadata include the generator's name, its base path, and the source
5
- # which yielded it (PathSource, GemPathSource, etc.)
6
- class Spec
7
- attr_reader :name, :path, :source
8
-
9
- def initialize(name, path, source)
10
- @name, @path, @source = name, path, source
11
- end
12
-
13
- # Look up the generator class. Require its class file, find the class
14
- # in ObjectSpace, tag it with this spec, and return.
15
- def klass
16
- unless @klass
17
- require class_file
18
- @klass = lookup_class
19
- @klass.spec = self
20
- end
21
- @klass
22
- end
23
-
24
- def class_file
25
- "#{path}/#{name}_generator.rb"
26
- end
27
-
28
- def class_name
29
- "#{name.camelize}Generator"
30
- end
31
-
32
- private
33
- # Search for the first Class descending from Rails::Generator::Base
34
- # whose name matches the requested class name.
35
- def lookup_class
36
- ObjectSpace.each_object(Class) do |obj|
37
- return obj if obj.ancestors.include?(Rails::Generator::Base) and
38
- obj.name.split('::').last == class_name
39
- end
40
- raise NameError, "Missing #{class_name} class in #{class_file}"
41
- end
42
- end
43
- end
44
- end