sequel-rails 0.5.1 → 0.6.0

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
  SHA1:
3
- metadata.gz: d8ea9bc9710a82354d3df888106dc2c6b971eb41
4
- data.tar.gz: bb493d857f3236c479356890e1790906ff7ed3ab
3
+ metadata.gz: 3330d90f962d4bfa80130c3493821dd336026f9f
4
+ data.tar.gz: 0bf339401f577de82fbabc98a7e0802c445a8937
5
5
  SHA512:
6
- metadata.gz: a7f6e7394c214be105146096a8f65e7f0eda0b33d7525a67f51b0a2611454a52f8baf352a6868d317e1e2488b4e283d0d2169d2a3fa8dbbf2044bcb6f07cbda4
7
- data.tar.gz: cd45198031727fdefee6ca5a4c68a80db03d7c3e7bc3111cb0ddd3169577030bd0815a5c00b2f76085832c250ce051b451899baf86743ad752ebbab3c65566b7
6
+ metadata.gz: f2223b86642bc6a5ee1fdf190fb50f49a3b7e75f98df818c0d00bc1bf787ab9c7643735cf6789737d0397d7e269e02a9de3d064f30d6b5354a0d3dd9e453016f
7
+ data.tar.gz: fb92d8c8da9c8850b5ae5c843d9025049065b163e354284c8e78c378a1b27d547b969c82204b79969051e45dc8f9cd415dde02b984f29e716892abc576600197
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ 0.6.0 (2013-09-12)
2
+ ==================
3
+
4
+ * Do not try to construct `url` from config if data config already contains one `url` [#35](https://github.com/TalentBox/sequel-rails/issues/41)
5
+ * Add setting to allow disabling database's rake tasks to be loaded [#41](https://github.com/TalentBox/sequel-rails/issues/41)
6
+ * Loosen the Sequel dependencies to `< 5.0` (Joshua Hansen) [#39](https://github.com/TalentBox/sequel-rails/pull/39)
7
+ * Fix regexp to extract root url when using JDBC (Eric Strathmeyer) [#40](https://github.com/TalentBox/sequel-rails/pull/40)
8
+
1
9
  0.5.1 (2013-08-05)
2
10
  ==================
3
11
 
data/README.md CHANGED
@@ -68,6 +68,10 @@ You can configure some options with the usual rails mechanism, in
68
68
  # These override corresponding settings from the database config.
69
69
  config.sequel.max_connections = 16
70
70
  config.sequel.search_path = %w(mine public)
71
+
72
+ # Configure whether database's rake tasks will be loaded or not
73
+ # Defaults to true
74
+ config.sequel.load_database_tasks = false
71
75
  ```
72
76
 
73
77
  Available sequel specific rake tasks
@@ -148,6 +152,7 @@ Improvements has been made by those awesome contributors:
148
152
  * Sean Sorrell (rudle)
149
153
  * Saulius Grigaliunas (sauliusg)
150
154
  * Jacques Crocker (railsjedi)
155
+ * Eric Strathmeyer (strathmeyer)
151
156
 
152
157
  Credits
153
158
  =======
@@ -23,6 +23,11 @@ module SequelRails
23
23
  attr_accessor :logger
24
24
  attr_accessor :migration_dir
25
25
 
26
+ def initialize(root, database_yml_hash)
27
+ super()
28
+ @root, @raw = root, database_yml_hash
29
+ end
30
+
26
31
  def environment_for(name)
27
32
  environments[name.to_s] || environments[name.to_sym]
28
33
  end
@@ -39,17 +44,16 @@ module SequelRails
39
44
  super.nil? ? (schema_dump = default_schema_dump) : super
40
45
  end
41
46
 
47
+ def load_database_tasks
48
+ super.nil? ? (load_database_tasks = true) : super
49
+ end
50
+
42
51
  private
43
52
 
44
53
  def default_schema_dump
45
54
  not %w(test production).include? Rails.env
46
55
  end
47
56
 
48
- def initialize(root, database_yml_hash)
49
- super()
50
- @root, @raw = root, database_yml_hash
51
- end
52
-
53
57
  def normalize_repository_config(hash)
54
58
  config = {}
55
59
  hash.each do |key, value|
@@ -86,7 +90,7 @@ module SequelRails
86
90
  config['search_path'] = search_path if search_path
87
91
 
88
92
  # some adapters only support an url
89
- if config['adapter'] && config['adapter'] =~ /^(jdbc|do):/
93
+ if config['adapter'] && config['adapter'] =~ /^(jdbc|do):/ && !config.has_key?('url')
90
94
  params = {}
91
95
  config.each do |k, v|
92
96
  next if ['adapter', 'host', 'port', 'database'].include?(k)
@@ -98,7 +102,7 @@ module SequelRails
98
102
  end
99
103
  params_str = params.map { |k, v| "#{k}=#{v}" }.join('&')
100
104
  port = config['port'] ? ":#{config['port']}" : ''
101
- config['url'] = case config['adapter']
105
+ config['url'] ||= case config['adapter']
102
106
  when /sqlite/
103
107
  "%s:%s" % [config['adapter'], config['database']]
104
108
  else
@@ -36,8 +36,10 @@ module SequelRails
36
36
 
37
37
  config.sequel = ActiveSupport::OrderedOptions.new
38
38
 
39
- rake_tasks do
40
- load "sequel_rails/railties/database.rake"
39
+ rake_tasks do |app|
40
+ if app.config.sequel.load_database_tasks
41
+ load "sequel_rails/railties/database.rake"
42
+ end
41
43
  end
42
44
 
43
45
  initializer 'sequel.configuration' do |app|
@@ -15,7 +15,7 @@ module SequelRails
15
15
  end
16
16
 
17
17
  def _root_url
18
- config['url'].scan(/^jdbc:mysql:\/\/\w*:?\d*/).first
18
+ config['url'].scan(/^jdbc:mysql:\/\/[\w\.]*:?\d*/).first
19
19
  end
20
20
 
21
21
  def db_name
@@ -1,3 +1,3 @@
1
1
  module SequelRails
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.extra_rdoc_files = ["LICENSE", "README.md"]
20
20
  s.rdoc_options = ["--charset=UTF-8"]
21
21
 
22
- s.add_runtime_dependency "sequel", [">= 3.28", "< 4.1.0"]
22
+ s.add_runtime_dependency "sequel", [">= 3.28", "< 5.0"]
23
23
  s.add_runtime_dependency "railties", ">= 3.2.0"
24
24
 
25
25
  s.add_development_dependency "rake", ">= 0.8.7"
@@ -2,46 +2,50 @@ require "spec_helper"
2
2
 
3
3
  describe SequelRails::Configuration do
4
4
 
5
- let(:environments) do
6
- {
7
- "development" => {
8
- "adapter" => "postgres",
9
- "owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
10
- "username" => (ENV["TEST_OWNER"] || ENV["USER"]),
11
- "database" => "sequel_rails_test_storage_dev",
12
- "host" => "127.0.0.1",
13
- },
14
- "test" => {
15
- "adapter" => "postgres",
16
- "owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
17
- "username" => (ENV["TEST_OWNER"] || ENV["USER"]),
18
- "database" => "sequel_rails_test_storage_test",
19
- "host" => "127.0.0.1",
20
- },
21
- "remote" => {
22
- "adapter" => "mysql",
23
- "host" => "10.0.0.1",
24
- "database" => "sequel_rails_test_storage_remote",
25
- },
26
- "production" => {
27
- "host" => "10.0.0.1",
28
- "database" => "sequel_rails_test_storage_production",
29
- },
30
- "bogus" => {},
31
- }
32
- end
33
- let(:is_jruby) { false }
5
+ describe ".setup" do
34
6
 
35
- before do
36
- SequelRails.configuration.stub(:raw).and_return environments
37
- SequelRails.configuration.instance_variable_set('@environments', nil)
38
- SequelRails.stub(:jruby?).and_return is_jruby
39
- end
7
+ let(:environments) do
8
+ {
9
+ "development" => {
10
+ "adapter" => "postgres",
11
+ "owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
12
+ "username" => (ENV["TEST_OWNER"] || ENV["USER"]),
13
+ "database" => "sequel_rails_test_storage_dev",
14
+ "host" => "127.0.0.1",
15
+ },
16
+ "test" => {
17
+ "adapter" => "postgres",
18
+ "owner" => (ENV["TEST_OWNER"] || ENV["USER"]),
19
+ "username" => (ENV["TEST_OWNER"] || ENV["USER"]),
20
+ "database" => "sequel_rails_test_storage_test",
21
+ "host" => "127.0.0.1",
22
+ },
23
+ "remote" => {
24
+ "adapter" => "mysql",
25
+ "host" => "10.0.0.1",
26
+ "database" => "sequel_rails_test_storage_remote",
27
+ },
28
+ "production" => {
29
+ "host" => "10.0.0.1",
30
+ "database" => "sequel_rails_test_storage_production",
31
+ },
32
+ "url_already_constructed" => {
33
+ "adapter" => "adapter_name",
34
+ "url" => "jdbc:adapter_name://HOST/DB?user=U&password=P&ssl=true&sslfactory=sslFactoryOption"
35
+ },
36
+ "bogus" => {},
37
+ }
38
+ end
39
+ let(:is_jruby) { false }
40
40
 
41
- subject { SequelRails.setup(environment) }
41
+ before do
42
+ SequelRails.configuration.stub(:raw).and_return environments
43
+ SequelRails.configuration.instance_variable_set('@environments', nil)
44
+ SequelRails.stub(:jruby?).and_return is_jruby
45
+ end
46
+
47
+ subject { SequelRails.setup(environment) }
42
48
 
43
- describe ".setup" do
44
-
45
49
  shared_examples "max_connections" do
46
50
  context "with max_connections config option" do
47
51
  let(:max_connections) { 31337 }
@@ -64,7 +68,7 @@ describe SequelRails::Configuration do
64
68
  end
65
69
 
66
70
  context "for a postgres connection" do
67
-
71
+
68
72
  shared_examples "search_path" do
69
73
  context "with search_path config option" do
70
74
  let(:search_path) { ['secret', 'private', 'public'] }
@@ -89,7 +93,7 @@ describe SequelRails::Configuration do
89
93
  let(:environment) { 'development' }
90
94
 
91
95
  context "in C-Ruby" do
92
-
96
+
93
97
  include_examples "max_connections"
94
98
  include_examples "search_path"
95
99
 
@@ -99,11 +103,11 @@ describe SequelRails::Configuration do
99
103
  end
100
104
  subject
101
105
  end
102
-
106
+
103
107
  end
104
108
 
105
109
  context "in JRuby" do
106
-
110
+
107
111
  include_examples "max_connections"
108
112
  include_examples "search_path"
109
113
 
@@ -117,11 +121,25 @@ describe SequelRails::Configuration do
117
121
  end
118
122
  subject
119
123
  end
124
+
125
+ context "when url is already given" do
126
+
127
+ let(:environment) { "url_already_constructed" }
128
+
129
+ it "does not change the url" do
130
+ ::Sequel.should_receive(:connect) do |url, hash|
131
+ url.should == "jdbc:adapter_name://HOST/DB?user=U&password=P&ssl=true&sslfactory=sslFactoryOption"
132
+ hash['adapter'].should == 'jdbc:adapter_name'
133
+ end
134
+ subject
135
+ end
136
+
137
+ end
120
138
  end
121
139
  end
122
140
 
123
141
  context "for a mysql connection" do
124
-
142
+
125
143
  let(:environment) { 'remote' }
126
144
 
127
145
  context "in C-Ruby" do
@@ -137,7 +155,7 @@ describe SequelRails::Configuration do
137
155
  end
138
156
 
139
157
  context "in JRuby" do
140
-
158
+
141
159
  include_examples "max_connections"
142
160
 
143
161
  let(:is_jruby) { true }
@@ -150,7 +168,87 @@ describe SequelRails::Configuration do
150
168
  end
151
169
  subject
152
170
  end
171
+
172
+ context "when url is already given" do
173
+
174
+ let(:environment) { "url_already_constructed" }
175
+
176
+ it "does not change the url" do
177
+ ::Sequel.should_receive(:connect) do |url, hash|
178
+ url.should == "jdbc:adapter_name://HOST/DB?user=U&password=P&ssl=true&sslfactory=sslFactoryOption"
179
+ hash['adapter'].should == 'jdbc:adapter_name'
180
+ end
181
+ subject
182
+ end
183
+
184
+ end
185
+ end
186
+ end
187
+ end
188
+
189
+ describe "#schema_dump" do
190
+ before{ Rails.stub(:env).and_return environment }
191
+ subject { SequelRails::Configuration.new("path/to/app", {}) }
192
+
193
+ context "in test environment" do
194
+ let(:environment) { "test" }
195
+ it "defaults to false" do
196
+ subject.schema_dump.should be_false
197
+ end
198
+ it "can be assigned" do
199
+ subject.schema_dump = true
200
+ subject.schema_dump.should be_true
201
+ end
202
+ it "can be set from merging another hash" do
203
+ subject.merge!(:schema_dump => true)
204
+ subject.schema_dump.should be_true
205
+ end
206
+ end
207
+
208
+ context "in production environment" do
209
+ let(:environment) { "production" }
210
+ it "defaults to false" do
211
+ subject.schema_dump.should be_false
153
212
  end
213
+ it "can be assigned" do
214
+ subject.schema_dump = true
215
+ subject.schema_dump.should be_true
216
+ end
217
+ it "can be set from merging another hash" do
218
+ subject.merge!(:schema_dump => true)
219
+ subject.schema_dump.should be_true
220
+ end
221
+ end
222
+
223
+ context "in other environments" do
224
+ let(:environment) { "development" }
225
+ it "defaults to true" do
226
+ subject.schema_dump.should be_true
227
+ end
228
+ it "can be assigned" do
229
+ subject.schema_dump = false
230
+ subject.schema_dump.should be_false
231
+ end
232
+ it "can be set from merging another hash" do
233
+ subject.merge!(:schema_dump => false)
234
+ subject.schema_dump.should be_false
235
+ end
236
+ end
237
+ end
238
+
239
+ describe "#load_database_tasks" do
240
+ subject { SequelRails::Configuration.new("path/to/app", {}) }
241
+
242
+ it "defaults to true" do
243
+ subject.load_database_tasks.should be_true
244
+ end
245
+ it "can be assigned" do
246
+ subject.load_database_tasks = false
247
+ subject.load_database_tasks.should be_false
248
+ end
249
+ it "can be set from merging another hash" do
250
+ subject.merge!(:load_database_tasks => false)
251
+ subject.load_database_tasks.should be_false
154
252
  end
155
253
  end
156
254
  end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe SequelRails::Storage::Jdbc do
4
+ let(:adapter) { 'jdbc:mysql' }
5
+ let(:auto_reconnect) { true }
6
+ let(:connection_handling) { 'queue' }
7
+ let(:database) { 'test' }
8
+ let(:host) { 'localhost' }
9
+ let(:password) { nil }
10
+ let(:pool) { 80 }
11
+ let(:user) { 'root' }
12
+ let(:timeout) { 5000 }
13
+ let(:config) do
14
+ {
15
+ 'password' => password,
16
+ 'pool' => pool,
17
+ 'autoReconnect' => auto_reconnect,
18
+ 'adapter' => adapter,
19
+ 'timeout' => timeout,
20
+ 'connection_handling' => connection_handling,
21
+ 'user' => user,
22
+ 'host' => host,
23
+ 'database' => database,
24
+ 'url' => "#{adapter}://#{host}/#{database}?password=#{password}&pool=#{pool}&autoReconnect=#{auto_reconnect}&timeout=#{timeout}&connection_handling=#{connection_handling}&user=#{user}"
25
+ }
26
+ end
27
+ let(:store) { described_class.new(config) }
28
+
29
+ describe "#_root_url" do
30
+ subject { store._root_url }
31
+ let(:expected) { "jdbc:mysql://#{host}" }
32
+
33
+ it { should == expected }
34
+
35
+ context "with ip addresses" do
36
+ let(:host) { '127.0.0.1'}
37
+
38
+ it { should == expected }
39
+ end
40
+ end
41
+ end
@@ -45,10 +45,6 @@ describe SequelRails::Railtie do
45
45
  end
46
46
  end
47
47
 
48
- it "adds it's own database's rake tasks" do
49
- pending "need to find a way to spec it"
50
- end
51
-
52
48
  it "stores it's own config in app.config.sequel" do
53
49
  app.config.sequel.should be_instance_of SequelRails::Configuration
54
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brasten Sager (brasten)
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
12
+ date: 2013-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '3.28'
21
21
  - - <
22
22
  - !ruby/object:Gem::Version
23
- version: 4.1.0
23
+ version: '5.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '3.28'
31
31
  - - <
32
32
  - !ruby/object:Gem::Version
33
- version: 4.1.0
33
+ version: '5.0'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: railties
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +163,7 @@ files:
163
163
  - spec/internal/public/favicon.ico
164
164
  - spec/lib/generators/sequel/migration_spec.rb
165
165
  - spec/lib/sequel_rails/configuration_spec.rb
166
+ - spec/lib/sequel_rails/jdbc_spec.rb
166
167
  - spec/lib/sequel_rails/migrations_spec.rb
167
168
  - spec/lib/sequel_rails/railtie_spec.rb
168
169
  - spec/lib/sequel_rails/railties/database_rake_spec.rb
@@ -205,6 +206,7 @@ test_files:
205
206
  - spec/internal/public/favicon.ico
206
207
  - spec/lib/generators/sequel/migration_spec.rb
207
208
  - spec/lib/sequel_rails/configuration_spec.rb
209
+ - spec/lib/sequel_rails/jdbc_spec.rb
208
210
  - spec/lib/sequel_rails/migrations_spec.rb
209
211
  - spec/lib/sequel_rails/railtie_spec.rb
210
212
  - spec/lib/sequel_rails/railties/database_rake_spec.rb