sinatra-activerecord 2.0.14 → 2.0.19

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: a68d0f53d0161b4b41deb097efdad5fea9071023fe8a27da906573f2e7571b52
4
- data.tar.gz: 9e29d1aa6b4d09aed33ded5da3b0b2c56bbca8a7659a0211128430fb7da3ad60
3
+ metadata.gz: 55e1552d34d4435f9c90c62ae00e76474b5e4e08558dfb872778133499af4694
4
+ data.tar.gz: 77ce57edc98e8ebadbf747d3f34d74282d1c00d6aae75241329b1743c55328c8
5
5
  SHA512:
6
- metadata.gz: b08e875a9d38daac4b62f3df39cab16037b5dec436f0aa60c2c6716d23c1379c2ea0324b59c326ce19316225a4586da01fa271b7806b0b258273a61696cb25b4
7
- data.tar.gz: 1ceefe52451f1330235ea910a92b816353bfaff504a0786c6e3cf87867938cfb7b2824866c5acf62e1a9bf6e68f0300563483c4868d9856f562e817e2d1fde33
6
+ metadata.gz: 0c1e9e206386d461a94650a0fc32b0fd75f3637e644d7ac095fee1e91b883ef4eff1cb0e3deec07512a9c3b121f8d4cfc7f783aa6c0f085fbebe299cf5e715b4
7
+ data.tar.gz: d11486ea5b6138fdbe3fed75a95ec489193ff1840e4ab8d5cb050a4cd7fd63b3db1c120f19cf7430bf83ac59a9592386ffd098c3835d0a6dda0e635b5856e8e7
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"
@@ -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.14
4
+ version: 2.0.19
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: 2019-09-05 00:00:00.000000000 Z
12
+ date: 2020-10-05 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.