padrino-gen 0.14.1.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjI5ZjIxMmQwYzJhMGIyMmQ4N2I2NTBmZmY4OGQwYTQ3MzYxZDE5NQ==
5
- data.tar.gz: !binary |-
6
- ZGU1Yzg5NjI2NDBkNjQzNjJlODc0ODY4MjQ5ZDZjZmNlZTBlNmQ5Yw==
2
+ SHA1:
3
+ metadata.gz: 54060d405658309147c991cd2eff9a365cf2fa8f
4
+ data.tar.gz: 94d6b1400fcd1e232991adcc770d4ee06e55b3cf
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- YjEwMmQ3OWVhOTA1ODBiYWU2ZWUyNWFhMzZiNjkxNzQ3MjExZGE1MDY3ZWQ4
10
- ZTE0MTYzYjdlMzlkZTZjYmVmZjYyYTRlY2JlM2MxZGI1YTEyNTQ0Mjc3OTQy
11
- M2ZjOTJlNzZkNWJiNTJiNjc3MTRjNzNlMDJhOGYyMjk4OTNkOGM=
12
- data.tar.gz: !binary |-
13
- YWM1OGU1NmIzZTc1NzlhNjIxNTdjNmRiMDFhOTZkMzRlOWEzNTRhZDM5YzJk
14
- MzgyMjZmOGYyNDRlYTNjYmI4MzIyNTg1Y2ZmNDU4YzMwNWM1ODE5N2FmZGZh
15
- ZDFiNGQ0MDFhMmY0ZWI2YWY3NjNlYWQyMTQ1ODE5Zjg2NGRmNDk=
6
+ metadata.gz: f007cda5e22efca492e334c2877868e9306e1c3f50a5a70cd4f67f0862eb38bbe0479b7f7e408060424fa96079ccf91741e34f688a346798b70fa470dd4e6e59
7
+ data.tar.gz: 38a60006fc6610bcc01f71577a357f69e5971ffbc2ade927525913a432106c60b3752ce44c1839a17da16b2446a4dfbd7c4dd8bfe02db2645cb941a5129693aa
@@ -13,6 +13,6 @@ module Padrino
13
13
  #
14
14
  def self.bin_gen(*args)
15
15
  @_padrino_gen_bin ||= [Padrino.ruby_command, File.expand_path("../../../bin/padrino-gen", __FILE__)]
16
- system args.unshift(@_padrino_gen_bin).join(" ")
16
+ system *@_padrino_gen_bin, *args
17
17
  end
18
18
  end
@@ -145,11 +145,11 @@ module Padrino
145
145
  # resolve_valid_choice(:mock)
146
146
  #
147
147
  def resolve_valid_choice(component)
148
- available_string = self.class.available_choices_for(component).join(", ")
148
+ choices = self.class.available_choices_for(component).map(&:to_s)
149
149
  choice = options[component]
150
150
  until valid_choice?(component, choice)
151
151
  say("Option for --#{component} '#{choice}' is not available.", :red)
152
- choice = ask("Please enter a valid option for #{component} (#{available_string}):")
152
+ choice = ask("Please enter a valid option for #{component}:", :limited_to => choices)
153
153
  end
154
154
  choice
155
155
  end
@@ -181,9 +181,9 @@ module Padrino
181
181
  # @example
182
182
  # store_component_config('/foo/bar')
183
183
  #
184
- def store_component_config(destination)
184
+ def store_component_config(destination, opts = {})
185
185
  components = @_components || options
186
- create_file(destination) do
186
+ create_file(destination, opts) do
187
187
  self.class.component_types.inject({}) { |result, comp|
188
188
  result[comp] = components[comp].to_s; result
189
189
  }.to_yaml
@@ -435,29 +435,6 @@ WARNING
435
435
  in_root { run 'bundle install --binstubs' }
436
436
  end
437
437
 
