merb-gen 0.9.10 → 0.9.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ module Merb::Generators
7
7
  end
8
8
 
9
9
  desc <<-DESC
10
- Generates a layout
10
+ Generates a new layout.
11
11
  DESC
12
12
 
13
13
  #option :testing_framework, :desc => 'Testing framework to use (one of: rspec, test_unit)'
@@ -34,8 +34,8 @@ module Merb
34
34
  :desc => 'Template engine to prefer for this application (one of: erb, haml).'
35
35
 
36
36
  desc <<-DESC
37
- This generates a Merb application with Ruby on Rails like structure.
38
- Generator lets you configure your ORM and testing framework of choice.
37
+ Generates a new Merb application with Ruby on Rails like structure.
38
+ You can specify the ORM and testing framework.
39
39
  DESC
40
40
 
41
41
  first_argument :name, :required => true, :desc => "Application name"
@@ -34,9 +34,8 @@ module Merb
34
34
  :desc => 'Template engine to prefer for this application (one of: erb, haml).'
35
35
 
36
36
  desc <<-DESC
37
- This generates a flat merb application: all code but config files and
38
- templates fits in one application. This is something in between Sinatra
39
- and "regular" Merb application.
37
+ Generates a new flat Merb application: all code in one file except for config files and
38
+ views, something in-between Sinatra and a "regular" Merb application.
40
39
  DESC
41
40
 
42
41
  first_argument :name, :required => true, :desc => "Application name"
@@ -38,8 +38,8 @@ module Merb
38
38
  :desc => 'Template engine to prefer for this application (one of: erb, haml).'
39
39
 
40
40
  desc <<-DESC
41
- This generates a "prepackaged" (or "opinionated") Merb application that uses DataMapper,
42
- RSpec, helpers, assets, mailer, caching, slices and merb-auth all out of the box.
41
+ Generates a new "jump start" Merb application with support for DataMapper,
42
+ helpers, assets, mailer, caching, slices and merb-auth.
43
43
  DESC
44
44
 
45
45
  first_argument :name, :required => true, :desc => "Application name"
@@ -27,8 +27,8 @@ module Merb
27
27
  :desc => 'Template engine to prefer for this application (one of: erb, haml).'
28
28
 
29
29
  desc <<-DESC
30
- This generates a very flat merb application: the whole application
31
- fits in one file, very much like Sinatra or Camping.
30
+ Generates a new very flat Merb application: the whole application
31
+ in one file, similar to Sinatra or Camping.
32
32
  DESC
33
33
 
34
34
  first_argument :name, :required => true, :desc => "Application name"
@@ -16,7 +16,7 @@ module Merb::Generators
16
16
  option :bin, :as => :boolean # TODO: explain this
17
17
 
18
18
  desc <<-DESC
19
- Merb plugin generator: lets you kick start your Merb plugin.
19
+ Generates a new Merb plugin.
20
20
  DESC
21
21
 
22
22
  glob!
@@ -7,7 +7,7 @@ module Merb::Generators
7
7
  end
8
8
 
9
9
  desc <<-DESC
10
- This is a migration generator
10
+ Generates a new database migration.
11
11
  DESC
12
12
 
13
13
  option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
@@ -7,7 +7,7 @@ module Merb::Generators
7
7
  end
8
8
 
9
9
  desc <<-DESC
10
- This is a part controller generator
10
+ Generates a new part controller.
11
11
  DESC
12
12
 
13
13
  first_argument :name, :required => true
@@ -14,4 +14,4 @@ RewriteCond %{REQUEST_FILENAME} !-f
14
14
  RewriteRule ^(.*)$ merb.fcgi [QSA,L]
15
15
 
16
16
 
17
- ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached
17
+ ErrorDocument 500 "<h2>Application Error</h2>Merb could not be reached"
@@ -5,7 +5,7 @@ require 'fileutils'
5
5
  require 'yaml'
6
6
 
7
7
  # Important - don't change this line or its position
