merb-gen 0.9.2 → 0.9.3

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/README CHANGED
@@ -1,10 +1,21 @@
1
1
  ==== merb-gen
2
2
 
3
- merb-gen is a part of the Merb More package. It provides application and plugin generators for Merb.
3
+ merb-gen is a part of the Merb More package. It provides application, plugin, and component
4
+ generators for Merb.
4
5
 
5
6
  ==== Usage
6
7
 
7
- To generate a new merb app, run merb-gen &lt;path&gt;. For instance, <tt>merb-gen foo</tt> would create
8
- a new merb app inside of the foo directory.
8
+ To generate directory structure for a new merb app, run merb-gen app &lt;app-name&gt;.
9
+ For instance, <tt>merb-gen app foo</tt> would create a new foo merb app inside of the foo directory.
9
10
 
10
- To generate a new merb plugin, run merb-gen plugin &lt;path&gt;.
11
+ Use <tt>--flat</tt> to generate a flattened application (very simple directory structure)
12
+ and <tt>--very-flat</tt> to generate a single file application.
13
+
14
+ To generate a new merb plugin, run merb-gen plugin &lt;plugin_name&gt;.
15
+
16
+ To see what generators are available, run merb-gen generators.
17
+
18
+ ==== Custom generators
19
+
20
+ If you want to create your custom generators to use with Merb, and don't want to create a gem,
21
+ you should put them in ~/.rubigen/merb_generators/.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
3
 
4
4
  GEM = "merb-gen"
5
- VERSION = "0.9.2"
5
+ VERSION = "0.9.3"
6
6
  AUTHOR = "Yehuda Katz"
7
7
  EMAIL = "wycats@gmail.com"
8
8
  HOMEPAGE = "http://www.merbivore.com"
@@ -23,7 +23,7 @@ spec = Gem::Specification.new do |s|
23
23
  s.executables = %w( merb-gen )
24
24
 
25
25
  # Uncomment this to add a dependency
26
- s.add_dependency "merb-core", ">= 0.9.2"
26
+ s.add_dependency "merb-core", ">= 0.9.3"
27
27
  s.add_dependency "rubigen", ">= 1.2.4"
28
28
 
29
29
  s.require_path = 'lib'
@@ -36,12 +36,14 @@ Rake::GemPackageTask.new(spec) do |pkg|
36
36
  pkg.gem_spec = spec
37
37
  end
38
38
 
39
+ install_home = ENV['GEM_HOME'] ? "-i #{ENV['GEM_HOME']}" : ""
40
+
39
41
  namespace :jruby do
40
42
  task :install do