438
- ##
439
- # Ask something to the user and receives a response.
440
- #
441
- # @param [String] statement
442
- # String of statement to display for input.
443
- # @param [String] default
444
- # Default value for input.
445
- # @param [String] color
446
- # Name of color to display input.
447
- #auto_locale
448
- # @return [String] Input value
449
- #
450
- # @example
451
- # ask("What is your name?")
452
- # ask("Path for ruby", "/usr/local/bin/ruby") => "Path for ruby (leave blank for /usr/local/bin/ruby):"
453
- #
454
- def ask(statement, default=nil, color=nil)
455
- default_text = default ? " (leave blank for #{default}):" : nil
456
- say("#{statement}#{default_text} ", color)
457
- result = $stdin.gets.strip
458
- result.empty? ? default : result
459
- end
460
-
461
438
  ##
462
439
  # Raise SystemExit if the app does not exist.
463
440
  #
@@ -111,29 +111,38 @@ MIDDLEWARE
111
111
  def setup_orm
112
112
  ar = AR
113
113
  db = @project_name.underscore
114
- # We're now defaulting to mysql2 since mysql is deprecated
115
- case options[:adapter]
116
- when 'mysql-gem'
117
- ar.sub! /!DB_DEVELOPMENT!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_development'")
118
- ar.sub! /!DB_PRODUCTION!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_production'")
119
- ar.sub! /!DB_TEST!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_test'")
120
- require_dependencies 'mysql', :version => "~> 2.8.1"
121
- when 'mysql', 'mysql2'
122
- ar.sub! /!DB_DEVELOPMENT!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_development'")
123
- ar.sub! /!DB_PRODUCTION!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_production'")
124
- ar.sub! /!DB_TEST!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_test'")
125
- require_dependencies 'mysql2'
126
- when 'postgres'
127
- ar.sub! /!DB_DEVELOPMENT!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_development'")
128
- ar.sub! /!DB_PRODUCTION!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_production'")
129
- ar.sub! /!DB_TEST!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_test'")
130
- require_dependencies 'pg'
131
- else
132
- ar.sub! /!DB_DEVELOPMENT!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_development.db')")
133
- ar.sub! /!DB_PRODUCTION!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_production.db')")
134
- ar.sub! /!DB_TEST!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_test.db')")
135
- require_dependencies 'sqlite3'
114
+
115
+ begin
116
+ case adapter ||= options[:adapter]
117
+ when 'mysql-gem'
118
+ ar.sub! /!DB_DEVELOPMENT!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_development'")
119
+ ar.sub! /!DB_PRODUCTION!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_production'")
120
+ ar.sub! /!DB_TEST!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_test'")
121
+ require_dependencies 'mysql', :version => "~> 2.8.1"
122
+ when 'mysql', 'mysql2'
123
+ ar.sub! /!DB_DEVELOPMENT!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_development'")
124
+ ar.sub! /!DB_PRODUCTION!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_production'")
125
+ ar.sub! /!DB_TEST!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_test'")
126
+ require_dependencies 'mysql2'
127
+ when 'postgres'
128
+ ar.sub! /!DB_DEVELOPMENT!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_development'")
129
+ ar.sub! /!DB_PRODUCTION!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_production'")
130
+ ar.sub! /!DB_TEST!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_test'")
131
+ require_dependencies 'pg'
132
+ when 'sqlite'
133
+ ar.sub! /!DB_DEVELOPMENT!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_development.db')")
134
+ ar.sub! /!DB_PRODUCTION!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_production.db')")
135
+ ar.sub! /!DB_TEST!/, SQLITE.sub(/!DB_NAME!/,"Padrino.root('db', '#{db}_test.db')")
136
+ require_dependencies 'sqlite3'
137
+ else
138
+ say "Failed to generate `config/database.rb` for ORM adapter `#{options[:adapter]}`", :red
139
+ fail ArgumentError
140
+ end
141
+ rescue ArgumentError
142
+ adapter = ask("Please, choose a proper adapter:", :limited_to => %w[mysql mysql2 mysql-gem postgres sqlite])
143
+ retry
136
144
  end
145
+
137
146
  require_dependencies 'activerecord', :require => 'active_record', :version => ">= 3.1"
138
147
  create_file("config/database.rb", ar)
139
148
  middleware :connection_pool_management, CONNECTION_POOL_MIDDLEWARE