8
- MERB_THOR_VERSION = '0.0.52'
8
+ MERB_THOR_VERSION = '0.1.0'
9
9
 
10
10
  ##############################################################################
11
11
 
@@ -301,7 +301,7 @@ module GemManagement
301
301
  end
302
302
  end
303
303
  end
304
-
304
+
305
305
  private
306
306
 
307
307
  def executable_wrapper(spec, bin_file_name, minigems = true)
@@ -325,6 +325,7 @@ end
325
325
  if File.directory?(gems_dir = File.join(Dir.pwd, 'gems')) ||
326
326
  File.directory?(gems_dir = File.join(File.dirname(__FILE__), '..', 'gems'))
327
327
  $BUNDLE = true; Gem.clear_paths; Gem.path.unshift(gems_dir)
328
+ ENV["PATH"] = "\#{File.dirname(__FILE__)}:\#{gems_dir}/bin:\#{ENV["PATH"]}"
328
329
  if (local_gem = Dir[File.join(gems_dir, "specifications", "#{spec.name}-*.gemspec")].last)
329
330
  version = File.basename(local_gem)[/-([\\.\\d]+)\\.gemspec$/, 1]
330
331
  end
@@ -476,8 +477,9 @@ module MerbThorHelper
476
477
  end
477
478
 
478
479
  def install_dependency(dependency, opts = {})
479
- opts[:version] ||= dependency.version_requirements.to_s
480
- Merb::Gem.install(dependency.name, default_install_options.merge(opts))
480
+ version = dependency.version_requirements.to_s
481
+ install_opts = default_install_options.merge(:version => version)
482
+ Merb::Gem.install(dependency.name, install_opts.merge(opts))
481
483
  end
482
484
 
483
485
  def install_dependency_from_source(dependency, opts = {})
@@ -760,8 +762,10 @@ module Merb
760
762
  if only_missing = comp == 'missing'
761
763
  message "Preparing to install missing gems #{where} using #{strategy} strategy..."
762
764
  comp = nil
765
+ clobber = false
763
766
  else
764
767
  message "Preparing to install #{where} using #{strategy} strategy..."
768
+ clobber = true
765
769
  end
766
770
 
767
771
  # If comp given, filter on known stack components
@@ -777,7 +781,7 @@ module Merb
777
781
  warning "No dependencies to install..."
778
782
  else
779
783
  puts "#{deps.length} dependencies to install..."
780
- install_dependencies(strategy, deps)
784
+ install_dependencies(strategy, deps, clobber)
781
785
  end
782
786
 
783
787
  # Show current dependency info now that we're done
@@ -873,10 +877,21 @@ module Merb
873
877
  # merb:dependencies:configure --config-file file.yml # write to the specified config file
874
878
 
875
879
  desc 'configure [comp]', 'Create a dependencies config file'
876
- method_options "--dry-run" => :boolean, "--force" => :boolean
880
+ method_options "--dry-run" => :boolean, "--force" => :boolean, "--versions" => :boolean
877
881
  def configure(comp = nil)
878
882
  # If comp given, filter on known stack components
879
883
  deps = comp ? Merb::Stack.select_component_dependencies(dependencies, comp) : dependencies
884
+
885
+ # If --versions is set, update the version_requirements with the actual version available
886
+ if options[:versions]
887
+ specs = local_gemspecs
888
+ deps.each do |dep|
889
+ if spec = specs.find { |s| s.name == dep.name }
890
+ dep.version_requirements = ::Gem::Requirement.create(spec.version)
891
+ end
892
+ end
893
+ end
894
+
880
895
  config = YAML.dump(deps.map { |d| d.to_s })
881
896
  puts "#{config}\n"
882
897
  if File.exists?(config_file) && !options[:force]
@@ -902,31 +917,33 @@ module Merb
902
917
  end
903
918
  end
904
919
 
905
- def install_dependencies(strategy, deps)
920
+ def install_dependencies(strategy, deps, clobber = true)
906
921
  if method = strategy?(strategy)
907
922
  # Clobber existing local dependencies
