minidoc 2.0.0 → 2.0.1

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: f94229d111dbbb7b7abdaaf21036b775c4dae1f0
4
- data.tar.gz: 79957eed89f74d4564806d05e12b0f6c095e3bc2
3
+ metadata.gz: a8cf89e249748f809266af352e66320d4fb388b5
4
+ data.tar.gz: 249b016bad5f2c05294881593c41a46dce8f9277
5
5
  SHA512:
6
- metadata.gz: 3a74d5b6d68dbfd2abd69b669ca8ac5be982da8cfe643357aa4707f1a0e5d9a0bcd13942dd4be8ea541cb1ab957b3c6ad0b8d80a9e49a694eda2b5b5741a43c6
7
- data.tar.gz: eb0c2fb02647e48fbce4e3ca68f9868d82f26d2032741ea312697ffc041a2ebcfa6033464aa6d2e95c5b4176782681b296876bf8afff4c8f08c8023739e565a2
6
+ metadata.gz: d7336a4d0526a4242b15844f695707d7eab0b63349ebf909c0be771021a30057ea86f6f1c45c0eaa990f4a820eb60857fd140c746d190a4a90eae0a60545d56b
7
+ data.tar.gz: a778137311b667764d318e86d1b82ba4b2c2046d29f95e5c120609dc37c751733e9aedde6640178212444af938be01f5fa5e99c98fe4f79ea3e4d7f1bcf7d828
@@ -5,7 +5,14 @@ class Minidoc::ReadOnly < Minidoc::Value
5
5
  include Minidoc::Connection
6
6
  include Minidoc::Finders
7
7
 
8
- def self.database
9
- Minidoc.database
8
+ # This and `self.database_name` are deleted & redefined by `class_attribute`
9
+ # when you call `.connection=` or `.database_name=`, so these still allow
10
+ # `ReadOnly` subclasses to override their connection details
11
+ def self.connection
12
+ Minidoc.connection
13
+ end
14
+
15
+ def self.database_name
16
+ Minidoc.database_name
10
17
  end
11
18
  end
@@ -16,9 +16,11 @@ class Minidoc
16
16
  end
17
17
 
18
18
  def each_collection(&block)
19
- Minidoc.database.collections.
20
- reject { |c| c.name.include?("system") }.
21
- each(&block)
19
+ [$mongo, $alt_mongo].each do |conn|
20
+ conn.db.collections.
21
+ reject { |c| c.name.include?("system") }.
22
+ each(&block)
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,3 @@
1
1
  class Minidoc
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
@@ -6,6 +6,13 @@ describe Minidoc::ReadOnly do
6
6
  attribute :name, String
7
7
  end
8
8
 
9
+ class AltModel < Minidoc::ReadOnly
10
+ self.connection = $alt_mongo
11
+ self.database_name = $alt_mongo.db.name
12
+
13
+ attribute :name, String
14
+ end
15
+
9
16
  it "is read only, meaning it can't change over time" do
10
17
  expect { ReadOnlyUser.create(name: "Bryan") }.to raise_error(NoMethodError)
11
18
 
@@ -18,6 +25,17 @@ describe Minidoc::ReadOnly do
18
25
  expect { user.name = "Noah" }.to raise_error(NoMethodError)
19
26
  end
20
27
 
28
+ it "can have a separate mongo connection" do
29
+ expect(AltModel.count).to eq(0)
30
+ $alt_mongo.db[:alt_models].insert(name: "42")
31
+ expect(AltModel.count).to eq(1)
32
+
33
+ instance = AltModel.find_one(name: "42")
34
+ expect(instance.name).to eq("42")
35
+
36
+ expect { instance.name = "Noah" }.to raise_error(NoMethodError)
37
+ end
38
+
21
39
  it "can become a value object" do
22
40
  user = User.new(name: "Bryan")
23
41
  user.name = "Noah"
data/spec/spec_helper.rb CHANGED
@@ -26,6 +26,9 @@ $mongo = Mongo::MongoClient.from_uri(ENV["MONGODB_URI"] || "mongodb://localhost/
26
26
  Minidoc.connection = $mongo
27
27
  Minidoc.database_name = $mongo.db.name
28
28
 
29
+ alt_url = "mongodb://#{$mongo.host}/#{$mongo.db.name}_2"
30
+ $alt_mongo = Mongo::MongoClient.from_uri(alt_url)
31
+
29
32
  RSpec.configure do |config|
30
33
  if config.files_to_run.one?
31
34
  config.default_formatter = "doc"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-02 00:00:00.000000000 Z
12
+ date: 2017-10-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport