padrino-gen 0.12.0.rc3 → 0.12.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91185270927b70c242badab1189db4a7edaa21ec
4
- data.tar.gz: ac81f2f68dfd273adede1d263e9055f21061c36d
3
+ metadata.gz: 529163bdc909b9c5aad2faa4ba1dcf647290eef3
4
+ data.tar.gz: 3fd83aca799e92e14220d0447f8a0145e279aade
5
5
  SHA512:
6
- metadata.gz: 1fa158ce2281c6a1a895902a6b1a092fd3f9761479e272b85191c60018746dd6b89c9c3f74511b430e19cf6fadcd7e28c3ea1d07292edfd4c7a6748557d239e5
7
- data.tar.gz: 9a10dfb30ae2a48c72d2d0f082630179e15f1127a8a19bf5b0c216ea5a39f1cc13e92fb82a76f949ff6bd5dbc467a3e3ad733a0e17719d8148b896a94f8c8e08
6
+ metadata.gz: 49e3c1b34292d216122cd51ce66d23359b38df3409966063f5db03ace99ea3dea3a077edc1503c6cffdb2055046625b1b47aa53acadf5913aa581ecd6891ef0a
7
+ data.tar.gz: 3aa0eea49ffdb6dc2b020d1a551423d68e86c71c2b942d799327ce0df3f9abb49d7eec7ecbc1843d66cc2cd696c600ffbdace4d45ec47680e10172abb2e80c52
@@ -17,7 +17,8 @@ module Padrino
17
17
 
18
18
  desc "Description:\n\n\tpadrino-gen component add components into a Padrino project"
19
19
 
20
- class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
20
+ class_option :app, :desc => 'The application name', :aliases => '-n', :default => nil, :type => :string
21
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
21
22
  class_option :adapter, :desc => 'SQL adapter for ORM (sqlite, mysql, mysql2, mysql-gem, postgres)', :aliases => '-a', :default => 'sqlite', :type => :string
22
23
 
23
24
  defines_component_options :default => false
@@ -29,6 +30,7 @@ module Padrino
29
30
  self.destination_root = options[:root]
30
31
  if in_app_root?
31
32
  @_components = options.dup.slice(*self.class.component_types)
33
+ @app_name = (options[:app] || "App").gsub(/\W/, '_').underscore.camelize
32
34
  if @_components.values.delete_if(&:blank?).empty?
33
35
  self.class.start(["-h"])
34
36
  say
@@ -50,6 +52,11 @@ module Padrino
50
52
  next unless yes?("Switch #{comp} to '#{choice}' from '#{existing}' ?[yes/no]:")
51
53
  end
52
54
  @project_name = fetch_component_choice(:namespace)
55
+ if comp.to_s == 'test' && !already_exists?(@app_name, @project_name)
56
+ say "#{@project_name}::#{@app_name} does not exist."
57
+ say "Please, change app name."
58
+ next
59
+ end
53
60
  execute_component_setup(comp, choice)
54
61
  store_component_choice(comp, choice)
55
62
  if comp.to_s == 'orm' && choice.to_s != 'none'
@@ -38,7 +38,7 @@ if ActiveRecord::VERSION::MAJOR.to_i < 4
38
38
  ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
39
39
  end
40
40
 
41
- # Include Active Record class name as root for JSON serialized output.
41
+ # Doesn't include Active Record class name as root for JSON serialized output.
42
42
  ActiveRecord::Base.include_root_in_json = false
43
43
 
44
44
  # Store the full class name (including module namespace) in STI type column.
@@ -1,4 +1,19 @@
1
1
  MR = (<<-MR) unless defined?(MR)
2
+ ##
3
+ # You can use other adapters like:
4
+ #
5
+ # ActiveRecord::Base.configurations[:development] = {
6
+ # :adapter => 'mysql2',
7
+ # :encoding => 'utf8',
8
+ # :reconnect => true,
9
+ # :database => 'your_database',
10
+ # :pool => 5,
11
+ # :username => 'root',
12
+ # :password => '',
13
+ # :host => 'localhost',
14
+ # :socket => '/tmp/mysql.sock'
15
+ # }
16
+ #
2
17
  ActiveRecord::Base.configurations[:development] = {
3
18
  !DB_DEVELOPMENT!
4
19
  }
@@ -32,7 +47,7 @@ ActiveRecord::Base.store_full_sti_class = true
32
47
  # Use ISO 8601 format for JSON serialized times and dates.
33
48
  ActiveSupport.use_standard_json_time_format = true
34
49
 