@@ -152,7 +161,19 @@ def create_model_file(name, options={})
152
161
  create_file(model_path, model_contents,:skip => true)
153
162
  end
154
163
 
164
+ if defined?(ActiveRecord::Migration) && ActiveRecord::Migration.respond_to?(:[])
165
+ AR_MIGRATION = (<<-MIGRATION) unless defined?(AR_MIGRATION)
166
+ class !FILECLASS! < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]
167
+ def self.up
168
+ !UP!
169
+ end
155
170
 
171
+ def self.down
172
+ !DOWN!
173
+ end
174
+ end
175
+ MIGRATION
176
+ else
156
177
  AR_MIGRATION = (<<-MIGRATION) unless defined?(AR_MIGRATION)
157
178
  class !FILECLASS! < ActiveRecord::Migration
158
179
  def self.up
@@ -164,6 +185,7 @@ class !FILECLASS! < ActiveRecord::Migration
164
185
  end
165
186
  end
166
187
  MIGRATION
188
+ end
167
189
 
168
190
  AR_MODEL_UP_MG = (<<-MIGRATION).gsub(/^/,' ') unless defined?(AR_MODEL_UP_MG)
169
191
  create_table :!TABLE! do |t|
@@ -68,22 +68,31 @@ def setup_orm
68
68
  dm-timestamps
69
69
  dm-validations
70
70
  ).each { |dep| require_dependencies dep }
71
- require_dependencies case options[:adapter]
71
+
72
+ begin
73
+ case adapter ||= options[:adapter]
72
74
  when 'mysql', 'mysql2'
73
75
  dm.gsub!(/!DB_DEVELOPMENT!/,"\"mysql://root@localhost/#{db}_development\"")
74
76
  dm.gsub!(/!DB_PRODUCTION!/,"\"mysql://root@localhost/#{db}_production\"")
75
77
  dm.gsub!(/!DB_TEST!/,"\"mysql://root@localhost/#{db}_test\"")
76
- 'dm-mysql-adapter'
78
+ require_dependencies 'dm-mysql-adapter'
77
79
  when 'postgres'
78
80
  dm.gsub!(/!DB_DEVELOPMENT!/,"\"postgres://root@localhost/#{db}_development\"")
79
81
  dm.gsub!(/!DB_PRODUCTION!/,"\"postgres://root@localhost/#{db}_production\"")
80
82
  dm.gsub!(/!DB_TEST!/,"\"postgres://root@localhost/#{db}_test\"")
81
- 'dm-postgres-adapter'
82
- else
83
+ require_dependencies 'dm-postgres-adapter'
84
+ when 'sqlite'
83
85
  dm.gsub!(/!DB_DEVELOPMENT!/,"\"sqlite3://\" + Padrino.root('db', \"#{db}_development.db\")")
84
86
  dm.gsub!(/!DB_PRODUCTION!/,"\"sqlite3://\" + Padrino.root('db', \"#{db}_production.db\")")
85
87
  dm.gsub!(/!DB_TEST!/,"\"sqlite3://\" + Padrino.root('db', \"#{db}_test.db\")")
86
- 'dm-sqlite-adapter'
88
+ require_dependencies 'dm-sqlite-adapter'
89
+ else
90
+ say "Failed to generate `config/database.rb` for ORM adapter `#{options[:adapter]}`", :red
91
+ fail ArgumentError
92
+ end
93
+ rescue ArgumentError
94
+ adapter = ask("Please, choose a proper adapter:", :limited_to => %w[mysql mysql2 postgres sqlite])
95
+ retry
87
96
  end
88
97
 
89
98
  create_file("config/database.rb", dm)
@@ -111,28 +111,38 @@ MIDDLEWARE
111
111
  def setup_orm
112
112
  ar = MR
113
113
  db = @project_name.underscore
