mongar 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem 'linguistics'
7
- gem 'mongo'
7
+ gem 'mongo', '1.12.3'
8
8
 
9
9
  # Add dependencies to develop your gem here.
10
10
  # Include everything needed to run rake, tests, features, etc.
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- bson (1.5.1)
4
+ bson (1.12.3)
5
5
  diff-lcs (1.1.3)
6
6
  git (1.2.5)
7
7
  jeweler (1.6.4)
@@ -9,8 +9,8 @@ GEM
9
9
  git (>= 1.2.5)
10
10
  rake
11
11
  linguistics (1.0.9)
12
- mongo (1.5.1)
13
- bson (= 1.5.1)
12
+ mongo (1.12.3)
13
+ bson (= 1.12.3)
14
14
  rake (0.9.2.2)
15
15
  rcov (0.9.11)
16
16
  rspec (2.3.0)
@@ -30,7 +30,7 @@ DEPENDENCIES
30
30
  bundler (~> 1.0.0)
31
31
  jeweler (~> 1.6.4)
32
32
  linguistics
33
- mongo
33
+ mongo (= 1.12.3)
34
34
  rcov
35
35
  rspec (~> 2.3.0)
36
36
  yard (~> 0.6.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -21,7 +21,7 @@ class Mongar
21
21
  @status_collection ||= 'statuses'
22
22
  end
23
23
 
24
- [:database, :user, :password, :host, :port, :status_collection].each do |attr_name|
24
+ [:database, :auth_database, :auth_mechanism, :user, :password, :host, :port, :status_collection].each do |attr_name|
25
25
  define_method(attr_name) do |*args|
26
26
  val = args.first
27
27
  return instance_variable_get(:"@#{attr_name}") if val.nil?
@@ -30,10 +30,7 @@ class Mongar
30
30
  end
31
31
 
32
32
  def connection
33
- @connection = ::Mongo::Connection.new(host, port)
34
- return @connection if self.user.nil? || @connection.authenticate(user, password)
35
- @connection.close
36
- @connection = nil
33
+ ::Mongo::Connection.new(host, port)
37
34
  end
38
35
 
39
36
  def connection!
@@ -41,7 +38,14 @@ class Mongar
41
38
  end
42
39
 
43
40
  def db
44
- @db ||= connection!.db(database.to_s)
41
+ return @db unless @db.nil?
42
+ @db = connection!.db(database.to_s)
43
+ unless self.user.nil?
44
+ db = self.auth_database.nil? ? @db : connection!.db(self.auth_database)
45
+ mechanism = self.auth_mechanism || 'SCRAM-SHA-1'
46
+ db.authenticate(user, password, :mechanism => mechanism)
47
+ end
48
+ @db
45
49
  end
46
50
 
47
51
  def status_collection_accessor
@@ -52,4 +56,4 @@ class Mongar
52
56
  db.eval("return new Date()")
53
57
  end
54
58
  end
55
- end
59
+ end
@@ -53,12 +53,23 @@ class Mongar::Mongo
53
53
  def log_activity
54
54
  return unless should_log_activity?
55
55
  logger.debug "Logging activity for #{name}"
56
-
57
- # should be able to set last_activity_at = new Date() but I can't figure out how to get
58
- # ruby's mongo library to evaluate it instead of setting it to the string "new Date()"
59
- status_collection.update({ :collection_name => name },
60
- { '$set' => { :collection_name => name, :last_activity_at => mongodb.time_on_server } },
61
- { :upsert => true })
56
+
57
+ # MongoDB 2.6+ supports currentDate, so let's try that first.
58
+ begin
59
+ status_collection.update(
60
+ { :collection_name => name },
61
+ { '$currentDate' => { :last_activity_at => true }, '$set' => { :collection_name => name } },
62
+ { :upsert => true }
63
+ )
64
+ rescue => e
65
+ raise e unless e.to_s =~ /Invalid modifier specified \$currentDate/
66
+ # Fallback to an $eval to get the date (gross).
67
+ status_collection.update(
68
+ { :collection_name => name },
69
+ { '$set' => { :collection_name => name, :last_activity_at => mongodb.time_on_server } },
70
+ { :upsert => true }
71
+ )
72
+ end
62
73
  @last_logged_activity = Time.now
63
74
  end
64
75
 
@@ -130,4 +141,4 @@ class Mongar::Mongo
130
141
  end
131
142
  end
132
143
  end
133
- end
144
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mongar"
8
- s.version = "0.0.11"
8
+ s.version = "0.0.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Philippe Green"]
12
- s.date = "2012-04-19"
12
+ s.date = "2015-09-11"
13
13
  s.description = "Replicates data from ActiveRecord (or other Ruby data mapping class) to MongoDB"