35
- # Don't escape HTML entities in JSON, leave that for the json_escape helper
50
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper
36
51
  # if you're including raw JSON in an HTML page.
37
52
  ActiveSupport.escape_html_entities_in_json = false
38
53
 
@@ -77,6 +92,8 @@ SQLITE = (<<-SQLITE) unless defined?(SQLITE)
77
92
  :adapter => 'sqlite3',
78
93
  :database => !DB_NAME!
79
94
  SQLITE
95
+
96
+
80
97
  def setup_orm
81
98
  ar = MR
82
99
  db = @project_name.underscore
data/test/helper.rb CHANGED
@@ -43,7 +43,10 @@ class MiniTest::Spec
43
43
  options, model_path = {}, File.expand_path(File.join(root, "/models/**/*.rb"))
44
44
  options = params.pop if params.last.is_a?(Hash)
45
45
  Dir[model_path].each{|path| require path }
46
- Array(options[:apps]).each{|app_name| require File.expand_path(File.join(root, "/#{app_name}/app.rb")) } if options[:apps]
46
+ Array(options[:apps]).each do |app_name|
47
+ path = File.expand_path(File.join(root, "/#{app_name}/app.rb"))
48
+ require path if File.exist?(path)
49
+ end if options[:apps]
47
50
  end
48
51
  "Padrino::Generators::#{name.to_s.camelize}".constantize.start(params)
49
52
  ($" - features).each{|x| $".delete(x) }
@@ -38,8 +38,27 @@ describe "ComponentGenerator" do
38
38
  components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
39
39
  assert_equal 'sequel', components_chosen[:orm]
40
40
  end
41
- end
42
41
 
42
+ should "enable @app_name value" do
43
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
44
+ out, err = capture_io { generate_with_parts(:component, '--test=cucumber', "-r=#{@apptmp}/sample_project", :apps => "app") }
45
+ assert_match_in_file(/SampleProject::App\.tap \{ \|app\| \}/, "#{@apptmp}/sample_project/features/support/env.rb")
46
+ end
47
+
48
+ should "generate component in specified app" do
49
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
50
+ capture_io { generate(:app, 'compo', "-r=#{@apptmp}/sample_project") }
51
+ out, err = capture_io { generate_with_parts(:component, '--test=cucumber', "--app=compo", "-r=#{@apptmp}/sample_project", :apps => "compo") }
52
+ assert_match_in_file(/SampleProject::Compo\.tap \{ \|app\| \}/, "#{@apptmp}/sample_project/features/support/env.rb")
53
+ end
54
+
55
+ should "not generate component in specified app if the app does not exist" do
56
+ capture_io { generate(:project, 'sample_project', "--root=#{@apptmp}") }
57
+ out, err = capture_io { generate_with_parts(:component, '--test=cucumber', "--app=compo", "-r=#{@apptmp}/sample_project", :apps => "compo") }
58
+ assert_match(/SampleProject::Compo does not exist./, out)
59
+ assert_no_file_exists("#{@apptmp}/sample_project/features")
60
+ end
61
+ end
43
62
 
44
63
  context "specified of same the component" do
45
64
  should "does not change" do
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.12.0.rc3
4
+ version: 0.12.0
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: 2014-01-20 00:00:00.000000000 Z
14
+ date: 2014-02-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-core
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.12.0.rc3
22
+ version: 0.12.0
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.12.0.rc3
29
+ version: 0.12.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -47,28 +47,28 @@ dependencies:
47
47
  requirements:
48
48
  - - '='
49
49
  - !ruby/object:Gem::Version
50
- version: 0.12.0.rc3
50
+ version: 0.12.0
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - '='
56
56
  - !ruby/object:Gem::Version
57
- version: 0.12.0.rc3
57
+ version: 0.12.0
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: padrino-mailer
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - '='
63
63
  - !ruby/object:Gem::Version
64
- version: 0.12.0.rc3
64
+ version: 0.12.0
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - '='
70
70
  - !ruby/object:Gem::Version
71
- version: 0.12.0.rc3
71
+ version: 0.12.0
72
72
  description: Generators for easily creating and building padrino applications from
73
73
  the console
74
74
  email: padrinorb@gmail.com
@@ -208,9 +208,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  requirements:
211
- - - '>'
211
+ - - '>='
212
212
  - !ruby/object:Gem::Version
213
- version: 1.3.1
213
+ version: 1.3.6
214
214
  requirements: []
215
215
  rubyforge_project: padrino-gen
216
216
  rubygems_version: 2.0.6