merb-gen 0.9.5 → 0.9.6

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/Rakefile CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "jonas.nicklas@gmail.com"
17
17
 
18
18
  GEM_NAME = "merb-gen"
19
19
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
20
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.5") + PKG_BUILD
20
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.6") + PKG_BUILD
21
21
 
22
22
  RELEASE_NAME = "REL #{GEM_VERSION}"
23
23
 
@@ -38,8 +38,8 @@ spec = Gem::Specification.new do |s|
38
38
  s.bindir = "bin"
39
39
  s.executables = %w( merb-gen )
40
40
 
41
- s.add_dependency "merb-core", ">= 0.9.5"
42
- s.add_dependency "templater", ">= 0.1.5"
41
+ s.add_dependency "merb-core", ">= 0.9.6"
42
+ s.add_dependency "templater", ">= 0.2.0"
43
43
 
44
44
  s.require_path = 'lib'
45
45
  s.autorequire = GEM_NAME
@@ -52,14 +52,14 @@ end
52
52
 
53
53
  desc "Install the gem"
54
54
  task :install => [:package] do
55
- sh %{#{sudo} gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION} --no-update-sources}
55
+ sh install_command(GEM_NAME, GEM_VERSION)
56
56
  end
57
57
 
58
58
  namespace :jruby do
59
59
 
60
60
  desc "Run :package and install the resulting .gem with jruby"
61
61
  task :install => :package do
62
- sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{GEM_NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
62
+ sh jinstall_command(GEM_NAME, GEM_VERSION)
63
63
  end
64
64
 
65
65
  end
data/bin/merb-gen CHANGED
@@ -1,6 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
3
+ # See also: merb-gen scripts and script/merb-gen
4
+
5
+ # Try to use minigems instead of the fully rubygems library
6
+ begin
7
+ require 'minigems'
8
+ rescue LoadError
9
+ require 'rubygems'
10
+ end
11
+
12
+ # Load script helpers if available - either local or system-wide.
13
+ begin
14
+ # Figure out the merb root - defaults to the current directory.
15
+ root_key = %w[-m --merb-root].detect { |o| ARGV.index(o) }
16
+ root = ARGV[ARGV.index(root_key) + 1] if root_key
17
+ __DIR__ = root.to_a.empty? ? Dir.getwd : root
18
+
19
+ # Piggyback on the merb-core rubygem for initial setup scripts.
20
+ # Requiring it doesn't affect the local gem version of merb-core
21
+ # we might effectively want to load here after.
22
+ if merb_core_dir = Dir[File.join(__DIR__, 'gems', 'gems', 'merb-core-*')].last
23
+ require File.join(merb_core_dir, 'lib', 'merb-core', 'script')
24
+ else
25
+ require 'merb-core/script'
26
+ end
27
+ # Now setup local gems to be incorporated into the normal loaded gems.
28
+ # Unless the option --no-frozen is given, local gems are enabled.
29
+ include Merb::ScriptHelpers
30
+ setup_local_gems!(__DIR__)
31
+ rescue LoadError
32
+ end
33
+
4
34
  require 'merb-gen'
5
35
 
6
36
  Merb::BootLoader.after_app_loads do
@@ -17,24 +17,24 @@ module Merb::Generators
17
17
 
18
18
  invoke :helper
19
19
 
20
- template :controller do
21
- source('app/controllers/%file_name%.rb')
22
- destination("app/controllers", base_path, "#{file_name}.rb")
20
+ template :controller do |template|
21
+ template.source = 'app/controllers/%file_name%.rb'
22
+ template.destination = "app/controllers" / base_path / "#{file_name}.rb"
23
23
  end
24
24
 
25
- template :index_erb, :template_engine => :erb do
26
- source('app/views/%file_name%/index.html.erb')
27
- destination("app/views", base_path, "#{file_name}/index.html.erb")
25
+ template :index_erb, :template_engine => :erb do |template|
26
+ template.source = 'app/views/%file_name%/index.html.erb'
27
+ template.destination = "app/views" / base_path / "#{file_name}/index.html.erb"
28
28
  end
29
29
 
30
- template :controller_spec, :testing_framework => :rspec do
31
- source('spec/controllers/%file_name%_spec.rb')
32
- destination("spec/controllers", base_path, "#{file_name}_spec.rb")
30
+ template :controller_spec, :testing_framework => :rspec do |template|
31
+ template.source = 'spec/controllers/%file_name%_spec.rb'
32
+ template.destination = "spec/controllers" / base_path / "#{file_name}_spec.rb"
33
33
  end
34
34
 
35
- template :controller_test_unit, :testing_framework => :test_unit do
36
- source('test/controllers/%file_name%_test.rb')
37
- destination("test/controllers", base_path, "#{file_name}_test.rb")
35
+ template :controller_test_unit, :testing_framework => :test_unit do |template|
36
+ template.source = 'test/controllers/%file_name%_test.rb'
37
+ template.destination = "test/controllers" / base_path / "#{file_name}_test.rb"
38
38
  end
39
39
 
40
40
  end
@@ -14,14 +14,14 @@ module Merb::Generators
14
14
 
15
15
  first_argument :name, :required => true, :desc => "helper name"
16
16
 
17
- template :helper do
18
- source('app/helpers/%file_name%_helper.rb')
19
- destination("app/helpers", base_path, "#{file_name}_helper.rb")
17
+ template :helper do |template|
18
+ template.source = 'app/helpers/%file_name%_helper.rb'
19
+ template.destination = "app/helpers" / base_path / "#{file_name}_helper.rb"
20
20
  end
21
21
 
22
- template :helper_spec, :testing_framework => :rspec do
23
- source('spec/helpers/%file_name%_helper_spec.rb')
24
- destination("spec/helpers", base_path, "#{file_name}_helper_spec.rb")
22
+ template :helper_spec, :testing_framework => :rspec do |template|
23
+ template.source = 'spec/helpers/%file_name%_helper_spec.rb'
24
+ template.destination = "spec/helpers" / base_path / "#{file_name}_helper_spec.rb"
25
25
  end
26
26
 
27
27
  end
@@ -15,9 +15,9 @@ module Merb::Generators
15
15
 
16
16
  first_argument :name, :required => true, :desc => "layout name"
17
17
 
18
- template :layout_erb, :template_engine => :erb do
19
- source('app/views/layout/%file_name%.html.erb')
20
- destination("app/views/layout/#{file_name}.html.erb")
18
+ template :layout_erb, :template_engine => :erb do |template|
19
+ template.source = 'app/views/layout/%file_name%.html.erb'
20
+ template.destination = "app/views/layout/#{file_name}.html.erb"
21
21
  end
22
22
 
23
23
  end
@@ -13,9 +13,9 @@ module Merb::Generators
13
13
 
14
14
  first_argument :name, :required => true, :desc => "Application name"
15
15
 
16
- template :application do
17
- source('application.rbt')
18
- destination("#{base_name}.rb")
16
+ template :application do |template|
17
+ template.source = 'application.rbt'
18
+ template.destination = "#{base_name}.rb"
19
19
  end
20
20
 
21
21
  file :spec_helper, 'spec/spec_helper.rb', 'spec/spec_helper.rb'
@@ -17,19 +17,19 @@ module Merb::Generators
17
17
  first_argument :name, :required => true, :desc => "model name"
18
18
  second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated model properties in form of name:type. Example: state:string"
19
19
 
20
- template :model_none, :orm => :none do
21
- source("app/models/%file_name%.rb")
22
- destination("app/models", base_path, "#{file_name}.rb")
20
+ template :model_none, :orm => :none do |template|
21
+ template.source = "app/models/%file_name%.rb"
22
+ template.destination = "app/models" / base_path / "#{file_name}.rb"
23
23
  end
24
24
 
25
- template :spec, :testing_framework => :rspec do
26
- source('spec/models/%file_name%_spec.rb')
27
- destination("spec/models", base_path, "#{file_name}_spec.rb")
25
+ template :spec, :testing_framework => :rspec do |template|
26
+ template.source = 'spec/models/%file_name%_spec.rb'
27
+ template.destination = "spec/models" / base_path / "#{file_name}_spec.rb"
28
28
  end
29
29
 
30
- template :test_unit, :testing_framework => :test_unit do
31
- source('test/models/%file_name%_test.rb')
32
- destination("test/models", base_path, "#{file_name}_test.rb")
30
+ template :test_unit, :testing_framework => :test_unit do |template|
31
+ template.source = 'test/models/%file_name%_test.rb'
32
+ template.destination = "test/models" / base_path / "#{file_name}_test.rb"
33
33
  end
34
34
 
35
35
  def attributes?
@@ -16,14 +16,14 @@ module Merb::Generators
16
16
  generator.new(destination_root, options, "#{full_class_name}Part")
17
17
  end
18
18
 
19
- template :controller do
20
- source('app/parts/%file_name%_part.rb')
21
- destination("app/parts", base_path, "#{file_name}_part.rb")
19
+ template :controller do |template|
20
+ template.source = 'app/parts/%file_name%_part.rb'
21
+ template.destination = "app/parts" / base_path / "#{file_name}_part.rb"
22
22
  end
23
23
 
24
- template :index do
25
- source('app/parts/views/%file_name%_part/index.html.erb')
26
- destination("app/parts/views", base_path, "#{file_name}_part/index.html.erb")
24
+ template :index do |template|
25
+ template.source = 'app/parts/views/%file_name%_part/index.html.erb'
26
+ template.destination = "app/parts/views" / base_path / "#{file_name}_part/index.html.erb"
27
27
  end
28
28
 
29
29
  end
@@ -27,26 +27,26 @@ module Merb::Generators
27
27
  # add controller and view templates for each of the four big ORM's
28
28
 
29
29
 
30
- template :controller_none, :orm => :none do
31
- source("app/controllers/%file_name%.rb")
32
- destination("app/controllers", base_path, "#{file_name}.rb")
30
+ template :controller_none, :orm => :none do |template|
31
+ template.source = "app/controllers/%file_name%.rb"
32
+ template.destination = "app/controllers" / base_path / "#{file_name}.rb"
33
33
  end
34
34
 
35
35
  [:index, :show, :edit, :new].each do |view|
36
- template "view_#{view}_none".to_sym, :orm => :none do
37
- source("app/views/%file_name%/#{view}.html.erb")
38
- destination("app/views", base_path, "#{file_name}/#{view}.html.erb")
36
+ template "view_#{view}_none".to_sym, :orm => :none do |template|
37
+ template.source = "app/views/%file_name%/#{view}.html.erb"
38
+ template.destination = "app/views" / base_path / "#{file_name}/#{view}.html.erb"
39
39
  end
40
40
  end
41
41
 
42
- template :controller_spec, :testing_framework => :rspec, :orm => :none do
43
- source('spec/controllers/%file_name%_spec.rb')
44
- destination("spec/controllers", base_path, "#{file_name}_spec.rb")
42
+ template :controller_spec, :testing_framework => :rspec, :orm => :none do |template|
43
+ template.source = 'spec/controllers/%file_name%_spec.rb'
44
+ template.destination = "spec/controllers" / base_path / "#{file_name}_spec.rb"
45
45
  end
46
46
 
47
- template :controller_test_unit, :testing_framework => :test_unit, :orm => :none do
48
- source('test/controllers/%file_name%_test.rb')
49
- destination("test/controllers", base_path, "#{file_name}_test.rb")
47
+ template :controller_test_unit, :testing_framework => :test_unit, :orm => :none do |template|
48
+ template.source = 'test/controllers/%file_name%_test.rb'
49
+ template.destination = "test/controllers" / base_path / "#{file_name}_test.rb"
50
50
  end
51
51
 
52
52
  def model_class_name
@@ -0,0 +1,51 @@
1
+ module Merb::Generators
2
+
3
+ class ScriptsGenerator < Generator
4
+
5
+ def self.source_root
6
+ File.join(super, 'component', 'scripts')
7
+ end
8
+
9
+ desc <<-DESC
10
+ Generates local Merb scripts (script/merb and script/merb-gen for example).
11
+ DESC
12
+
13
+ # Install a script/merb script for local execution (for frozen apps).
14
+ file :script_merb do |f|
15
+ f.source = bin_merb_location
16
+ f.destination = 'script/merb'
17
+ end
18
+
19
+ # Install a script/merb-gen script for local execution (for frozen apps).
20
+ file :script_merb_gen do |f|
21
+ f.source = bin_merb_gen_location
22
+ f.destination = 'script/merb-gen'
23
+ end
24
+
25
+ protected
26
+
27
+ def bin_merb_location
28
+ if (gem_spec = Gem.source_index.search('merb-core').last) &&
29
+ File.exists?(location = File.join(gem_spec.full_gem_path, gem_spec.bindir, 'merb'))
30
+ location
31
+ else
32
+ 'script/merb'
33
+ end
34
+ end
35
+
36
+ def bin_merb_gen_location
37
+ if (gem_spec = Gem.source_index.search('merb-gen').last) &&
38
+ File.exists?(location = File.join(gem_spec.full_gem_path, gem_spec.bindir, 'merb-gen'))
39
+ location
40
+ else
41
+ 'script/merb-gen'
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ add :scripts, ScriptsGenerator
48
+
49
+ puts ScriptsGenerator
50
+
51
+ end
@@ -1,6 +1,25 @@
1
1
  require 'rubygems'
2
- Gem.clear_paths
3
- Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
2
+
3
+ # Figure out the merb root - defaults to the current directory.
4
+ __DIR__ = ENV['MERB_ROOT'] || Dir.getwd
5
+
6
+ # Piggyback on the merb-core rubygem for initial setup scripts.
7
+ # Requiring it doesn't affect the local gem version of merb-core
8
+ # we might effectively want to load here after.
9
+ if merb_core_dir = Dir[File.join(__DIR__, 'gems', 'gems', 'merb-core-*')].last
10
+ require File.join(merb_core_dir, 'lib', 'merb-core', 'script')
11
+ else
12
+ require 'merb-core/script'
13
+ end
14
+
15
+ # Include some script helper methods.
16
+ include Merb::ScriptHelpers
17
+
18
+ # Now setup local gems to be incorporated into the normal loaded gems.
19
+ setup_local_gems!(__DIR__)
20
+
21
+ # When running rake tasks, you can disable local gems using NO_FROZEN:
22
+ # rake NO_FROZEN=true -T # see all rake tasks, loaded from system gems.
4
23
 
5
24
  require 'rake'
6
25
  require 'rake/rdoctask'
@@ -8,44 +27,8 @@ require 'rake/testtask'
8
27
  require 'spec/rake/spectask'
9
28
  require 'fileutils'
10
29
 
11
- ##
12
- # requires frozen merb-core (from /framework)
13
- # adds the other components to the load path
14
- def require_frozen_framework
15
- framework = File.join(File.dirname(__FILE__), "framework")
16
- if File.directory?(framework)
17
- puts "Running from frozen framework"
18
- core = File.join(framework,"merb-core")
19
- if File.directory?(core)
20
- puts "using merb-core from #{core}"
21
- $:.unshift File.join(core,"lib")
22
- require 'merb-core'
23
- end
24
- more = File.join(framework,"merb-more")
25
- if File.directory?(more)
26
- Dir.new(more).select {|d| d =~ /merb-/}.each do |d|
27
- $:.unshift File.join(more,d,'lib')
28
- end
29
- end
30
- plugins = File.join(framework,"merb-plugins")
31
- if File.directory?(plugins)
32
- Dir.new(plugins).select {|d| d =~ /merb_/}.each do |d|
33
- $:.unshift File.join(plugins,d,'lib')
34
- end
35
- end
36
- require "merb-core/core_ext/kernel"
37
- require "merb-core/core_ext/rubygems"
38
- else
39
- p "merb doesn't seem to be frozen in /framework"
40
- require 'merb-core'
41
- end
42
- end
43
-
44
- if ENV['FROZEN']
45
- require_frozen_framework
46
- else
47
- require 'merb-core'
48
- end
30
+ # Require the *real* merb-core, which is the local version for a frozen setup.
31
+ require "merb-core"
49
32
 
50
33
  require 'merb-core/tasks/merb'
51
34
  include FileUtils
@@ -63,7 +46,6 @@ tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks")
63
46
  rake_files = Dir["#{tasks_path}/*.rake"]
64
47
  rake_files.each{|rake_file| load rake_file }
65
48
 
66
-
67
49
  desc "start runner environment"
68
50
  task :merb_env do
69
51
  Merb.start_environment(:environment => init_env, :adapter => 'runner')
@@ -0,0 +1,9 @@
1
+ module Merb
2
+ module Session
3
+
4
+ # The Merb::Session module gets mixed into Merb::SessionContainer to allow
5
+ # app-level functionality; it will be included and methods will be available
6
+ # through request.session as instance methods.
7
+
8
+ end
9
+ end
@@ -4,5 +4,6 @@ Merb::Config.use { |c|
4
4
  c[:reload_classes] = true
5
5
  c[:reload_time] = 0.5
6
6
  c[:log_auto_flush ] = true
7
+ c[:ignore_tampered_cookies] = true
7
8
  c[:log_level] = :debug
8
- }
9
+ }
@@ -1,3 +1,5 @@
1
+ $KCODE = 'UTF8'
2
+
1
3
  #
2
4
  # ==== Structure of Merb initializer
3
5
  #
@@ -33,8 +35,6 @@
33
35
  # Remember that bundling of dependencies as gems with your application
34
36
  # makes it independent of the environment it runs in and is a very
35
37
  # good, encouraged practice to follow.
36
- Gem.clear_paths
37
- Gem.path.unshift(Merb.root / "gems")
38
38
 
39
39
  # If you want modules and classes from libraries organized like
40
40
  # merbapp/lib/magicwand/lib/magicwand.rb to autoload,
@@ -127,8 +127,9 @@ Merb::Config.use do |c|
127
127
  c[:session_secret_key] = '<%= SHA1.new(rand(100000000000).to_s).to_s %>'
128
128
 
129
129
  # There are various options here, by default Merb comes with 'cookie',
130
- # 'memory' or 'memcached'. You can of course use your favorite ORM
131
- # instead: 'datamapper', 'sequel' or 'activerecord'.
130
+ # 'memory', 'memcache' or 'container'.
131
+ # You can of course use your favorite ORM instead:
132
+ # 'datamapper', 'sequel' or 'activerecord'.
132
133
  c[:session_store] = 'cookie'
133
134
  end
134
135
 
@@ -136,22 +137,22 @@ end
136
137
  # ==== Tune your inflector
137
138
 
138
139
  # To fine tune your inflector use the word, singular_word and plural_word
139
- # methods of Language::English::Inflector module metaclass.
140
+ # methods of English::Inflect module metaclass.
140
141
  #
141
142
  # Here we define erratum/errata exception case:
142
143
  #
143
- # Language::English::Inflector.word "erratum", "errata"
144
+ # English::Inflect.word "erratum", "errata"
144
145
  #
145
146
  # In case singular and plural forms are the same omit
146
147
  # second argument on call:
147
148
  #
148
- # Language::English::Inflector.word 'information'
149
+ # English::Inflect.word 'information'
149
150
  #
150
151
  # You can also define general, singularization and pluralization
151
152
  # rules:
152
153
  #
153
154
  # Once the following rule is defined:
154
- # Language::English::Inflector.rule 'y', 'ies'
155
+ # English::Inflect.rule 'y', 'ies'
155
156
  #
156
157
  # You can see the following results:
157
158
  # irb> "fly".plural
@@ -161,14 +162,14 @@ end
161
162
  #
162
163
  # Example for singularization rule:
163
164
  #
164
- # Language::English::Inflector.singular_rule 'o', 'oes'
165
+ # English::Inflect.singular_rule 'o', 'oes'
165
166
  #
166
167
  # Works like this:
167
168
  # irb> "heroes".singular
168
169
  # => hero
169
170
  #
170
171
  # Example of pluralization rule:
171
- # Language::English::Inflector.singular_rule 'fe', 'ves'
172
+ # English::Inflect.singular_rule 'fe', 'ves'
172
173
  #
173
174
  # And the result is:
174
175
  # irb> "wife".plural
@@ -1,3 +1,5 @@
1
+ $KCODE = 'UTF8'
2
+
1
3
  # Move this to application.rb if you want it to be reloadable in dev mode.
2
4
  Merb::Router.prepare do |r|
3
5
  r.match('/').to(:controller => 'foo', :action =>'index')
@@ -15,4 +17,4 @@ Merb::Config.use { |c|
15
17
  c[:exception_details] = true,
16
18
  c[:reload_classes] = true,
17
19
  c[:reload_time] = 0.5
18
- }
20
+ }
@@ -1,3 +1,5 @@
1
+ $KCODE = 'UTF8'
2
+
1
3
  # run very flat apps with merb -I <app file>.
