padrino-gen 0.15.0 → 0.15.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52d53bb4bdb519cda6e7b532caae6464e273d671bb2e026535b54b86e7f01ebe
4
- data.tar.gz: 668f36bc2fcb2def4d49a24f1d061f977e7c508d09b7c5cb838fbead55d68d23
3
+ metadata.gz: 4715ef3a71b10c1c828571ecc035af5e589b4f657376fc6c7ee17a5dbd21bcf5
4
+ data.tar.gz: 6a38e83c98b6db24b9415194fac781daeb477ffac5cafd8bf5bd5283a22898bb
5
5
  SHA512:
6
- metadata.gz: fccd728a0d2061d38541cac0983ba7d384428a8a5376501c6033d68b48306d2b21bcc6a533bfb468a871c0878aa5f51c53d0100d978746edfaa5addfd8ee7e5b
7
- data.tar.gz: ba118e0fbf0cbdd5f148edfd2712966ff2039d543ea64afcdee89dfc4f74cd5a383a823ec1635f4d98165f3fe605a89175114c9095d262378e4183de0e6fd8f2
6
+ metadata.gz: ed706f3cd3d2e29c84155019bffb0967ddb35641cb2e2afb84e05bed4dbbd603fc672342f54714d76723de706de1ab4b991f7f39d2384799625e2fba6dd8e5e1
7
+ data.tar.gz: 41cb109b4e0afeb29150e406416de84bd28a1c403d808ebb4729fb5c4e19f8d15612a549a2fcf87ffaeb5d64006eafaffe504bea39265f7badd44dd6fe543218
@@ -2,28 +2,30 @@ AR = (<<-AR) unless defined?(AR)
2
2
  ##
3
3
  # You can use other adapters like:
4
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'
5
+ # ActiveRecord::Base.configurations = {
6
+ # :development => {
7
+ # :adapter => 'mysql2',
8
+ # :encoding => 'utf8',
9
+ # :reconnect => true,
10
+ # :database => 'your_database',
11
+ # :pool => 5,
12
+ # :username => 'root',
13
+ # :password => '',
14
+ # :host => 'localhost',
15
+ # :socket => '/tmp/mysql.sock'
16
+ # }
15
17
  # }
16
18
  #
17
- ActiveRecord::Base.configurations[:development] = {
19
+ ActiveRecord::Base.configurations = {
20
+ :development => {
18
21
  !DB_DEVELOPMENT!
19
- }
20
-
21
- ActiveRecord::Base.configurations[:production] = {
22
+ },
23
+ :production => {
22
24
  !DB_PRODUCTION!
23
- }
24
-
25
- ActiveRecord::Base.configurations[:test] = {
25
+ },
26
+ :test => {
26
27
  !DB_TEST!
28
+ }
27
29
  }
28
30
 
29
31
  # Setup our logger
@@ -52,48 +54,49 @@ ActiveSupport.use_standard_json_time_format = true
52
54
  ActiveSupport.escape_html_entities_in_json = false
53
55
 
54
56
  # Now we can establish connection with our db.
55
- ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env])
56
-
57
- # Timestamps are in the utc by default.
58
- ActiveRecord::Base.default_timezone = :utc
57
+ if ActiveRecord::VERSION::MAJOR.to_i < 6
58
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env])
59
+ else
60
+ ActiveRecord::Base.establish_connection(Padrino.env)
61
+ end
59
62
  AR
60
63
 
61
64
  MYSQL = (<<-MYSQL) unless defined?(MYSQL)
62
- :adapter => 'mysql',
63
- :encoding => 'utf8',
64
- :reconnect => true,
65
- :database => !DB_NAME!,
66
- :pool => 5,
67
- :username => 'root',
68
- :password => '',
69
- :host => 'localhost',
70
- :socket => '/tmp/mysql.sock'
65
+ :adapter => 'mysql',
66
+ :encoding => 'utf8',
67
+ :reconnect => true,
68
+ :database => !DB_NAME!,
69
+ :pool => 5,
70
+ :username => 'root',
71
+ :password => '',
72
+ :host => 'localhost',
73
+ :socket => '/tmp/mysql.sock'
71
74
  MYSQL