114
- case options[:adapter]
115
- when 'mysql-gem'
116
- ar.gsub! /!DB_DEVELOPMENT!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_development'")
117
- ar.gsub! /!DB_PRODUCTION!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_production'")
118
- ar.gsub! /!DB_TEST!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_test'")
119
- require_dependencies 'mysql', :version => "~> 2.8.1"
120
- when 'mysql', 'mysql2'
121
- ar.gsub! /!DB_DEVELOPMENT!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_development'")
122
- ar.gsub! /!DB_PRODUCTION!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_production'")
123
- ar.gsub! /!DB_TEST!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_test'")
124
- require_dependencies 'mysql2'
125
- when 'postgres'
126
- ar.gsub! /!DB_DEVELOPMENT!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_development'")
127
- ar.gsub! /!DB_PRODUCTION!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_production'")
128
- ar.gsub! /!DB_TEST!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_test'")
129
- require_dependencies 'pg'
130
- else
131
- ar.gsub! /!DB_DEVELOPMENT!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_development.db')")
132
- ar.gsub! /!DB_PRODUCTION!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_production.db')")
133
- ar.gsub! /!DB_TEST!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_test.db')")
134
- require_dependencies 'sqlite3'
114
+
115
+ begin
116
+ case adapter ||= options[:adapter]
117
+ when 'mysql-gem'
118
+ ar.gsub! /!DB_DEVELOPMENT!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_development'")
119
+ ar.gsub! /!DB_PRODUCTION!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_production'")
120
+ ar.gsub! /!DB_TEST!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_test'")
121
+ require_dependencies 'mysql', :version => "~> 2.8.1"
122
+ when 'mysql', 'mysql2'
123
+ ar.gsub! /!DB_DEVELOPMENT!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_development'")
124
+ ar.gsub! /!DB_PRODUCTION!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_production'")
125
+ ar.gsub! /!DB_TEST!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_test'")
126
+ require_dependencies 'mysql2'
127
+ when 'postgres'
128
+ ar.gsub! /!DB_DEVELOPMENT!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_development'")
129
+ ar.gsub! /!DB_PRODUCTION!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_production'")
130
+ ar.gsub! /!DB_TEST!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_test'")
131
+ require_dependencies 'pg'
132
+ when 'sqlite'
133
+ ar.gsub! /!DB_DEVELOPMENT!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_development.db')")
134
+ ar.gsub! /!DB_PRODUCTION!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_production.db')")
135
+ ar.gsub! /!DB_TEST!/, SQLITE.gsub(/!DB_NAME!/,"Padrino.root('db', '#{db}_test.db')")
136
+ require_dependencies 'sqlite3'
137
+ else
138
+ say "Failed to generate `config/database.rb` for ORM adapter `#{options[:adapter]}`", :red
139
+ fail ArgumentError
140
+ end
141
+ rescue ArgumentError
142
+ adapter = ask("Please, choose a proper adapter:", :limited_to => %w[mysql mysql2 mysql-gem postgres sqlite])
143
+ retry
135
144
  end
145
+
136
146
  require_dependencies 'mini_record'
137
147
  create_file('config/database.rb', ar)
138
148
  insert_hook('ActiveRecord::Base.auto_upgrade!', :after_load)
@@ -1,5 +1,4 @@
1
1
  SEQUEL = (<<-SEQUEL) unless defined?(SEQUEL)
2
- Sequel::Model.plugin(:schema)
3
2
  Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
4
3
  Sequel::Model.db = case Padrino.env
5
4
  when :development then Sequel.connect(!DB_DEVELOPMENT!, :loggers => [logger])
@@ -12,32 +11,38 @@ def setup_orm
12
11
  sequel = SEQUEL
13
12
  db = @project_name.underscore
14
13
  require_dependencies 'sequel'