908
- clobber_dependencies!
923
+ clobber_dependencies! if clobber
909
924
 
910
925
  # Run the chosen strategy - collect files installed from stable gems
911
926
  installed_from_stable = send(method, deps).map { |d| d.name }
912
927
 
913
- # Sleep a bit otherwise the following steps won't see the new files
914
- sleep(deps.length) if deps.length > 0
915
-
916
- # Leave a file to denote the strategy that has been used for this dependency
917
- self.local.each do |spec|
918
- next unless File.directory?(spec.full_gem_path)
919
- unless installed_from_stable.include?(spec.name)
920
- FileUtils.touch(File.join(spec.full_gem_path, "#{strategy}.strategy"))
921
- else
922
- FileUtils.touch(File.join(spec.full_gem_path, "stable.strategy"))
923
- end
924
- end
928
+ unless dry_run?
929
+ # Sleep a bit otherwise the following steps won't see the new files
930
+ sleep(deps.length) if deps.length > 0 && deps.length <= 10
931
+
932
+ # Leave a file to denote the strategy that has been used for this dependency
933
+ self.local.each do |spec|
934
+ next unless File.directory?(spec.full_gem_path)
935
+ unless installed_from_stable.include?(spec.name)
936
+ FileUtils.touch(File.join(spec.full_gem_path, "#{strategy}.strategy"))
937
+ else
938
+ FileUtils.touch(File.join(spec.full_gem_path, "stable.strategy"))
939
+ end
940
+ end
925
941
 
926
- # Add local binaries for the installed framework dependencies
927
- comps = Merb::Stack.all_components & deps.map { |d| d.name }
928
- comps << { :no_minigems => 'merb-gen' }
929
- ensure_bin_wrapper_for(*comps)
942
+ # Add local binaries for the installed framework dependencies
943
+ comps = Merb::Stack.all_components & deps.map { |d| d.name }
944
+ comps << { :no_minigems => 'merb-gen' }
945
+ ensure_bin_wrapper_for(*comps)
946
+ end
930
947
  return true
931
948
  end
932
949
  false
@@ -967,7 +984,7 @@ module Merb
967
984
  end
968
985
  end
969
986
  end
970
-
987
+
971
988
  deps
972
989
  end
973
990
 
@@ -1037,15 +1054,12 @@ module Merb
1037
1054
  # Selectively update repositories for the matching dependencies
1038
1055
  update_dependency_repositories(deps) unless dry_run?
1039
1056
 
1040
- # Skip gem dependencies to prevent them from being installed from stable;
1041
- # however, core dependencies will be retrieved from source when available
1042
- install_opts = { :ignore_dependencies => true }
1043
1057
  if core = deps.find { |d| d.name == 'merb-core' }
1044
1058
  if dry_run?
1045
1059
  note "Installing #{core.name}..."
1046
1060
  else
1047
- if install_dependency_from_source(core, install_opts)
1048
- elsif install_dependency(core, install_opts)
1061
+ if install_dependency_from_source(core)
1062
+ elsif install_dependency(core)
1049
1063
  info "Installed #{core.name} from rubygems..."
1050
1064
  installed_from_rubygems << core
1051
1065
  end
@@ -1057,8 +1071,8 @@ module Merb
1057
1071
  if dry_run?
1058
1072
  note "Installing #{dependency.name}..."
1059
1073
  else
1060
- if install_dependency_from_source(dependency, install_opts)
1061
- elsif install_dependency(dependency, install_opts)
1074
+ if install_dependency_from_source(dependency)
1075
+ elsif install_dependency(dependency)
1062
1076
  info "Installed #{dependency.name} from rubygems..."
1063
1077
  installed_from_rubygems << dependency
1064
1078
  end
@@ -1079,24 +1093,31 @@ module Merb
1079
1093
  end
1080
1094
 
1081
1095
  # Extract application dependencies by querying the app directly.
1082
- def self.extract_dependencies(merb_root, env = 'production')
1096
+ def self.extract_dependencies(merb_root)
1083
1097
  require 'merb-core'
