sinatra-activerecord 2.0.15 → 2.0.20

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
  SHA256:
3
- metadata.gz: 4d67085a10064adfededc08eda8ccc64b995827241f7a397c8fac43f6c5b615d
4
- data.tar.gz: 781a0e1eb138e705021b37eb73892e2efa2d00176d97d908a5ef61f09cee54c2
3
+ metadata.gz: 536a528576f9a003de9a0f910ee935d5028e7ec10652bb5ca43bcd23e9cd5e25
4
+ data.tar.gz: d08f1ee914093a0918d31be3435961e863b497b869326dd7e1d05de5480212ce
5
5
  SHA512:
6
- metadata.gz: 6e21b386700b45220639c6dcee8d49a077995718bb00cf6d43ba3a4a0f0952452eb6aa5f914fd1941a2374efe96843518eda024af9cbbde45b1639d9ab844ca1
7
- data.tar.gz: 0d0f23e9f7352e6333e785af312a83c594c179bbde29008818cf5f9d71cf44ba1f819f23a03fe572252e0e5221b6622c67b2da94250bf1270a803332507480ac
6
+ metadata.gz: f1c964a3b55958eafc132f9caa8b74f4b5a57905244ec13b7fcf1374a9887c062b6556480133d9d3a802b12e00da273a706c2945aeb533160e1fdbb09805ceff
7
+ data.tar.gz: 5f13ff25c06d4c2bbb0136d266327d3b9a0da08e69bbf372e2a1798308999d2f90e00aa494a8597b93c9faa36079b466e98dd1ed9368e63cd0fe12950ba556ee
data/README.md CHANGED
@@ -4,6 +4,11 @@ Extends [Sinatra](http://www.sinatrarb.com/) with extension methods and Rake
4
4
  tasks for dealing with an SQL database using the
5
5
  [ActiveRecord ORM](https://github.com/rails/rails/tree/master/activerecord).
6
6
 
7
+ ![test badge](https://github.com/sinatra-activerecord/sinatra-activerecord/workflows/rspec/badge.svg)
8
+
9
+ ## Requirement
10
+ ActiveRecord >= 4.1
11
+
7
12
  ## Setup
8
13
 
9
14
  Put it in your `Gemfile`, along with the adapter of your database. For
@@ -43,13 +43,21 @@ module Sinatra
43
43
  if spec.is_a?(Hash) and spec.symbolize_keys[environment.to_sym]
44
44
  ActiveRecord::Base.configurations = spec.stringify_keys
45
45
  ActiveRecord::Base.establish_connection(environment.to_sym)
46
- elsif spec.is_a?(Hash)
47
- ActiveRecord::Base.configurations[environment.to_s] = spec.stringify_keys
46
+ elsif spec.is_a?(Hash)
47
+ ActiveRecord::Base.configurations = {
48
+ environment.to_s => spec.stringify_keys
49
+ }
50
+
48
51
  ActiveRecord::Base.establish_connection(spec.stringify_keys)
49
52
  else
53
+ if Gem.loaded_specs["activerecord"].version >= Gem::Version.create('6.0')
54
+ ActiveRecord::Base.configurations ||= ActiveRecord::DatabaseConfigurations.new({}).resolve(spec)
55
+ else
56
+ ActiveRecord::Base.configurations ||= {}
57
+ ActiveRecord::Base.configurations[environment.to_s] = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(spec).to_hash
58
+ end
59
+
50
60
  ActiveRecord::Base.establish_connection(spec)
51
- ActiveRecord::Base.configurations ||= {}
52
- ActiveRecord::Base.configurations[environment.to_s] = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(spec).to_hash
53
61
  end
54
62
  end
55
63
 
@@ -8,7 +8,7 @@ module Rails
8
8
  end
9
9
 
10
10
  def env
11
- ActiveSupport::StringInquirer.new(ENV["RACK_ENV"] || "development")
11
+ ActiveSupport::StringInquirer.new(ENV["APP_ENV"] || ENV["RACK_ENV"] || "development")
12
12
  end
13
13
 
14
14
  def application
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  ActiveRecord::Tasks::DatabaseTasks.tap do |config|
8
8
  config.root = Rake.application.original_dir
9
- config.env = ENV["RACK_ENV"] || "development"
9
+ config.env = ENV["APP_ENV"] || ENV["RACK_ENV"] || "development"
10
10
  config.db_dir = "db"
11
11
  config.migrations_paths = ["db/migrate"]
12
12
  config.fixtures_path = "test/fixtures"
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  ActiveRecord::Tasks::DatabaseTasks.tap do |config|
8
8
  config.root = Rake.application.original_dir
9
- config.env = ENV["RACK_ENV"] || "development"
9
+ config.env = ENV["APP_ENV"] || ENV["RACK_ENV"] || "development"
10
10
  config.db_dir = "db"
11
11
  config.migrations_paths = ["db/migrate"]
12
12
  config.fixtures_path = "test/fixtures"
@@ -6,7 +6,7 @@ end
6
6
 
7
7
  ActiveRecord::Tasks::DatabaseTasks.tap do |config|
8
8
  config.root = Rake.application.original_dir
9
- config.env = ENV["RACK_ENV"] || "development"
9
+ config.env = ENV["APP_ENV"] || ENV["RACK_ENV"] || "development"
10
10
  config.db_dir = "db"
11
11
  config.migrations_paths = ["db/migrate"]
12
12
  config.fixtures_path = "test/fixtures"
@@ -5,13 +5,21 @@ require "fileutils"
5
5
  namespace :db do
6
6
  desc "Create a migration (parameters: NAME, VERSION)"
7
7
  task :create_migration do
8
- unless ENV["NAME"]
8
+ ARGV.each do |a|
9
+ # when we run 'rake db:create_migration create_users v1',
10
+ # rake will also run 'rake create_users' and 'rake v1'
11
+ # to avoid rake abort, we define an empty method for these (ie: "task :create_users do ; end")
12
+ next if a.nil?
13
+ task a.to_sym do ; end
14
+ end
15
+
16
+ unless ENV["NAME"] || ARGV[1]
9
17
  puts "No NAME specified. Example usage: `rake db:create_migration NAME=create_users`"
10
18
  exit
11
19
  end
12
20
 
13
- name = ENV["NAME"]
14
- version = ENV["VERSION"] || Time.now.utc.strftime("%Y%m%d%H%M%S")
21
+ name = ENV["NAME"] || ARGV[1]
22
+ version = ENV["VERSION"] || ARGV[2] || Time.now.utc.strftime("%Y%m%d%H%M%S")
15
23
 
16
24
  ActiveRecord::Migrator.migrations_paths.each do |directory|
17
25
  next unless File.exist?(directory)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.15
4
+ version: 2.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-15 00:00:00.000000000 Z
12
+ date: 2020-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '3.2'
34
+ version: '4.1'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '3.2'
41
+ version: '4.1'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.0.3
132
+ rubygems_version: 3.1.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Extends Sinatra with ActiveRecord helpers.