15
- case options[:adapter]
16
- when 'mysql-gem'
17
- sequel.gsub!(/!DB_DEVELOPMENT!/, "\"mysql://localhost/#{db}_development\"")
18
- sequel.gsub!(/!DB_PRODUCTION!/, "\"mysql://localhost/#{db}_production\"")
19
- sequel.gsub!(/!DB_TEST!/,"\"mysql://localhost/#{db}_test\"")
20
- require_dependencies 'mysql', :version => "~> 2.8.1"
21
- 'mysql'
22
- when 'mysql', 'mysql2'
23
- sequel.gsub!(/!DB_DEVELOPMENT!/, "\"mysql2://localhost/#{db}_development\"")
24
- sequel.gsub!(/!DB_PRODUCTION!/, "\"mysql2://localhost/#{db}_production\"")
25
- sequel.gsub!(/!DB_TEST!/,"\"mysql2://localhost/#{db}_test\"")
26
- require_dependencies 'mysql2'
27
- 'mysql2'
28
- when 'postgres'
29
- sequel.gsub!(/!DB_DEVELOPMENT!/, "\"postgres://localhost/#{db}_development\"")
30
- sequel.gsub!(/!DB_PRODUCTION!/, "\"postgres://localhost/#{db}_production\"")
31
- sequel.gsub!(/!DB_TEST!/,"\"postgres://localhost/#{db}_test\"")
32
- require_dependencies 'pg'
33
- 'pg'
34
- else
35
- sequel.gsub!(/!DB_DEVELOPMENT!/,"\"sqlite://db/#{db}_development.db\"")
36
- sequel.gsub!(/!DB_PRODUCTION!/, "\"sqlite://db/#{db}_production.db\"")
37
- sequel.gsub!(/!DB_TEST!/, "\"sqlite://db/#{db}_test.db\"")
38
- require_dependencies 'sqlite3'
39
- 'sqlite3'
14
+
15
+ begin
16
+ case adapter ||= options[:adapter]
17
+ when 'mysql-gem'
18
+ sequel.gsub!(/!DB_DEVELOPMENT!/, "\"mysql://localhost/#{db}_development\"")
19
+ sequel.gsub!(/!DB_PRODUCTION!/, "\"mysql://localhost/#{db}_production\"")
20
+ sequel.gsub!(/!DB_TEST!/,"\"mysql://localhost/#{db}_test\"")
21
+ require_dependencies 'mysql', :version => "~> 2.8.1"
22
+ when 'mysql', 'mysql2'
23
+ sequel.gsub!(/!DB_DEVELOPMENT!/, "\"mysql2://localhost/#{db}_development\"")
24
+ sequel.gsub!(/!DB_PRODUCTION!/, "\"mysql2://localhost/#{db}_production\"")
25
+ sequel.gsub!(/!DB_TEST!/,"\"mysql2://localhost/#{db}_test\"")
26
+ require_dependencies 'mysql2'
27
+ when 'postgres'
28
+ sequel.gsub!(/!DB_DEVELOPMENT!/, "\"postgres://localhost/#{db}_development\"")
29
+ sequel.gsub!(/!DB_PRODUCTION!/, "\"postgres://localhost/#{db}_production\"")
30
+ sequel.gsub!(/!DB_TEST!/,"\"postgres://localhost/#{db}_test\"")
31
+ require_dependencies 'pg'
32
+ when 'sqlite'
33
+ sequel.gsub!(/!DB_DEVELOPMENT!/,"\"sqlite://db/#{db}_development.db\"")
34
+ sequel.gsub!(/!DB_PRODUCTION!/, "\"sqlite://db/#{db}_production.db\"")
35
+ sequel.gsub!(/!DB_TEST!/, "\"sqlite://db/#{db}_test.db\"")
36
+ require_dependencies 'sqlite3'
37
+ else
38
+ say "Failed to generate `config/database.rb` for ORM adapter `#{options[:adapter]}`", :red
39
+ fail ArgumentError
40
+ end
41
+ rescue ArgumentError
42
+ adapter = ask("Please, choose a proper adapter:", :limited_to => %w[mysql mysql2 mysql-gem postgres sqlite])
43
+ retry
40
44
  end
45
+
41
46
  create_file("config/database.rb", sequel)
42
47
  empty_directory('db/migrate')
43
48
  end
@@ -91,7 +91,7 @@ module Padrino
91
91
  choice = @_components[comp] = resolve_valid_choice(comp)
92
92
  execute_component_setup(comp, choice)
93
93
  end
94
- store_component_config('.components')
94
+ store_component_config('.components', :force => true)
95
95
  store_component_choice(:namespace, @project_name)