72
75
 
73
76
  MYSQL2 = (<<-MYSQL2) unless defined?(MYSQL2)
74
- :adapter => 'mysql2',
75
- :encoding => 'utf8',
76
- :reconnect => true,
77
- :database => !DB_NAME!,
78
- :pool => 5,
79
- :username => 'root',
80
- :password => '',
81
- :host => 'localhost',
82
- :socket => '/tmp/mysql.sock'
77
+ :adapter => 'mysql2',
78
+ :encoding => 'utf8',
79
+ :reconnect => true,
80
+ :database => !DB_NAME!,
81
+ :pool => 5,
82
+ :username => 'root',
83
+ :password => '',
84
+ :host => 'localhost',
85
+ :socket => '/tmp/mysql.sock'
83
86
  MYSQL2
84
87
 
85
88
  POSTGRES = (<<-POSTGRES) unless defined?(POSTGRES)
86
- :adapter => 'postgresql',
87
- :database => !DB_NAME!,
88
- :username => 'root',
89
- :password => '',
90
- :host => 'localhost',
91
- :port => 5432
89
+ :adapter => 'postgresql',
90
+ :database => !DB_NAME!,
91
+ :username => 'root',
92
+ :password => '',
93
+ :host => 'localhost',
94
+ :port => 5432
92
95
  POSTGRES
93
96
 
94
97
  SQLITE = (<<-SQLITE) unless defined?(SQLITE)
95
- :adapter => 'sqlite3',
96
- :database => !DB_NAME!
98
+ :adapter => 'sqlite3',
99
+ :database => !DB_NAME!
97
100
  SQLITE
98
101
 
99
102
  CONNECTION_POOL_MIDDLEWARE = <<-MIDDLEWARE
