mongo-configure 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/lib/mongo-configure.rb +1 -37
- data/lib/mongo/configure.rb +36 -0
- data/lib/{mongo-configure → mongo/configure}/uri.rb +0 -0
- data/lib/{mongo-configure → mongo/configure}/version.rb +1 -1
- data/mongo-configure.gemspec +3 -1
- data/spec/{mongo-configure → mongo/configure}/uri_spec.rb +1 -1
- data/spec/{mongo-configure_spec.rb → mongo/configure_spec.rb} +3 -3
- metadata +30 -7
data/.travis.yml
CHANGED
data/lib/mongo-configure.rb
CHANGED
@@ -1,37 +1 @@
|
|
1
|
-
require
|
2
|
-
require "mongo-configure/version"
|
3
|
-
require 'mongo-configure/uri'
|
4
|
-
require 'mongo-configure/config'
|
5
|
-
|
6
|
-
module Mongo
|
7
|
-
module Configure
|
8
|
-
|
9
|
-
class Config
|
10
|
-
include Morphine
|
11
|
-
|
12
|
-
register(:connection) { Connection }
|
13
|
-
|
14
|
-
def initialize(uri)
|
15
|
-
@uri = uri
|
16
|
-
end
|
17
|
-
attr_reader :uri
|
18
|
-
def load
|
19
|
-
connection.from_uri(@uri.to_s).db @uri.database
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class << self
|
24
|
-
|
25
|
-
def from_uri(uri)
|
26
|
-
@config = Config.new URI.parse uri
|
27
|
-
end
|
28
|
-
def from_database(name)
|
29
|
-
@config = Config.new URI.new.tap { |uri| uri.database = name }
|
30
|
-
end
|
31
|
-
def current
|
32
|
-
@config ||= new
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require "mongo/configure"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'morphine'
|
2
|
+
require "mongo/configure/version"
|
3
|
+
require 'mongo/configure/uri'
|
4
|
+
|
5
|
+
module Mongo
|
6
|
+
module Configure
|
7
|
+
|
8
|
+
class Config
|
9
|
+
include Morphine
|
10
|
+
|
11
|
+
register(:connection) { Connection }
|
12
|
+
|
13
|
+
def initialize(uri)
|
14
|
+
@uri = uri
|
15
|
+
end
|
16
|
+
attr_reader :uri
|
17
|
+
def load
|
18
|
+
connection.from_uri(@uri.to_s).db @uri.database
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
|
24
|
+
def from_uri(uri)
|
25
|
+
@config = Config.new URI.parse uri
|
26
|
+
end
|
27
|
+
def from_database(name)
|
28
|
+
@config = Config.new URI.new.tap { |uri| uri.database = name }
|
29
|
+
end
|
30
|
+
def current
|
31
|
+
@config ||= new
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
File without changes
|
data/mongo-configure.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/mongo
|
2
|
+
require File.expand_path('../lib/mongo/configure/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Jon Rowe"]
|
@@ -17,5 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency 'morphine'
|
19
19
|
gem.add_dependency 'mongo'
|
20
|
+
|
20
21
|
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'rake'
|
21
23
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'mongo
|
1
|
+
require 'mongo/configure'
|
2
2
|
|
3
3
|
describe 'configuring databases' do
|
4
4
|
describe 'from a uri' do
|
@@ -42,8 +42,8 @@ describe 'configuring databases' do
|
|
42
42
|
|
43
43
|
describe 'loading a connection from the configuration' do
|
44
44
|
let(:configuration) { Mongo::Configure.current }
|
45
|
-
let(:fake_connector) { double from_uri
|
46
|
-
let(:fake_connection) { double db
|
45
|
+
let(:fake_connector) { double :from_uri => fake_connection }
|
46
|
+
let(:fake_connection) { double :db => database }
|
47
47
|
let(:database) { double }
|
48
48
|
|
49
49
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo-configure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: A simple gem for configuring mongo databases.
|
63
79
|
email:
|
64
80
|
- hello@jonrowe.co.uk
|
@@ -73,11 +89,12 @@ files:
|
|
73
89
|
- README.md
|
74
90
|
- Rakefile
|
75
91
|
- lib/mongo-configure.rb
|
76
|
-
- lib/mongo
|
77
|
-
- lib/mongo
|
92
|
+
- lib/mongo/configure.rb
|
93
|
+
- lib/mongo/configure/uri.rb
|
94
|
+
- lib/mongo/configure/version.rb
|
78
95
|
- mongo-configure.gemspec
|
79
|
-
- spec/mongo
|
80
|
-
- spec/mongo
|
96
|
+
- spec/mongo/configure/uri_spec.rb
|
97
|
+
- spec/mongo/configure_spec.rb
|
81
98
|
homepage: https://github.com/JonRowe/mongo-configure
|
82
99
|
licenses: []
|
83
100
|
post_install_message:
|
@@ -90,12 +107,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
107
|
- - ! '>='
|
91
108
|
- !ruby/object:Gem::Version
|
92
109
|
version: '0'
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
hash: 3998061049660393534
|
93
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
114
|
none: false
|
95
115
|
requirements:
|
96
116
|
- - ! '>='
|
97
117
|
- !ruby/object:Gem::Version
|
98
118
|
version: '0'
|
119
|
+
segments:
|
120
|
+
- 0
|
121
|
+
hash: 3998061049660393534
|
99
122
|
requirements: []
|
100
123
|
rubyforge_project:
|
101
124
|
rubygems_version: 1.8.24
|
@@ -103,5 +126,5 @@ signing_key:
|
|
103
126
|
specification_version: 3
|
104
127
|
summary: A simple gem for configuring mongo databases.
|
105
128
|
test_files:
|
106
|
-
- spec/mongo
|
107
|
-
- spec/mongo
|
129
|
+
- spec/mongo/configure/uri_spec.rb
|
130
|
+
- spec/mongo/configure_spec.rb
|