41
- sh %{sudo jruby -S gem install pkg/#{GEM}-#{VERSION} --no-update-sources}
43
+ sh %{sudo jruby -S gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
42
44
  end
43
45
  end
44
46
 
45
47
  task :install => [:package] do
46
- sh %{sudo gem install pkg/#{GEM}-#{VERSION} --no-update-sources}
48
+ sh %{sudo gem install #{install_home} pkg/#{GEM}-#{VERSION} --no-update-sources}
47
49
  end
data/TODO CHANGED
@@ -1,4 +0,0 @@
1
- TODO:
2
- Fix LICENSE with your name
3
- Fix Rakefile with your name and contact info
4
- Add your code to lib/<%= name %>.rb
@@ -33,4 +33,8 @@ class MerbGenerator < Merb::GeneratorBase
33
33
 
34
34
  def display_framework_selections
35
35
  end
36
+
37
+ def create_dirs
38
+ m.directory 'log'
39
+ end
36
40
  end
@@ -32,95 +32,3 @@ desc "Add new files to subversion"
32
32
  task :svn_add do
33
33
  system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
34
34
  end
35
-
36
-
37
- class Freezer
38
-
39
- class << self
40
-
41
- def components
42
- {
43
- "core" => "git://github.com/wycats/merb-core.git",
44
- "more" => "git://github.com/wycats/merb-more.git",
45
- "plugins" => "git://github.com/wycats/merb-plugins.git"
46
- }
47
- end
48
-
49
- def framework_dir
50
- # Should allow customization of this directory's location?
51
- File.join(File.dirname(__FILE__), "framework")
52
- end
53
-
54
- def gitmodules
55
- File.join(File.dirname(__FILE__), ".gitmodules")
56
- end
57
-
58
- def freeze(component, update = false)
59
- new(component, update).freeze
60
- end
61
-
62
- end
63
-
64
- def initialize(component, update)
65
- @component = "merb-" + component
66
- @update = update
67
- end
68
-
69
- def freeze
70
- # Ensure that required git commands are available
71
- %w(git-pull git-submodule).each do |bin|
72
- next if in_path?(bin)
73
- $stderr.puts "ERROR: #{bin} must be avaible in PATH"
74
- exit 1
75
- end
76
-
77
- unless File.directory?(framework_dir)
78
- puts "Creating framework directory ..."
79
- FileUtils.mkdir_p(framework_dir)
80
- end
81
-
82
- if managed?
83
- puts "#{@component} seems to be already managed by git-submodule."
84
- if @update
85
- puts "Trying to update #{@component} ..."
86
- sh "cd #{framework_dir}/#{@component} && git-pull"
87
- end
88
- else
89
- puts "Creating submodule for #{@component} ..."
90
- sh "git-submodule --quiet add #{components[@component.gsub("merb-", '')]} #{File.basename(framework_dir)}/#{@component}"
91
- if $?.success?
92
- sh("git-submodule init")
93
- else
94
- # Should this instead be a raise?
95
- $stderr.puts("ERROR: unable to create submodule for #{@component}")
96
- end
97
- end
98
- end
99
-
100
- protected
101
-
102
- def in_submodule?
103
- return false unless File.exists?(gitmodules)
104
- File.read(gitmodules) =~ %r![submodule "#{framework_dir}/#{@component}"]!
105
- end
106
-
107
- def managed?
108
- File.directory?(File.join(framework_dir, @component)) || in_submodule?
109
- end
110
-
111
- def in_path?(bin)
112
- `which #{bin}`
113
- !$?.nil? && $?.success?
114
- end
115
-
116
- end
117
-
118
- task :freeze => Freezer.components.keys.map { |component| "freeze:#{component}" }
119
- namespace :freeze do
120
- Freezer.components.each do |component, git_repository|
121
- desc "Freeze #{component} from #{git_repository}"
122
- task component do
123
- Freezer.freeze(component, ENV["UPDATE"])
124
- end
125
- end
126
- end
@@ -38,11 +38,19 @@
38
38
 
39
39
  <h3>Where can I find help?</h3>
40
40
  <p>If you have any questions or if you can't figure something out, please take a
41
- look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
42
- feel free to come chat at irc.freenode.net, channel #merb.</p>
41
+ look at our <a href="http://merbivore.com/"> project page</a>,
42
+ feel free to come chat at irc.freenode.net, channel #merb,
43
+ or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
44
+ on Google Groups.</p>
45
+
46
+ <h3>What if I've found a bug?</h3>
47
+ <p>If you want to file a bug or make your own contribution to Merb,
48
+ feel free to register and create a ticket at our
49
+ <a href="http://merb.lighthouseapp.com/">project development page</a>
50
+ on Lighthouse.</p>
43
51
 
44
52
  <h3>How do I edit this page?</h3>
45
- <p>You can change what people see when this happens byy editing <tt>app/views/exceptions/not_found.html.erb</tt>.</p>
53
+ <p>You can change what people see when this happens by editing <tt>app/views/exceptions/not_acceptable.html.erb</tt>.</p>
46
54
 
47
55
  </div>
48
56
 
@@ -17,8 +17,16 @@
17
17
 
18
18
  <h3>Where can I find help?</h3>
19
19
  <p>If you have any questions or if you can't figure something out, please take a
20
- look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
21
- feel free to come chat at irc.freenode.net, channel #merb.</p>
20
+ look at our <a href="http://merbivore.com/"> project page</a>,
21
+ feel free to come chat at irc.freenode.net, channel #merb,
22
+ or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
23
+ on Google Groups.</p>
24
+
25
+ <h3>What if I've found a bug?</h3>
26
+ <p>If you want to file a bug or make your own contribution to Merb,
27
+ feel free to register and create a ticket at our
28
+ <a href="http://merb.lighthouseapp.com/">project development page</a>
29
+ on Lighthouse.</p>
22
30
 
23
31
  <h3>How do I edit this page?</h3>
24
32
  <p>You're seeing this page because you need to edit the following files:
@@ -1,86 +1,88 @@
1
- # Adapted from Autotest::Rails
1
+ # Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
2
2
  require 'autotest'
3
3
 
4
+ class RspecCommandError < StandardError; end
5
+
4
6
  class Autotest::MerbRspec < Autotest
5
-
7
+
6
8
  # +model_tests_dir+:: the directory to find model-centric tests
7
9
  # +controller_tests_dir+:: the directory to find controller-centric tests
8
10
  # +view_tests_dir+:: the directory to find view-centric tests
9
11
  # +fixtures_dir+:: the directory to find fixtures in
10
12
  attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir
11
-
13
+
12
14
  def initialize # :nodoc:
13
15
  super
14
-
16
+
15
17
  initialize_test_layout
16
-
18
+
17
19
  # Ignore any happenings in these directories
18
20
  add_exception %r%^\./(?:doc|log|public|tmp)%
19
-
21
+
20
22
  # Ignore any mappings that Autotest may have already set up
21
23
  clear_mappings
22
-
23
- # Any changes to a file in the root of the 'lib' directory will run any
24
+
25
+ # Any changes to a file in the root of the 'lib' directory will run any
24
26
  # model test with a corresponding name.
25
27
  add_mapping %r%^lib\/.*\.rb% do |filename, _|
26
- files_matching Regexp.new("^#{model_test_for(filename)}$")
28
+ files_matching %r%#{model_test_for(filename)}$%
27
29
  end
28
-
30
+
29
31
  add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
30
32
  files_matching %r%^spec/.*_spec\.rb$%
31
33
  end
32
-
33
- # Any changes to a fixture will run corresponding view, controller and
34
+
35
+ # Any changes to a fixture will run corresponding view, controller and
34
36
  # model tests
35
37
  add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
36
38
  [
37
- model_test_for(m[1]),
38
- controller_test_for(m[1]),
39
+ model_test_for(m[1]),
40
+ controller_test_for(m[1]),
39
41
  view_test_for(m[1])
40
42
  ]
41
43
  end
42
-
44
+
43
45
  # Any change to a test or spec will cause it to be run
44
46
  add_mapping %r%^spec/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
45
47
  filename
46
48
  end
47
-
49
+
48
50
  # Any change to a model will cause it's corresponding test to be run
49
51
  add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
50
52
  model_test_for(m[1])
51
53
  end
52
-
53
- # Any change to the global helper will result in all view and controller
54
+
55
+ # Any change to the global helper will result in all view and controller
54
56
  # tests being run
55
57
  add_mapping %r%^app/helpers/global_helpers.rb% do
56
58
  files_matching %r%^spec/(views|functional|controllers)/.*_spec\.rb$%
57
59
  end
58
-
59
- # Any change to a helper will run it's corresponding view and controller
60
- # tests, unless the helper is the global helper. Changes to the global
60
+
61
+ # Any change to a helper will run it's corresponding view and controller
62
+ # tests, unless the helper is the global helper. Changes to the global
61
63
  # helper run all view and controller tests.
62
64
  add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
63
65
  if m[1] == "global" then
64
66
  files_matching %r%^spec/(views|functional|controllers)/.*_spec\.rb$%
65
67
  else
66
68
  [
67
- view_test_for(m[1]),
69
+ view_test_for(m[1]),
68
70
  controller_test_for(m[1])
69
71
  ]
70
72
  end
71
73
  end
72
-
73
- # Changes to views result in their corresponding view and controller test
74
+
75
+ # Changes to views result in their corresponding view and controller test
74
76
  # being run
75
77
  add_mapping %r%^app/views/(.*)/% do |_, m|
76
78
  [
77
- view_test_for(m[1]),
79
+ view_test_for(m[1]),
78
80
  controller_test_for(m[1])
79
81
  ]
80
82
  end
81
-
82
- # Changes to a controller result in its corresponding test being run. If
83
- # the controller is the exception or application controller, all
83
+
84
+ # Changes to a controller result in its corresponding test being run. If
85
+ # the controller is the exception or application controller, all
84
86
  # controller tests are run.
85
87
  add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
86
88
  if ["application", "exception"].include?(m[1])
@@ -95,36 +97,58 @@ class Autotest::MerbRspec < Autotest
95
97
  files_matching %r%^spec/(controllers|views|functional)/.*_spec\.rb$%
96
98
  end
97
99
 
98
- # If any of the major files governing the environment are altered, run
100
+ # If any of the major files governing the environment are altered, run
99
101
  # everything
100
102
  add_mapping %r%^spec/spec_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX
101
103
  files_matching %r%^spec/(unit|models|controllers|views|functional)/.*_spec\.rb$%
102
104
  end
103
105
  end
104
-
105
- ##
106
- # Methods below this point are adapted from Auotest::Rspec
107
-
106
+
107
+ def failed_results(results)
108
+ results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
109
+ end
110
+
111
+ def handle_results(results)
112
+ @failures = failed_results(results)
113
+ @files_to_test = consolidate_failures @failures
114
+ unless $TESTING
115
+ if @files_to_test.empty?
116
+ hook :green
117
+ else
118
+ hook :red
119
+ end
120
+ end
121
+ @tainted = true unless @files_to_test.empty?
122
+ end
123
+
108
124
  def consolidate_failures(failed)
109
125
  filters = Hash.new { |h,k| h[k] = [] }
110
126
  failed.each do |spec, failed_trace|
111
- if f = test_files_for(failed).find { |f| failed_trace =~ Regexp.new(f) } then
112
- filters[f] << spec
113
- break
127
+ find_files.keys.select { |f| f =~ /spec\// }.each do |f|
128
+ if failed_trace =~ Regexp.new(f)
129
+ filters[f] << spec
130
+ break
131
+ end
114
132
  end
115
133
  end
116
- return filters
134
+ filters
117
135
  end
118
136
 
119
137
  def make_test_cmd(files_to_test)
120
- return "#{ruby} -S #{spec_command} #{add_options_if_present} #{files_to_test.keys.flatten.join(' ')}"
138
+ [
139
+ ruby,
140
+ "-S",
141
+ spec_command,
142
+ add_options_if_present,
143
+ files_to_test.keys.flatten.join(' ')
144
+ ].join(" ")
121
145
  end
122
-
146
+
123
147
  def add_options_if_present
124
148
  File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
125
149
  end
126
150
 
127
- # Finds the proper spec command to use. Precendence is set in the
151
+ # Finds the proper spec command to use. Precendence is set in the
128
152
  # lazily-evaluated method spec_commands. Alias + Override that in
129
153
  # ~/.autotest to provide a different spec command then the default
130
154
  # paths provided.
@@ -134,7 +158,7 @@ class Autotest::MerbRspec < Autotest
134
158
 
135
159
  raise RspecCommandError, "No spec command could be found!" unless @spec_command
136
160
 
137
- @spec_command.gsub! File::SEPARATOR, separator if separator
161
+ @spec_command.gsub!(File::SEPARATOR, separator) if separator
138
162
  end
139
163
  @spec_command
140
164
  end
@@ -142,18 +166,15 @@ class Autotest::MerbRspec < Autotest
142
166
  # Autotest will look for spec commands in the following
143
167
  # locations, in this order:
144
168
  #
145
- # * bin/spec
146
169
  # * default spec bin/loader installed in Rubygems
170
+ # * any spec command found in PATH
147
171
  def spec_commands
148
- [
149
- File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')),
150
- File.join(Config::CONFIG['bindir'], 'spec')
151
- ]
172
+ [ File.join(Config::CONFIG['bindir'], 'spec'), 'spec' ]
152
173
  end
153
-
174
+
154
175
  private
155
176
 
156
- # Determines the paths we can expect tests or specs to reside, as well as
177
+ # Determines the paths we can expect tests or specs to reside, as well as
157
178
  # corresponding fixtures.
158
179
  def initialize_test_layout
159
180
  self.model_tests_dir = "spec/models"
@@ -161,19 +182,19 @@ private
161
182
  self.view_tests_dir = "spec/views"
162
183
  self.fixtures_dir = "spec/fixtures"
163
184
  end
164
-
165
- # Given a filename and the test type, this method will return the
185
+
186
+ # Given a filename and the test type, this method will return the
166
187
  # corresponding test's or spec's name.
167
- #
188
+ #
168
189
  # ==== Arguments
169
190
  # +filename+<String>:: the file name of the model, view, or controller
170
191
  # +kind_of_test+<Symbol>:: the type of test we that we should run
171
- #
192
+ #
172
193
  # ==== Returns
173
194
  # String:: the name of the corresponding test or spec
174
- #
195
+ #
175
196
  # ==== Example
176
- #
197
+ #
177
198
  # > test_for("user", :model)
178
199
  # => "user_test.rb"
179
200
  # > test_for("login", :controller)
@@ -182,21 +203,21 @@ private
182
203
  # => "form_view_spec.rb" # If you're running a RSpec-like suite
183
204
  def test_for(filename, kind_of_test) # :nodoc:
184
205
  name = [filename]
185
- name << kind_of_test.to_s unless if == :view
206
+ name << kind_of_test.to_s if kind_of_test == :view
186
207
  name << "spec"
187
208
  return name.join("_") + ".rb"
188
209
  end
189
-
210
+
190
211
  def model_test_for(filename)
191
212
  [model_tests_dir, test_for(filename, :model)].join("/")
192
213
  end
193
-
214
+
194
215
  def controller_test_for(filename)
195
216
  [controller_tests_dir, test_for(filename, :controller)].join("/")
196
217
  end
197
-
218
+
198
219
  def view_test_for(filename)
199
220
  [view_tests_dir, test_for(filename, :view)].join("/")
200
221
  end
201
-
202
- end
222
+
223
+ end
@@ -3,4 +3,5 @@ Merb::Config.use { |c|
3
3
  c[:exception_details] = true
4
4
  c[:reload_classes] = true
5
5
  c[:reload_time] = 0.5
6
+ c[:log_auto_flush ] = true
6
7
  }
@@ -2,4 +2,6 @@ Merb.logger.info("Loaded PRODUCTION Environment...")
2
2
  Merb::Config.use { |c|
3
3
  c[:exception_details] = false
4
4
  c[:reload_classes] = false
5
+ c[:log_level] = :error
6
+ c[:log_file] = Merb.log_path + "/production.log"
5
7
  }
@@ -2,4 +2,5 @@ Merb.logger.info("Loaded TEST Environment...")
2
2
  Merb::Config.use { |c|
3
3
  c[:testing] = true
4
4
  c[:exception_details] = true
5
+ c[:log_auto_flush ] = true
5
6
  }
@@ -1,58 +1,153 @@
1
- # Make the app's "gems" directory a place where gems are loaded from
1
+ #
2
+ # ==== Structure of Merb initializer
3
+ #
4
+ # 1. Load paths.
5
+ # 2. Dependencies configuration.
6
+ # 3. Libraries (ORM, testing tool, etc) you use.
7
+ # 4. Application-specific configuration.
8
+
9
+ #
10
+ # ==== Set up load paths
11
+ #
12
+
13
+ # Make the app's "gems" directory a place where gems are loaded from.
14
+ # Note that gems directory must have a structure RubyGems uses for
15
+ # directories under which gems are kept.
16
+ #
17
+ # To conveniently set it up use gem install -i <merb_app_root/gems>
18
+ # when installing gems. This will set up the structure under /gems
19
+ # automagically.
20
+ #
21
+ # An example:
22
+ #
23
+ # You want to bundle ActiveRecord and ActiveSupport with your Merb
24
+ # application to be deployment environment independent. To do so,
25
+ # install gems into merb_app_root/gems directory like this:
26
+ #
27
+ # gem install -i ~/dev/merbapp/gems activesupport-post-2.0.2gem activerecord-post-2.0.2.gem
28
+ #
29
+ # Since RubyGems will search merb_app_root/gems for dependencies, order
30
+ # in statement above is important: we need to install ActiveSupport which
31
+ # ActiveRecord depends on first.
32
+ #
33
+ # Remember that bundling of dependencies as gems with your application
34
+ # makes it independent of the environment it runs in and is a very
35
+ # good, encouraged practice to follow.
2
36
  Gem.clear_paths
3
37
  Gem.path.unshift(Merb.root / "gems")
4
38
 
5
- # Make the app's "lib" directory a place where ruby files get "require"d from
6
- $LOAD_PATH.unshift(Merb.root / "lib")
39
+ # If you want modules and classes from libraries organized like
40
+ # merbapp/lib/magicwand/lib/magicwand.rb to autoload,
41
+ # uncomment this.
42
+ # Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
7
43
 
8
44
  <% require 'sha1' %>
9
- Merb::Config.use do |c|
10
-
11
- ### Sets up a custom session id key, if you want to piggyback sessions of other applications
12
- ### with the cookie session store. If not specified, defaults to '_session_id'.
13
- # c[:session_id_key] = '_session_id'
14
-
15
- c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
16
- c[:session_store] = 'cookie'
17
- end
18
45
 
19
- ### Merb doesn't come with database support by default. You need
20
- ### an ORM plugin. Install one, and uncomment one of the following lines,
21
- ### if you need a database.
22
46
 
23
- ### Uncomment for DataMapper ORM
47
+ # ==== Dependencies
48
+
49
+ # These are some examples of how you might specify dependencies.
50
+ # Dependencies load is delayed to one of later Merb app
51
+ # boot stages. It may be important when
52
+ # later part of your configuration relies on libraries specified
53
+ # here.
54
+ #
55
+ # dependencies "RedCloth", "merb_helpers"
56
+ # OR
57
+ # dependency "RedCloth", "> 3.0"
58
+ # OR
59
+ # dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
60
+ Merb::BootLoader.after_app_loads do
61
+ # Add dependencies here that must load after the application loads:
62
+
63
+ # dependency "magic_admin" # this gem uses the app's model classes
64
+ end
65
+
66
+ #
67
+ # ==== Set up your ORM of choice
68
+ #
69
+
70
+ # Merb doesn't come with database support by default. You need
71
+ # an ORM plugin. Install one, and uncomment one of the following lines,
72
+ # if you need a database.
73
+
74
+ # Uncomment for DataMapper ORM
24
75
  <%= "# " unless default_orm?(:datamapper) %>use_orm :datamapper
25
76
 
26
- ### Uncomment for ActiveRecord ORM
77
+ # Uncomment for ActiveRecord ORM
27
78
  <%= "# " unless default_orm?(:activerecord) %>use_orm :activerecord
28
79
 
29
- ### Uncomment for Sequel ORM
80
+ # Uncomment for Sequel ORM
30
81
  <%= "# " unless default_orm?(:sequel) %>use_orm :sequel
31
82
 
32
83
 
33
- ### This defines which test framework the generators will use
34
- ### rspec is turned on by default
35
- ###
36
- ### Note that you need to install the merb_rspec if you want to ue
37
- ### rspec and merb_test_unit if you want to use test_unit.
38
- ### merb_rspec is installed by default if you did gem install
39
- ### merb.
40
- ###
84
+ #
85
+ # ==== Pick what you test with
86
+ #
87
+
88
+ # This defines which test framework the generators will use
89
+ # rspec is turned on by default
90
+ #
91
+ # Note that you need to install the merb_rspec if you want to ue
92
+ # rspec and merb_test_unit if you want to use test_unit.
93
+ # merb_rspec is installed by default if you did gem install
94
+ # merb.
95
+ #
41
96
  <%= "# " unless default_test_suite?(:test) %>use_test :test_unit
42
97
  <%= "# " unless default_test_suite?(:spec) %>use_test :rspec
43
98
 
44
- ### Add your other dependencies here
45
99
 
46
- # These are some examples of how you might specify dependencies.
47
- #
48
- # dependencies "RedCloth", "merb_helpers"
49
- # OR
50
- # dependency "RedCloth", "> 3.0"
51
- # OR
52
- # dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
100
+ #
101
+ # ==== Set up your basic configuration
102
+ #
103
+ Merb::Config.use do |c|
53
104
 
54
- Merb::BootLoader.after_app_loads do
55
- ### Add dependencies here that must load after the application loads:
105
+ # Sets up a custom session id key, if you want to piggyback sessions of other applications
106
+ # with the cookie session store. If not specified, defaults to '_session_id'.
107
+ # c[:session_id_key] = '_session_id'
56
108
 
57
- # dependency "magic_admin" # this gem uses the app's model classes
109
+ c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
110
+ c[:session_store] = 'cookie'
58
111
  end
112
+
113
+
114
+ # ==== Tune your inflector
115
+
116
+ # To fine tune your inflector use word, singular_word and plural_word
117
+ # methods of Language::English::Inflector module metaclass.
118
+ #
119
+ # Here we define erratum/errata exception case:
120
+ #
121
+ # Language::English::Inflector.word "erratum", "errata"
122
+ #
123
+ # In case singular and plural forms are the same omit
124
+ # second argument on call:
125
+ #
126
+ # Language::English::Inflector.word 'information'
127
+ #
128
+ # You can also define general, singularization and pluralization
129
+ # rules:
130
+ #
131
+ # Once the following rule is defined:
132
+ # Language::English::Inflector.rule 'y', 'ies'
133
+ #
134
+ # You can see the following results:
135
+ # irb> "fly".plural
136
+ # => flies
137
+ # irb> "cry".plural
138
+ # => cries
139
+ #
140
+ # Example for singularization rule:
141
+ #
142
+ # Language::English::Inflector.singular_rule 'o', 'oes'
143
+ #
144
+ # Works like this:
145
+ # irb> "heroes".singular
146
+ # => hero
147
+ #
148
+ # Example of pluralization rule:
149
+ # Language::English::Inflector.singular_rule 'fe', 'ves'
150
+ #
151
+ # And the result is:
152
+ # irb> "wife".plural
153
+ # => wives
@@ -23,7 +23,7 @@ spec = Gem::Specification.new do |s|
23
23
  s.add_dependency('merb', '>= 0.4.0')
24
24
  s.require_path = 'lib'
25
25
  s.autorequire = PLUGIN
26
- s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
26
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
27
27
  end
28
28
 
29
29
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -31,7 +31,7 @@ Rake::GemPackageTask.new(spec) do |pkg|
31
31
  end
32
32
 
33
33
  task :install => [:package] do
34
- sh %{sudo gem install pkg/#{NAME}-#{VERSION}}
34
+ sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
35
35
  end
36
36
 
37
37
  namespace :jruby do
@@ -27,7 +27,6 @@ app_help = <<-EOF
27
27
  merb-gen app app_name (for a standard application)
28
28
  merb-gen app app_name --flat (for a flattened application)
29
29
  merb-gen app app_name --very-flat (for a single file application)
30
- merb-gen frozen-merb (script to run from frozen gems/framework)
31
30
  merb-gen plugin plugin_name (creates a plugin gem skeleton)
32
31
 
33
32
  Other Generators:
@@ -76,10 +75,6 @@ elsif ARGV[0] && ARGV[0] == "app" && ARGV[1] && ARGV[1] !~ /^-/
76
75
  elsif ARGV[0] && ARGV[0] == "plugin"
77
76
  Merb::ApplicationGenerator.run ARGV[1], ARGV[2..-1], "merb_plugin", command || "generate"
78
77
 
79
- # merb-gen frozen-merb
80
- elsif ARGV[0] && ARGV[0] == "frozen-merb"
81
- Merb::ComponentGenerator.run "frozen-merb", ["frozen-merb"], "freezer", command || "generate"
82
-
83
78
  # merb-gen controller foo
84
79
  # merb-gen resource foo --test
85
80
  elsif ARGV[1] && ARGV[1] !~ /^-/
@@ -29,10 +29,11 @@ class Merb::GeneratorBase < RubiGen::Base
29
29
  # Set the assigns that should be used for path-interpolation and building templates
30
30
  @assigns = {:base_name => File.basename(@name), :test_type => options["spec"] ? "rspec" : "test_unit"}
31
31
 
32
- FileUtils.mkdir_p @name
32
+ FileUtils.mkdir_p @name
33
+ create_dirs
33
34
  copy_dirs
34
35
  copy_files
35
-
36
+
36
37
  display_framework_selections
37
38
  end
38
39
  end
@@ -55,8 +56,11 @@ class Merb::GeneratorBase < RubiGen::Base
55
56
  puts
56
57
  puts "Your app will use the #{@assigns[:test_type]} test framework."
57
58
  if Gem.cache.search("merb_#{@assigns[:test_type]}").size == 0
58
- puts "You need to install the merb_#{@assigns[:test_type]} gem."
59
+ puts "You need to install the merb_#{@assigns[:test_type]} gem." unless @assigns[:test_type] == 'rspec'
59
60
  end
60
61
  puts
61
62
  end
63
+
64
+ def create_dirs
65
+ end
62
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ autorequire: merb-gen
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-03-24 00:00:00 -05:00
12
+ date: 2008-05-04 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.9.2
22
+ version: 0.9.3
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: rubigen
@@ -159,12 +159,6 @@ files:
159
159
  - merb_generators/controller/templates/app/views/%controller_file_name%
160
160
  - merb_generators/controller/templates/app/views/%controller_file_name%/index.html.erb
161
161
  - merb_generators/controller/USAGE
162
- - merb_generators/freezer
163
- - merb_generators/freezer/freezer_generator.rb
164
- - merb_generators/freezer/templates
165
- - merb_generators/freezer/templates/script
166
- - merb_generators/freezer/templates/script/frozen-merb
167
- - merb_generators/freezer/USAGE
168
162
  - merb_generators/part_controller
169
163
  - merb_generators/part_controller/part_controller_generator.rb
170
164
  - merb_generators/part_controller/templates
File without changes
@@ -1,25 +0,0 @@
1
- class FreezerGenerator < Merb::GeneratorBase
2
-
3
- def initialize(args, runtime_args = {})
4
- @base = File.dirname(__FILE__)
5
- super
6
- end
7
-
8
- def manifest
9
- record do |m|
10
- @m = m
11
- @assigns = {}
12
- copy_dirs
13
- m.file "script/frozen-merb", "script/frozen-merb", :chmod => 0755, :shebang => DEFAULT_SHEBANG
14
- end
15
- end
16
-
17
- protected
18
- def banner
19
- <<-EOS.split("\n").map{|x| x.strip}.join("\n")
20
- Creates a frozen-merb script that runs merb from framework/ or gems/
21
-
22
- USAGE: #{spec.name} frozen-merb
23
- EOS
24
- end
25
- end
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- __DIR__ = File.join(File.dirname(__FILE__),"..")
4
-
5
- framework = File.join(__DIR__,"framework")
6
-
7
- if File.directory?(framework)
8
- puts "Running from frozen framework"
9
- core = File.join(framework,"merb-core")
10
- if File.directory?(core)
11
- $:.push File.join(core,"lib")
12
- end
13
- more = File.join(framework,"merb-more")
14
- if File.directory?(more)
15
- Dir.new(more).select {|d| d =~ /merb-/}.each do |d|
16
- $:.push File.join(more,d,'lib')
17
- end
18
- end
19
- plugins = File.join(framework,"merb-plugins")
20
- if File.directory?(plugins)
21
- Dir.new(plugins).select {|d| d =~ /merb_/}.each do |d|
22
- $:.push File.join(plugins,d,'lib')
23
- end
24
- end
25
- require "merb-core/core_ext/kernel"
26
- require "merb-core/core_ext/rubygems"
27
- else
28
- gem = Dir.glob(__DIR__ + "/gems/gems/merb-core-*").last
29
- raise "Can't run frozen without framework/ or local gem" unless gem
30
- require gem + "/lib/merb-core/core_ext/kernel"
31
- require gem + "/lib/merb-core/core_ext/rubygems"
32
-
33
- Gem.clear_paths
34
- Gem.path.unshift(__DIR__+"/gems")
35
- end
36
-
37
- require 'merb-core'
38
- unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
39
- ARGV.push *%w[-a mongrel]
40
- end
41
-
42
- Merb.frozen!
43
- Merb.start