1084
1098
  if !@_merb_loaded || Merb.root != merb_root
1085
1099
  Merb.start_environment(
1100
+ :log_level => :fatal,
1086
1101
  :testing => true,
1087
1102
  :adapter => 'runner',
1088
- :environment => env,
1103
+ :environment => ENV['MERB_ENV'] || 'development',
1089
1104
  :merb_root => merb_root
1090
1105
  )
1091
1106
  @_merb_loaded = true
1092
1107
  end
1093
1108
  Merb::BootLoader::Dependencies.dependencies
1094
- rescue => e
1109
+ rescue StandardError => e
1095
1110
  error "Couldn't extract dependencies from application!"
1096
1111
  error e.message
1097
1112
  puts "Make sure you're executing the task from your app (--merb-root), or"
1098
1113
  puts "specify a config option (--config or --config-file=YAML_FILE)"
1099
1114
  return []
1115
+ rescue SystemExit
1116
+ error "Couldn't extract dependencies from application!"
1117
+ error "application failed to run"
1118
+ puts "Please check if your application runs using 'merb'; for example,"
1119
+ puts "look for any gem version mismatches in dependencies.rb"
1120
+ return []
1100
1121
  end
1101
1122
 
1102
1123
  # Parse the basic YAML config data, and process Gem::Dependency output.
@@ -1124,12 +1145,14 @@ module Merb
1124
1145
 
1125
1146
  DM_STACK = %w[
1126
1147
  extlib
1148
+ data_objects
1127
1149
  dm-core
1128
1150
  dm-aggregates
1129
1151
  dm-migrations
1130
1152
  dm-timestamps
1131
1153
  dm-types
1132
1154
  dm-validations
1155
+ merb_datamapper
1133
1156
  ]
1134
1157
 
1135
1158
  MERB_STACK = %w[
@@ -1142,6 +1165,11 @@ module Merb
1142
1165
  merb-mailer
1143
1166
  merb-slices
1144
1167
  merb-auth
1168
+ merb-auth-core
1169
+ merb-auth-more
1170
+ merb-auth-slice-password
1171
+ merb-param-protection
1172
+ merb-exceptions
1145
1173
  ] + DM_STACK
1146
1174
 
1147
1175
  MERB_BASICS = %w[
@@ -1218,6 +1246,15 @@ module Merb
1218
1246
  dm-rest-adapter
1219
1247
  ]
1220
1248
 
1249
+ DATA_OBJECTS = %w[
1250
+ data_objects
1251
+ do_derby do_hsqldb
1252
+ do_jdbc
1253
+ do_mysql
1254
+ do_postgres
1255
+ do_sqlite3
1256
+ ]
1257
+
1221
1258
  attr_accessor :system, :local, :missing
1222
1259
 
1223
1260
  include MerbThorHelper
@@ -1388,6 +1425,7 @@ module Merb
1388
1425
  comps["merb-more"] = MERB_MORE.sort
1389
1426
  comps["merb-plugins"] = MERB_PLUGINS.sort
1390
1427
  comps["dm-more"] = DM_MORE.sort
1428
+ comps["do"] = DATA_OBJECTS.sort
1391
1429
 
1392
1430
  comps
1393
1431
  end
@@ -1413,7 +1451,7 @@ module Merb
1413
1451
  end
1414
1452
 
1415
1453
  def self.framework_components
1416
- %w[merb-core merb-more merb-plugins].inject([]) do |all, comp|
1454
+ %w[merb-core merb-more].inject([]) do |all, comp|
1417
1455
  all + components(comp)
1418
1456
  end
1419
1457
  end
@@ -1435,7 +1473,7 @@ module Merb
1435
1473
  end
1436
1474
 
1437
1475
  def self.base_components
1438
- %w[thor rake]
1476
+ %w[thor rake extlib]
1439
1477
  end
1440
1478
 
1441
1479
  def self.all_components
@@ -1447,6 +1485,7 @@ module Merb
1447
1485
  def self.core_dependencies(gem_dir = nil, ignore_deps = false)