@@ -126,7 +126,7 @@ module Padrino
126
126
  when template_file =~ %r{^https?://} && template_file !~ /gist/
127
127
  template_file
128
128
  when template_file =~ /gist/ && template_file !~ /raw/
129
- raw_link, _ = *open(template_file) { |io| io.read.scan(/<a\s+href\s?\=\"(.*?)\"\>raw/) }
129
+ raw_link, _ = *URI.open(template_file) { |io| io.read.scan(/<a\s+href\s?\=\"(.*?)\"\>raw/) }
130
130
  raw_link ? "https://gist.github.com#{raw_link[0]}" : template_file
131
131
  when File.extname(template_file).empty? # referencing official plugin (i.e hoptoad)
132
132
  "https://raw.github.com/padrino/padrino-recipes/master/#{kind.to_s.pluralize}/#{template_file}_#{kind}.rb"
@@ -8,7 +8,7 @@
8
8
  **/
9
9
 
10
10
  $(function(){
11
- $('form').on('submit', function(e) {
11
+ $(document).on('submit', 'form', function(e) {
12
12
  var element = $(this), message = element.data('confirm');
13
13
  if (message && !confirm(message)) { return false; }
14
14
  if (element.data('remote') == true) {
@@ -420,6 +420,10 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
420
420
  ActiveRecord.version < Gem::Version.create("6.0.0")
421
421
  end
422
422
 
423
+ def less_than_active_record_6_1?
424
+ ActiveRecord.version < Gem::Version.create("6.1.0")
425
+ end
426
+
423
427
  def with_database(env_name)
424
428
  if less_than_active_record_6_0?
425
429
  config = ActiveRecord::Base.configurations.with_indifferent_access[env_name]
@@ -429,7 +433,7 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
429
433
  db_configs = ActiveRecord::Base.configurations.configs_for(env_name: env_name.to_s)
430
434
 
431
435
  db_configs.each do |db_config|
432
- yield db_config.config.with_indifferent_access
436
+ yield configuration_hash(db_config)
433
437
  end
434
438
  end
435
439
  end
@@ -441,11 +445,17 @@ if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
441
445
  end
442
446
  else
443
447
  ActiveRecord::Base.configurations.configs_for.each do |db_config|
444
- yield db_config.config.with_indifferent_access
448
+ yield configuration_hash(db_config)
445
449
  end
446
450
  end
447
451
  end
448
452
 
453
+ def configuration_hash(configuration)
454
+ return configuration if less_than_active_record_6_0?
455
+ config = less_than_active_record_6_1 ? configuration.config : configuration.configuration_hash
456
+ config.with_indifferent_access
457
+ end
458
+
449
459
  task 'db:migrate' => 'ar:migrate'
450
460
  task 'db:create' => 'ar:create'
451
461
  task 'db:drop' => 'ar:drop'
@@ -0,0 +1,66 @@
1
+ ##
2
+ # You can use other adapters like:
3
+ #
4
+ # ActiveRecord::Base.configurations = {
5
+ # :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
+ # }
17
+ #
18
+ ActiveRecord::Base.configurations = {
19
+ :development => {
20
+ :adapter => 'sqlite3',
21
+ :database => Padrino.root('db', 'sample_project_development.db')
22
+
23
+ },
24
+ :production => {
25
+ :adapter => 'sqlite3',
26
+ :database => Padrino.root('db', 'sample_project_production.db')
27
+
28
+ },
29
+ :test => {
30
+ :adapter => 'sqlite3',
31
+ :database => Padrino.root('db', 'sample_project_test.db')
32
+
33
+ }
34
+ }
35
+
36
+ # Setup our logger
37
+ ActiveRecord::Base.logger = logger
38
+
39
+ if ActiveRecord::VERSION::MAJOR.to_i < 4
40
+ # Raise exception on mass assignment protection for Active Record models.
41
+ ActiveRecord::Base.mass_assignment_sanitizer = :strict
42
+
43
+ # Log the query plan for queries taking more than this (works
44
+ # with SQLite, MySQL, and PostgreSQL).
45
+ ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
46
+ end
47
+
48
+ # Doesn't include Active Record class name as root for JSON serialized output.
49
+ ActiveRecord::Base.include_root_in_json = false
50
+
51
+ # Store the full class name (including module namespace) in STI type column.
52
+ ActiveRecord::Base.store_full_sti_class = true
53
+
54
+ # Use ISO 8601 format for JSON serialized times and dates.
55
+ ActiveSupport.use_standard_json_time_format = true
56
+
57
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper
58
+ # if you're including raw JSON in an HTML page.
59
+ ActiveSupport.escape_html_entities_in_json = false
60
+
61
+ # Now we can establish connection with our db.
62
+ if ActiveRecord::VERSION::MAJOR.to_i < 6
63
+ ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Padrino.env])
64
+ else
65
+ ActiveRecord::Base.establish_connection(Padrino.env)
66
+ end
data/test/helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/pride'
3
- require 'mocha/setup'
4
3
  require 'rack/test'
5
4
  require 'fakeweb'
6
5
  require 'thor/group'
@@ -11,6 +10,7 @@ require 'padrino-helpers'
11
10
 
12
11
  require 'ext/minitest-spec'
13
12
  require 'ext/fakeweb-ruby24'
13
+ require 'mocha/minitest'
14
14
 
15
15
  Padrino::Generators.load_components!
16
16
 
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/helper')
2
+ require "rb-readline"
2
3
 
3
4
  describe "ComponentGenerator" do
4
5
  def setup
@@ -25,6 +26,8 @@ describe "ComponentGenerator" do
25
26
  assert_match_in_file(/gem 'activerecord', '>= 3.1', :require => 'active_record'/, "#{@apptmp}/sample_project/Gemfile")
26
27
  assert_match_in_file(/gem 'sqlite3'/, "#{@apptmp}/sample_project/Gemfile")
27
28
  refute_match(/Switch renderer to/, out)
29
+ database_template_path = File.join(File.dirname(__FILE__), 'fixtures', 'database_template.rb')
30
+ assert FileUtils.compare_file("#{@apptmp}/sample_project/config/database.rb", database_template_path)
28
31
  components_chosen = YAML.load_file("#{@apptmp}/sample_project/.components")
29
32
  assert_equal 'activerecord', components_chosen[:orm]
30
33
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
8
8
  - Nathan Esquenazi
9
9
  - Davide D'Agostino
10
10
  - Arthur Chiu
11
- autorequire:
11
+ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2020-05-14 00:00:00.000000000 Z
14
+ date: 2022-12-23 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.15.0
22
+ version: 0.15.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.15.0
29
+ version: 0.15.2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -53,28 +53,28 @@ dependencies:
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 0.15.0
56
+ version: 0.15.2
57
57
  type: :development
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - '='
62
62
  - !ruby/object:Gem::Version
63
- version: 0.15.0
63
+ version: 0.15.2
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: padrino-mailer
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - '='
69
69
  - !ruby/object:Gem::Version
70
- version: 0.15.0
70
+ version: 0.15.2
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - '='
76
76
  - !ruby/object:Gem::Version
77
- version: 0.15.0
77
+ version: 0.15.2
78
78
  description: Generators for easily creating and building padrino applications from
79
79
  the console
80
80
  email: padrinorb@gmail.com
@@ -133,7 +133,6 @@ files:
133
133
  - lib/padrino-gen/generators/components/tests/minitest.rb
134
134
  - lib/padrino-gen/generators/components/tests/rspec.rb
135
135
  - lib/padrino-gen/generators/components/tests/shoulda.rb
136
- - lib/padrino-gen/generators/components/tests/testunit 2.rb
137
136
  - lib/padrino-gen/generators/components/tests/testunit.rb
138
137
  - lib/padrino-gen/generators/controller.rb
139
138
  - lib/padrino-gen/generators/helper.rb
@@ -185,6 +184,7 @@ files:
185
184
  - lib/padrino-gen/padrino-tasks/sql-helpers.rb
186
185
  - padrino-gen.gemspec
187
186
  - test/fixtures/admin_template.rb
187
+ - test/fixtures/database_template.rb
188
188
  - test/fixtures/example_template.rb
189
189
  - test/fixtures/git_template.rb
190
190
  - test/fixtures/plugin_template.rb
@@ -207,7 +207,7 @@ homepage: http://www.padrinorb.com
207
207
  licenses:
208
208
  - MIT
209
209
  metadata: {}
210
- post_install_message:
210
+ post_install_message:
211
211
  rdoc_options:
212
212
  - "--charset=UTF-8"
213
213
  require_paths:
@@ -223,12 +223,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  - !ruby/object:Gem::Version
224
224
  version: 1.3.6
225
225
  requirements: []
226
- rubygems_version: 3.0.6
227
- signing_key:
226
+ rubygems_version: 3.0.8
227
+ signing_key:
228
228
  specification_version: 4
229
229
  summary: Generators for easily creating and building padrino applications
230
230
  test_files:
231
231
  - test/fixtures/admin_template.rb
232
+ - test/fixtures/database_template.rb
232
233
  - test/fixtures/example_template.rb
233
234
  - test/fixtures/git_template.rb
234
235
  - test/fixtures/plugin_template.rb
@@ -1,112 +0,0 @@
1
- TESTUNIT_SETUP = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTUNIT_SETUP)
2
- RACK_ENV = 'test' unless defined?(RACK_ENV)
3
- require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
- Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
5
-
6
- class Test::Unit::TestCase
7
- include Rack::Test::Methods
8
-
9
- # You can use this method to custom specify a Rack app
10
- # you want rack-test to invoke:
11
- #
12
- # app CLASS_NAME
13
- # app CLASS_NAME.tap { |a| }
14
- # app(CLASS_NAME) do
15
- # set :foo, :bar
16
- # end
17
- #
18
- def app(app = nil, &blk)
19
- @app ||= block_given? ? app.instance_eval(&blk) : app
20
- @app ||= Padrino.application
21
- end
22
- end
23
- TEST
24
-
25
- TESTUNIT_RAKE = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTUNIT_RAKE)
26
- require 'rake/testtask'
27
-
28
- test_tasks = Dir['test/*/'].map { |d| File.basename(d) }
29
-
30
- test_tasks.each do |folder|
31
- Rake::TestTask.new("test:\#{folder}") do |test|
32
- test.pattern = "test/\#{folder}/**/*_test.rb"
33
- test.verbose = true
34
- end
35
- end
36
-
37
- desc "Run application test suite"
38
- task 'test' => test_tasks.map { |f| "test:\#{f}" }
39
-
40
- task :default => :test
41
- TEST
42
-
43
- TESTUNIT_CONTROLLER_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTUNIT_CONTROLLER_TEST)
44
- require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
45
-
46
- class !NAME!ControllerTest < Test::Unit::TestCase
47
- def setup
48
- get "/"
49
- end
50
-
51
- def test_returns_hello_world_text
52
- assert_equal "Hello World", last_response.body
53
- end
54
- end
55
- TEST
56
-
57
- TESTUNIT_MODEL_TEST = (<<-TEST).gsub(/^ {10}/, '') unless defined?(TESTUNIT_MODEL_TEST)
58
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
59
-
60
- class !NAME!Test < Test::Unit::TestCase
61
- def test_constructs_a_new_instance
62
- @!DNAME! = !NAME!.new
63
- refute_nil @!DNAME!
64
- end
65
- end
66
- TEST
67
-
68
- TESTUNIT_HELPER_TEST = (<<-TEST) unless defined?(TESTUNIT_HELPER_TEST)
69
- require File.expand_path(File.dirname(__FILE__) + '!PATH!/test_config.rb')
70
-
71
- class !NAME!Test < Test::Unit::TestCase
72
- def self.setup
73
- @helpers = Class.new
74
- @helpers.extend !CONSTANT_NAME!
75
- end
76
-
77
- def helpers
78
- @helpers
79
- end
80
-
81
- def test_foo_helper
82
- assert_equal nil, helpers.foo
83
- end
84
- end
85
- TEST
86
-
87
- def setup_test
88
- require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
89
- require_dependencies 'test-unit', :require => 'test/unit', :group => 'test'
90
- insert_test_suite_setup TESTUNIT_SETUP
91
- create_file destination_root("test/test.rake"), TESTUNIT_RAKE
92
- end
93
-
94
- def generate_controller_test(name, path)
95
- test_unit_contents = TESTUNIT_CONTROLLER_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize)
96
- controller_test_path = File.join('test',options[:app],'controllers',"#{name.to_s.underscore}_controller_test.rb")
97
- create_file destination_root(controller_test_path), test_unit_contents, :skip => true
98
- end
99
-
100
- def generate_model_test(name)
101
- test_unit_contents = TESTUNIT_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
102
- test_unit_contents.gsub!(/!PATH!/, recognize_path)
103
- model_test_path = File.join('test',options[:app],'models',"#{name.to_s.underscore}_test.rb")
104
- create_file destination_root(model_test_path), test_unit_contents, :skip => true
105
- end
106
-
107
- def generate_helper_test(name, project_name, app_name)
108
- test_unit_contents = TESTUNIT_HELPER_TEST.gsub(/!NAME!/, name).gsub(/!CONSTANT_NAME!/, "#{project_name}::#{app_name}::#{name}")
109
- test_unit_contents.gsub!(/!PATH!/, recognize_path)
110
- helper_spec_path = File.join('test', options[:app], 'helpers', "#{name.underscore}_test.rb")
111
- create_file destination_root(helper_spec_path), test_unit_contents, :skip => true
112
- end