low 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -6
- data/lib/low/mongo/heroku.rb +25 -0
- data/lib/low/mongo/util.rb +0 -18
- data/lib/low/mongo.rb +2 -1
- data/lib/low/version.rb +1 -1
- metadata +2 -1
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
low (0.0.
|
4
|
+
low (0.0.2)
|
5
5
|
bson_ext
|
6
6
|
mongo
|
7
7
|
rack
|
@@ -9,12 +9,12 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
bson (1.
|
13
|
-
bson_ext (1.
|
14
|
-
bson (~> 1.
|
12
|
+
bson (1.7.0)
|
13
|
+
bson_ext (1.7.0)
|
14
|
+
bson (~> 1.7.0)
|
15
15
|
diff-lcs (1.1.3)
|
16
|
-
mongo (1.
|
17
|
-
bson (~> 1.
|
16
|
+
mongo (1.7.0)
|
17
|
+
bson (~> 1.7.0)
|
18
18
|
rack (1.4.1)
|
19
19
|
rack-test (0.6.1)
|
20
20
|
rack (>= 1.0)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Low
|
2
|
+
module Mongo
|
3
|
+
# The `Heroku` module provides helper methods for Mongo on Heroku.
|
4
|
+
module Heroku
|
5
|
+
def self.current_remote
|
6
|
+
# If a mongodb URI can be extracted from `heroku config`,
|
7
|
+
if uri = Mongo::Util.extract_mongodb_uris(`heroku config`).first
|
8
|
+
|
9
|
+
# build a Mongo::Remote with it.
|
10
|
+
Mongo::Remote.new(uri)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def self.sync_current_remote(local_database_or_mongo)
|
16
|
+
# If there is a remote Heroku Mongo,
|
17
|
+
if remote = Heroku.current_remote
|
18
|
+
|
19
|
+
# sync it to the specified database or Mongo.
|
20
|
+
Mongo::Util.sync_from_remote(local_database_or_mongo, remote)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/low/mongo/util.rb
CHANGED
@@ -10,15 +10,6 @@ module Low
|
|
10
10
|
URI.extract(string, 'mongodb')
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.heroku_remote_mongo
|
14
|
-
# If a mongodb URI can be extracted from heroku config,
|
15
|
-
if uri = extract_mongodb_uris(`heroku config`).first
|
16
|
-
|
17
|
-
# build a Mongo::Remote with it.
|
18
|
-
Mongo::Remote.new(uri)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
13
|
def self.sync_from_remote(local_database_or_mongo, remote)
|
23
14
|
# If a Mongo::Local is specified,
|
24
15
|
local = local_database_or_mongo.is_a?(Mongo::Local) ?
|
@@ -43,15 +34,6 @@ module Low
|
|
43
34
|
remote.password
|
44
35
|
)
|
45
36
|
end
|
46
|
-
|
47
|
-
def self.sync_heroku(local_database_or_mongo)
|
48
|
-
# If there is a remote Heroku Mongo,
|
49
|
-
if remote = heroku_remote_mongo
|
50
|
-
|
51
|
-
# sync it to the specified database or Mongo.
|
52
|
-
sync_from_remote(local_database_or_mongo, remote)
|
53
|
-
end
|
54
|
-
end
|
55
37
|
end
|
56
38
|
end
|
57
39
|
end
|
data/lib/low/mongo.rb
CHANGED
@@ -4,7 +4,8 @@ module Low
|
|
4
4
|
# The `Mongo` module defines an interface for a Mongo helper
|
5
5
|
# class. It also includes two basic classes, `Local` and `Remote`.
|
6
6
|
module Mongo
|
7
|
-
autoload :
|
7
|
+
autoload :Heroku, 'low/mongo/heroku'
|
8
|
+
autoload :Util, 'low/mongo/util'
|
8
9
|
|
9
10
|
# Simple access to a Mongo::Collection instance.
|
10
11
|
def [](collection)
|
data/lib/low/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: low
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- Rakefile
|
107
107
|
- lib/low.rb
|
108
108
|
- lib/low/mongo.rb
|
109
|
+
- lib/low/mongo/heroku.rb
|
109
110
|
- lib/low/mongo/util.rb
|
110
111
|
- lib/low/subdomain_map.rb
|
111
112
|
- lib/low/version.rb
|