1448
1486
  @_core_dependencies ||= begin
1449
1487
  if gem_dir # add local gems to index
1488
+ orig_gem_path = ::Gem.path
1450
1489
  ::Gem.clear_paths; ::Gem.path.unshift(gem_dir)
1451
1490
  end
1452
1491
  deps = []
@@ -1461,7 +1500,7 @@ module Merb
1461
1500
  deps += gemspec.dependencies
1462
1501
  end
1463
1502
  end
1464
- ::Gem.clear_paths if gem_dir # reset
1503
+ ::Gem.path.replace(orig_gem_path) if gem_dir # reset
1465
1504
  deps
1466
1505
  end
1467
1506
  end
@@ -1818,6 +1857,8 @@ module Merb
1818
1857
  message "Installing #{current_gem} from source..."
1819
1858
  if install_dependency_from_source(dependency)
1820
1859
  ensure_bin_wrapper_for(dependency.name) if options[:binaries]
1860
+ else
1861
+ raise "gem source not found"
1821
1862
  end
1822
1863
  end
1823
1864
  end
@@ -6,7 +6,7 @@ Merb::Config.use { |c|
6
6
  # log less in testing environment
7
7
  c[:log_level] = :error
8
8
 
9
- c[:log_file] = Merb.root / "log" / "test.log"
9
+ #c[:log_file] = Merb.root / "log" / "test.log"
10
10
  # or redirect logger using IO handle
11
- # c[:log_stream] = STDOUT
11
+ c[:log_stream] = STDOUT
12
12
  }
@@ -1,4 +1,3 @@
1
-
2
1
  # use PathPrefix Middleware if :path_prefix is set in Merb::Config
3
2
  if prefix = ::Merb::Config[:path_prefix]
4
3
  use Merb::Rack::PathPrefix, prefix
@@ -6,7 +6,7 @@ Merb::Config.use { |c|
6
6
  # log less in testing environment
7
7
  c[:log_level] = :error
8
8
 
9
- c[:log_file] = Merb.root / "log" / "test.log"
9
+ #c[:log_file] = Merb.root / "log" / "test.log"
10
10
  # or redirect logger using IO handle
11
- # c[:log_stream] = STDOUT
11
+ c[:log_stream] = STDOUT
12
12
  }
@@ -1,4 +1,3 @@
1
-
2
1
  # use PathPrefix Middleware if :path_prefix is set in Merb::Config
3
2
  if prefix = ::Merb::Config[:path_prefix]
4
3
  use Merb::Rack::PathPrefix, prefix
@@ -52,9 +52,9 @@ describe "resource(:<%= plural_model %>)" do
52
52
 
53
53
  it "redirects to resource(:<%= plural_model %>)" do
54
54
  <%- if orm.to_sym == :datamapper -%>
55
- @response.should redirect_to(resource(<%= singular_model.capitalize %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
55
+ @response.should redirect_to(resource(<%= model_class_name %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
56
56
  <%- elsif orm.to_sym == :activerecord -%>
57
- @response.should redirect_to(resource(<%= singular_model.capitalize %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
57
+ @response.should redirect_to(resource(<%= model_class_name %>.first), :message => {:notice => "<%= singular_model %> was successfully created"})
58
58
  <% end -%>
59
59
  end
60
60
 
@@ -41,10 +41,6 @@ module Merb
41
41
  Merb::BootLoader::Logger.run
42
42
  Merb::BootLoader::BuildFramework.run
43
43
  Merb::BootLoader::Dependencies.run
44
-
45
- Merb::BootLoader::BeforeAppLoads.run
46
- Merb::BootLoader::ReloadClasses.run
47
- Merb::BootLoader::AfterAppLoads.run
48
44
 
49
45
  super
50
46
  options[:orm] ||= Merb.orm
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.10
4
+ version: 0.9.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Nicklas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-21 00:00:00 -07:00
12
+ date: 2008-10-29 00:00:00 -07: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.10
23
+ version: 0.9.11
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: templater