96
96
  store_component_choice(:migration_format, options[:migration_format])
97
97
  end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'open-uri'
2
3
 
3
4
  module Padrino
4
5
  module Generators
@@ -125,14 +126,18 @@ module Padrino
125
126
  when template_file =~ %r{^https?://} && template_file !~ /gist/
126
127
  template_file
127
128
  when template_file =~ /gist/ && template_file !~ /raw/
128
- raw_link, _ = *open(template_file).read.scan(/<a\s+href\s?\=\"(.*?)\"\>raw/)
129
+ raw_link, _ = *open(template_file) { |io| io.read.scan(/<a\s+href\s?\=\"(.*?)\"\>raw/) }
129
130
  raw_link ? "https://gist.github.com#{raw_link[0]}" : template_file
130
131
  when File.extname(template_file).empty? # referencing official plugin (i.e hoptoad)
131
132
  "https://raw.github.com/padrino/padrino-recipes/master/#{kind.to_s.pluralize}/#{template_file}_#{kind}.rb"
132
133
  else # local file on system
133
134
  File.expand_path(template_file)
134
135
  end
135
- self.apply(template_path) rescue say("The template at #{template_path} could not be found!", :red)
136
+ begin
137
+ self.apply(template_path)
138
+ rescue => error
139
+ say("The template at #{template_path} could not be loaded: #{error.message}", :red)
140
+ end
136
141
  end
137
142
  end
138
143
  end
@@ -6,5 +6,3 @@ PadrinoTasks.use(:database)
6
6
  PadrinoTasks.use(<%= options[:orm].to_sym.inspect %>)
7
7
  <%- end -%>
8
8
  PadrinoTasks.init
9
-
10
- task :default => :test
@@ -50,7 +50,7 @@ if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
50
50
 
51
51
  desc "Create the database"
52
52
  task :create => :environment do
53
- config = Utils.symbolize_keys(DataMapper.repository.adapter.options)
53
+ config = Padrino::Utils.symbolize_keys(DataMapper.repository.adapter.options)
54
54
  adapter = config[:adapter]
55
55
  user, password, host = config[:user], config[:password], config[:host]
56
56
 
@@ -67,7 +67,7 @@ if PadrinoTasks.load?(:datamapper, defined?(DataMapper))
67
67
 
68
68
  desc "Drop the database (postgres and mysql only)"
69
69
  task :drop => :environment do
70
- config = Utils.symbolize_keys(DataMapper.repository.adapter.options)
70
+ config = Padrino::Utils.symbolize_keys(DataMapper.repository.adapter.options)
71
71
  adapter = config[:adapter]
72
72
  user, password, host = config[:user], config[:password], config[:host]
73
73
 
@@ -101,7 +101,8 @@ describe "PluginGenerator" do
101
101
  FakeWeb.register_uri :get, resolved_path, :status => 404
102
102
  plugin_gen = Padrino::Generators::Plugin.new([ template_file], ["-r=#{@apptmp}/sample_project"],{})
103
103
  plugin_gen.expects(:in_app_root?).returns(true).once
104
- plugin_gen.expects(:say).with("The template at #{resolved_path} could not be found!", :red).returns(true).once
104
+ # Use regex to ignore trailing whitespace in message
105
+ plugin_gen.expects(:say).with{ |message, color| (message =~ /The template at #{resolved_path} could not be loaded:.*404.*/) && (color == :red) }.returns(true).once
105
106
  capture_io { plugin_gen.invoke_all }
106
107
  end
107
108
  end
@@ -328,7 +328,7 @@ describe "ProjectGenerator" do
328
328
  end
329
329
 
330
330
  it 'should properly generate sqlite3' do
331
- out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite3') }
331
+ out, err = capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}", '--orm=activerecord', '--adapter=sqlite') }
332
332
  assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
333
333
  assert_match_in_file(/sample_project_development.db/, "#{@apptmp}/sample_project/config/database.rb")
334
334
  assert_match_in_file(%r{:adapter => 'sqlite3'}, "#{@apptmp}/sample_project/config/database.rb")
@@ -54,5 +54,12 @@ describe "TaskGenerator" do
54
54
  assert_match_in_file(/desc "This is a sample"/, file_path)
55
55
  assert_match_in_file(/task :demo_task => :environment do/, file_path)
56
56
  end
57
+
58
+ it 'should preserve spaces' do
59
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
60
+ Padrino.bin_gen('task', 'DemoTask', "--namespace=Sample", "--description=This is a sample", "-r=#{@apptmp}/sample_project", :out => File::NULL)
61
+ file_path = "#{@apptmp}/sample_project/tasks/sample_demo_task.rake"
62
+ assert_match_in_file(/desc "This is a sample"/, file_path)
63
+ end
57
64
  end
58
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-05-16 00:00:00.000000000 Z
14
+ date: 2018-01-02 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-core
@@ -19,58 +19,56 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.14.1.1
22
+ version: 0.14.2
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.14.1.1
29
+ version: 0.14.2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ~>
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: !binary |-
37
- MS4w
36
+ version: '1.0'
38
37
  type: :runtime
39
38
  prerelease: false
40
39
  version_requirements: !ruby/object:Gem::Requirement
41
40
  requirements:
42
- - - ~>
41
+ - - "~>"
43
42
  - !ruby/object:Gem::Version
44
- version: !binary |-
45
- MS4w
43
+ version: '1.0'
46
44
  - !ruby/object:Gem::Dependency
47
45
  name: padrino-helpers
48
46
  requirement: !ruby/object:Gem::Requirement
49
47
  requirements:
50
48
  - - '='
51
49
  - !ruby/object:Gem::Version
52
- version: 0.14.1.1
50
+ version: 0.14.2
53
51
  type: :development
54
52
  prerelease: false
55
53
  version_requirements: !ruby/object:Gem::Requirement
56
54
  requirements:
57
55
  - - '='
58
56
  - !ruby/object:Gem::Version
59
- version: 0.14.1.1
57
+ version: 0.14.2
60
58
  - !ruby/object:Gem::Dependency
61
59
  name: padrino-mailer
62
60
  requirement: !ruby/object:Gem::Requirement
63
61
  requirements:
64
62
  - - '='
65
63
  - !ruby/object:Gem::Version
66
- version: 0.14.1.1
64
+ version: 0.14.2
67
65
  type: :development
68
66
  prerelease: false
69
67
  version_requirements: !ruby/object:Gem::Requirement
70
68
  requirements:
71
69
  - - '='
72
70
  - !ruby/object:Gem::Version
73
- version: 0.14.1.1
71
+ version: 0.14.2
74
72
  description: Generators for easily creating and building padrino applications from
75
73
  the console
76
74
  email: padrinorb@gmail.com
@@ -80,9 +78,9 @@ extensions: []
80
78
  extra_rdoc_files:
81
79
  - README.rdoc
82
80
  files:
83
- - .document
84
- - .gitignore
85
- - .yardopts
81
+ - ".document"
82
+ - ".gitignore"
83
+ - ".yardopts"
86
84
  - LICENSE.txt
87
85
  - README.rdoc
88
86
  - Rakefile
@@ -204,22 +202,22 @@ licenses:
204
202
  metadata: {}
205
203
  post_install_message:
206
204
  rdoc_options:
207
- - --charset=UTF-8
205
+ - "--charset=UTF-8"
208
206
  require_paths:
209
207
  - lib
210
208
  required_ruby_version: !ruby/object:Gem::Requirement
211
209
  requirements:
212
- - - ! '>='
210
+ - - ">="
213
211
  - !ruby/object:Gem::Version
214
212
  version: '0'
215
213
  required_rubygems_version: !ruby/object:Gem::Requirement
216
214
  requirements:
217
- - - ! '>='
215
+ - - ">="
218
216
  - !ruby/object:Gem::Version
219
217
  version: 1.3.6
220
218
  requirements: []
221
219
  rubyforge_project: padrino-gen
222
- rubygems_version: 2.4.3
220
+ rubygems_version: 2.6.12
223
221
  signing_key:
224
222
  specification_version: 4
225
223
  summary: Generators for easily creating and building padrino applications