minidoc 2.0.0 → 2.0.1
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 +4 -4
- data/lib/minidoc/read_only.rb +9 -2
- data/lib/minidoc/test_helpers.rb +5 -3
- data/lib/minidoc/version.rb +1 -1
- data/spec/minidoc/read_only_spec.rb +18 -0
- data/spec/spec_helper.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8cf89e249748f809266af352e66320d4fb388b5
|
4
|
+
data.tar.gz: 249b016bad5f2c05294881593c41a46dce8f9277
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7336a4d0526a4242b15844f695707d7eab0b63349ebf909c0be771021a30057ea86f6f1c45c0eaa990f4a820eb60857fd140c746d190a4a90eae0a60545d56b
|
7
|
+
data.tar.gz: a778137311b667764d318e86d1b82ba4b2c2046d29f95e5c120609dc37c751733e9aedde6640178212444af938be01f5fa5e99c98fe4f79ea3e4d7f1bcf7d828
|
data/lib/minidoc/read_only.rb
CHANGED
@@ -5,7 +5,14 @@ class Minidoc::ReadOnly < Minidoc::Value
|
|
5
5
|
include Minidoc::Connection
|
6
6
|
include Minidoc::Finders
|
7
7
|
|
8
|
-
|
9
|
-
|
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
|
data/lib/minidoc/test_helpers.rb
CHANGED
@@ -16,9 +16,11 @@ class Minidoc
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def each_collection(&block)
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
data/lib/minidoc/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|