2
4
 
3
5
  Merb::Config.use { |c|
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by 'merb-gen scripts' and
4
+ # is identical to the executables merb-core/bin/merb
5
+
6
+ # Try to use minigems instead of the fully rubygems library
7
+ begin
8
+ require 'minigems'
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ end
12
+
13
+ # Load script helpers if available - either local or system-wide.
14
+ begin
15
+ # Figure out the merb root - defaults to the current directory.
16
+ root_key = %w[-m --merb-root].detect { |o| ARGV.index(o) }
17
+ root = ARGV[ARGV.index(root_key) + 1] if root_key
18
+ __DIR__ = root.to_a.empty? ? Dir.getwd : root
19
+
20
+ # Piggyback on the merb-core rubygem for initial setup scripts.
21
+ # Requiring it doesn't affect the local gem version of merb-core
22
+ # we might effectively want to load here after.
23
+ if merb_core_dir = Dir[File.join(__DIR__, 'gems', 'gems', 'merb-core-*')].last
24
+ require File.join(merb_core_dir, 'lib', 'merb-core', 'script')
25
+ else
26
+ require 'merb-core/script'
27
+ end
28
+ # Now setup local gems to be incorporated into the normal loaded gems.
29
+ # Unless the option --no-frozen is given, local gems are enabled.
30
+ include Merb::ScriptHelpers
31
+ setup_local_gems!(__DIR__)
32
+ rescue LoadError
33
+ end
34
+
35
+ require 'merb-core'
36
+
37
+ ARGV.push '-H' if ARGV[0] && ARGV[0] =~ /^[^-]/
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.start
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by 'merb-gen scripts' and
4
+ # is identical to the executable merb-gen/bin/merb-gen
5
+
6
+ # Try to use minigems instead of the fully rubygems library
7
+ begin
8
+ require 'minigems'
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ end
12
+
13
+ # Load script helpers if available - either local or system-wide.
14
+ begin
15
+ # Figure out the merb root - defaults to the current directory.
16
+ root_key = %w[-m --merb-root].detect { |o| ARGV.index(o) }
17
+ root = ARGV[ARGV.index(root_key) + 1] if root_key
18
+ __DIR__ = root.to_a.empty? ? Dir.getwd : root
19
+
20
+ # Piggyback on the merb-core rubygem for initial setup scripts.
21
+ # Requiring it doesn't affect the local gem version of merb-core
22
+ # we might effectively want to load here after.
23
+ if merb_core_dir = Dir[File.join(__DIR__, 'gems', 'gems', 'merb-core-*')].last
24
+ require File.join(merb_core_dir, 'lib', 'merb-core', 'script')
25
+ else
26
+ require 'merb-core/script'
27
+ end
28
+ # Now setup local gems to be incorporated into the normal loaded gems.
29
+ # Unless the option --no-frozen is given, local gems are enabled.
30
+ include Merb::ScriptHelpers
31
+ setup_local_gems!(__DIR__)
32
+ rescue LoadError
33
+ end
34
+
35
+ require 'merb-gen'
36
+
37
+ Merb::BootLoader.after_app_loads do
38
+ Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
39
+ end
40
+
41
+ Merb.start :environment => 'development', :log_level => 'error'
data/lib/merb-gen.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'rubygems'
2
2
  require 'merb-core'
3
3
  require 'sha1'
4
- gem 'templater', '>= 0.1.5'
4
+ gem 'templater', '>= 0.2.0'
5
5
  require 'templater'
6
6
 
7
7
  path = File.join(File.dirname(__FILE__))
8
8
 
9
- require path / "merb-gen" / "generator"
10
- require path / "merb-gen" / "named_generator"
11
- require path / "merb-gen" / "namespaced_generator"
9
+ require path / "merb-gen" / "generator"
10
+ require path / "merb-gen" / "named_generator"
11
+ require path / "merb-gen" / "namespaced_generator"
12
12
  require path / "generators" / "merb"
13
13
  require path / "generators" / "merb" / "merb_full"
14
14
  require path / "generators" / "merb" / "merb_flat"
@@ -22,8 +22,8 @@ require path / "generators" / "session_migration"
22
22
  require path / "generators" / "model"
23
23
  require path / "generators" / "resource_controller"
24
24
  require path / "generators" / "resource"
25
- require path / "generators" / "freezer"
26
25
  require path / "generators" / "layout"
26
+ require path / "generators" / "scripts"
27
27
 
28
28
  Templater::Discovery.discover!("merb-gen")
29
29
 
@@ -27,13 +27,13 @@ describe Merb::Generators::Generator do
27
27
  before do
28
28
  @class = Class.new(Merb::Generators::Generator)
29
29
  path = File.expand_path('fixtures', File.dirname(__FILE__))
30
- @class.template(:no_modules) do
31
- source path / "templates" / "no_modules.test"
32
- destination path / "results" / "no_modules.test"
30
+ @class.template(:no_modules) do |template|
31
+ template.source = path / "templates" / "no_modules.test"
32
+ template.destination = path / "results" / "no_modules.test"
33
33
  end
34
- @class.template(:some_modules) do
35
- source path / "templates" / "some_modules.test"
36
- destination path / "results" / "some_modules.test"
34
+ @class.template(:some_modules) do |template|
35
+ template.source = path / "templates" / "some_modules.test"
36
+ template.destination = path / "results" / "some_modules.test"
37
37
  end
38
38
  @generator = @class.new('/tmp', {})
39
39
  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.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ autorequire: merb-gen
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-26 00:00:00 +03:00
12
+ date: 2008-09-09 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.5
23
+ version: 0.9.6
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: templater
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.1.5
33
+ version: 0.2.0
34
34
  version:
35
35
  description: Generators suite for Merb.
36
36
  email: jonas.nicklas@gmail.com
@@ -49,7 +49,6 @@ files:
49
49
  - TODO
50
50
  - lib/generators
51
51
  - lib/generators/controller.rb
52
- - lib/generators/freezer.rb
53
52
  - lib/generators/helper.rb
54
53
  - lib/generators/layout.rb
55
54
  - lib/generators/merb
@@ -63,6 +62,7 @@ files:
63
62
  - lib/generators/part_controller.rb
64
63
  - lib/generators/resource.rb
65
64
  - lib/generators/resource_controller.rb
65
+ - lib/generators/scripts.rb
66
66
  - lib/generators/session_migration.rb
67
67
  - lib/generators/templates
68
68
  - lib/generators/templates/application
@@ -73,6 +73,9 @@ files:
73
73
  - lib/generators/templates/application/merb/app/controllers/exceptions.rb
74
74
  - lib/generators/templates/application/merb/app/helpers
75
75
  - lib/generators/templates/application/merb/app/helpers/global_helpers.rb
76
+ - lib/generators/templates/application/merb/app/models
77
+ - lib/generators/templates/application/merb/app/models/merb
78
+ - lib/generators/templates/application/merb/app/models/merb/session.rb
76
79
  - lib/generators/templates/application/merb/app/views
77
80
  - lib/generators/templates/application/merb/app/views/exceptions
78
81
  - lib/generators/templates/application/merb/app/views/exceptions/internal_server_error.html.erb
@@ -146,9 +149,6 @@ files:
146
149
  - lib/generators/templates/component/controller/test
147
150
  - lib/generators/templates/component/controller/test/controllers
148
151
  - lib/generators/templates/component/controller/test/controllers/%file_name%_test.rb
149
- - lib/generators/templates/component/freezer
150
- - lib/generators/templates/component/freezer/script
151
- - lib/generators/templates/component/freezer/script/frozen_merb
152
152
  - lib/generators/templates/component/helper
153
153
  - lib/generators/templates/component/helper/app
154
154
  - lib/generators/templates/component/helper/app/helpers
@@ -246,6 +246,10 @@ files:
246
246
  - lib/generators/templates/component/resource_controller/test
247
247
  - lib/generators/templates/component/resource_controller/test/controllers
248
248
  - lib/generators/templates/component/resource_controller/test/controllers/%file_name%_test.rb
249
+ - lib/generators/templates/component/scripts
250
+ - lib/generators/templates/component/scripts/script
251
+ - lib/generators/templates/component/scripts/script/merb
252
+ - lib/generators/templates/component/scripts/script/merb-gen
249
253
  - lib/generators/templates/component/session_migration
250
254
  - lib/generators/templates/component/session_migration/activerecord
251
255
  - lib/generators/templates/component/session_migration/activerecord/schema
@@ -267,7 +271,6 @@ files:
267
271
  - spec/fixtures/templates
268
272
  - spec/fixtures/templates/no_modules.test
269
273
  - spec/fixtures/templates/some_modules.test
270
- - spec/freezer_spec.rb
271
274
  - spec/generator_spec.rb
272
275
  - spec/helper_spec.rb
273
276
  - spec/layout_spec.rb
@@ -1,19 +0,0 @@
1
- module Merb::Generators
2
-
3
- class FreezerGenerator < Generator
4
-
5
- def self.source_root
6
- File.join(super, 'component', 'freezer')
7
- end
8
-
9
- desc <<-DESC
10
- Generates Merb freezer scripts.
11
- DESC
12
-
13
- template :freezer, 'script/frozen_merb', 'script/frozen_merb'
14
-
15
- end
16
-
17
- add :freezer, FreezerGenerator
18
-
19
- 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
data/spec/freezer_spec.rb DELETED
@@ -1,17 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe Merb::Generators::FreezerGenerator do
4
-
5
- before(:each) do
6
- @generator = Merb::Generators::FreezerGenerator.new('/tmp', {})
7
- end
8
-
9
- it "should create a freezing script" do
10
- @generator.should create('/tmp/script/frozen_merb')
11
- end
12
-
13
- it "should render templates successfully" do
14
- lambda { @generator.render! }.should_not raise_error
15
- end
16
-
17
- end