14
14
  s.email = "phil@greenviewdata.com"
15
15
  s.extra_rdoc_files = [
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
45
45
  s.homepage = "http://github.com/gdi/mongar"
46
46
  s.licenses = ["MIT"]
47
47
  s.require_paths = ["lib"]
48
- s.rubygems_version = "1.8.10"
48
+ s.rubygems_version = "1.8.29"
49
49
  s.summary = "Replicates data from ActiveRecord (or other Ruby data mapping class) to MongoDB"
50
50
 
51
51
  if s.respond_to? :specification_version then
@@ -53,7 +53,7 @@ Gem::Specification.new do |s|
53
53
 
54
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
55
  s.add_runtime_dependency(%q<linguistics>, [">= 0"])
56
- s.add_runtime_dependency(%q<mongo>, [">= 0"])
56
+ s.add_runtime_dependency(%q<mongo>, ["= 1.12.3"])
57
57
  s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
58
58
  s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
59
59
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -61,7 +61,7 @@ Gem::Specification.new do |s|
61
61
  s.add_development_dependency(%q<rcov>, [">= 0"])
62
62
  else
63
63
  s.add_dependency(%q<linguistics>, [">= 0"])
64
- s.add_dependency(%q<mongo>, [">= 0"])
64
+ s.add_dependency(%q<mongo>, ["= 1.12.3"])
65
65
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
66
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
67
67
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
@@ -70,7 +70,7 @@ Gem::Specification.new do |s|
70
70
  end
71
71
  else
72
72
  s.add_dependency(%q<linguistics>, [">= 0"])
73
- s.add_dependency(%q<mongo>, [">= 0"])
73
+ s.add_dependency(%q<mongo>, ["= 1.12.3"])
74
74
  s.add_dependency(%q<rspec>, ["~> 2.3.0"])
75
75
  s.add_dependency(%q<yard>, ["~> 0.6.0"])
76
76
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
metadata CHANGED
@@ -1,102 +1,140 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mongar
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.11
3
+ version: !ruby/object:Gem::Version
4
+ hash: 7
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 12
10
+ version: 0.0.12
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Philippe Green
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-04-19 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: linguistics
16
- requirement: &70284555282580 !ruby/object:Gem::Requirement
17
+
18
+ date: 2015-09-11 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ requirement: &id001 !ruby/object:Gem::Requirement
17
22
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ name: linguistics
23
31
  prerelease: false
24
- version_requirements: *70284555282580
25
- - !ruby/object:Gem::Dependency
26
- name: mongo
27
- requirement: &70284555281820 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: '0'
32
+ version_requirements: *id001
33
33
  type: :runtime
34
+ - !ruby/object:Gem::Dependency
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - "="
39
+ - !ruby/object:Gem::Version
40
+ hash: 33
41
+ segments:
42
+ - 1
43
+ - 12
44
+ - 3
45
+ version: 1.12.3
46
+ name: mongo
34
47
  prerelease: false
35
- version_requirements: *70284555281820
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &70284555280780 !ruby/object:Gem::Requirement
48
+ version_requirements: *id002
49
+ type: :runtime
50
+ - !ruby/object:Gem::Dependency
51
+ requirement: &id003 !ruby/object:Gem::Requirement
39
52
  none: false
40
- requirements:
53
+ requirements:
41
54
  - - ~>
42
- - !ruby/object:Gem::Version
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 2
59
+ - 3
60
+ - 0
43
61
  version: 2.3.0
44
- type: :development
62
+ name: rspec
45
63
  prerelease: false
46
- version_requirements: *70284555280780
47
- - !ruby/object:Gem::Dependency
48
- name: yard
49
- requirement: &70284555279440 !ruby/object:Gem::Requirement
64
+ version_requirements: *id003
65
+ type: :development
66
+ - !ruby/object:Gem::Dependency
67
+ requirement: &id004 !ruby/object:Gem::Requirement
50
68
  none: false
51
- requirements:
69
+ requirements:
52
70
  - - ~>
53
- - !ruby/object:Gem::Version
71
+ - !ruby/object:Gem::Version
72
+ hash: 7
73
+ segments:
74
+ - 0
75
+ - 6
76
+ - 0
54
77
  version: 0.6.0
55
- type: :development
78
+ name: yard
56
79
  prerelease: false
57
- version_requirements: *70284555279440
58
- - !ruby/object:Gem::Dependency
59
- name: bundler
60
- requirement: &70284555278960 !ruby/object:Gem::Requirement
80
+ version_requirements: *id004
81
+ type: :development
82
+ - !ruby/object:Gem::Dependency
83
+ requirement: &id005 !ruby/object:Gem::Requirement
61
84
  none: false
62
- requirements:
85
+ requirements:
63
86
  - - ~>
64
- - !ruby/object:Gem::Version
87
+ - !ruby/object:Gem::Version
88
+ hash: 23
89
+ segments:
90
+ - 1
91
+ - 0
92
+ - 0
65
93
  version: 1.0.0
66
- type: :development
94
+ name: bundler
67
95
  prerelease: false
68
- version_requirements: *70284555278960
69
- - !ruby/object:Gem::Dependency
70
- name: jeweler
71
- requirement: &70284555303760 !ruby/object:Gem::Requirement
96
+ version_requirements: *id005
97
+ type: :development
98
+ - !ruby/object:Gem::Dependency
99
+ requirement: &id006 !ruby/object:Gem::Requirement
72
100
  none: false
73
- requirements:
101
+ requirements:
74
102
  - - ~>
75
- - !ruby/object:Gem::Version
103
+ - !ruby/object:Gem::Version
104
+ hash: 7
105
+ segments:
106
+ - 1
107
+ - 6
108
+ - 4
76
109
  version: 1.6.4
77
- type: :development
110
+ name: jeweler
78
111
  prerelease: false
79
- version_requirements: *70284555303760
80
- - !ruby/object:Gem::Dependency
81
- name: rcov
82
- requirement: &70284555303040 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
112
+ version_requirements: *id006
88
113
  type: :development
114
+ - !ruby/object:Gem::Dependency
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ name: rcov
89
125
  prerelease: false
90
- version_requirements: *70284555303040
91
- description: Replicates data from ActiveRecord (or other Ruby data mapping class)
92
- to MongoDB
126
+ version_requirements: *id007
127
+ type: :development
128
+ description: Replicates data from ActiveRecord (or other Ruby data mapping class) to MongoDB
93
129
  email: phil@greenviewdata.com
94
130
  executables: []
131
+
95
132
  extensions: []
96
- extra_rdoc_files:
133
+
134
+ extra_rdoc_files:
97
135
  - LICENSE.txt
98
136
  - README.rdoc
99
- files:
137
+ files:
100
138
  - .document
101
139
  - .rspec
102
140
  - Gemfile
@@ -122,31 +160,37 @@ files:
122
160
  - spec/mongar_spec.rb
123
161
  - spec/spec_helper.rb
124
162
  homepage: http://github.com/gdi/mongar
125
- licenses:
163
+ licenses:
126
164
  - MIT
127
165
  post_install_message:
128
166
  rdoc_options: []
129
- require_paths:
167
+
168
+ require_paths:
130
169
  - lib
131
- required_ruby_version: !ruby/object:Gem::Requirement
170
+ required_ruby_version: !ruby/object:Gem::Requirement
132
171
  none: false
133
- requirements:
134
- - - ! '>='
135
- - !ruby/object:Gem::Version
136
- version: '0'
137
- segments:
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ hash: 3
176
+ segments:
138
177
  - 0
139
- hash: -260101698656845288
140
- required_rubygems_version: !ruby/object:Gem::Requirement
178
+ version: "0"
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
180
  none: false
142
- requirements:
143
- - - ! '>='
144
- - !ruby/object:Gem::Version
145
- version: '0'
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ hash: 3
185
+ segments:
186
+ - 0
187
+ version: "0"
146
188
  requirements: []
189
+
147
190
  rubyforge_project:
148
- rubygems_version: 1.8.10
191
+ rubygems_version: 1.8.29
149
192
  signing_key:
150
193
  specification_version: 3
151
194
  summary: Replicates data from ActiveRecord (or other Ruby data mapping class) to MongoDB
152
195
  test_files: []
196
+