fish0 0.1.2 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a00a4bea56a945cd7b81b258645b09716c2c7a70
4
- data.tar.gz: 6476e00ce9d49567a3875414273859daa9ad229f
3
+ metadata.gz: c92bbc56a6b40c928b87b597f5f877c2b43c5794
4
+ data.tar.gz: ce6816113e2138835a1ffbf16ec16249d73dfc9b
5
5
  SHA512:
6
- metadata.gz: 60a3af9d7f5cf440e48a48b1a9271b2865b24fd06cdb04a275216d0f44e7e6404a9301adc1dc1ab8a4e5628892fb6076e0319e31957fceab03246c8d6572f3e8
7
- data.tar.gz: 1886eb1e1d73018ff5a4c9fbca48a02bffb0c780c2952a9cdf00d595edf1c4f8c8fb600a7bb9fdcfeaf6d614e924c6268b1082b309230df7502f42973d06ed88
6
+ metadata.gz: 7f5d4a46724a931dd927884ec52cbab0eeeac30ed8715131aeb069a59fc7bc02dc8b3c2d05384cb1a6b58b3333fea8ee7208af3b8efc52829b9c933edc871a79
7
+ data.tar.gz: 1246a6a736ac3793e211873640c0cc5839437c2d8c611894abdc2c5a00ee34cb6eeac1ea6f9f233f91c6ea59a26c444271ec750758eb1c9176d292c471db2713
data/README.md CHANGED
@@ -22,8 +22,8 @@ gem 'fish0'
22
22
  # config/initializers/fish0.rb
23
23
 
24
24
  Fish0::Configuration.configure do |config|
25
- config.mongo_hosts = ['127.0.0.1:27017', '127.0.0.2:27017']
26
- config.mongo_params = { database: 'project_db', read: { mode: :secondary } }
25
+ config.mongo_uri = 'mongodb://user:password@host_1:27017,replica_host_2:27017/project_db?auth_source=admin'
26
+ config.mongo_params = { read: { mode: :secondary } }
27
27
  end
28
28
  ```
29
29
 
@@ -18,16 +18,16 @@ module Fish0
18
18
  class << self
19
19
  def mongo_reader
20
20
  Mongo::Logger.logger = mongo_config['logger'] || Rails.logger
21
- @mongo_reader ||= Mongo::Client.new(mongo_config[:hosts], mongo_config[:params])
21
+ @mongo_reader ||= Mongo::Client.new(mongo_config[:mongo_uri], mongo_config[:params])
22
22
  end
23
23
 
24
24
  def mongo_config
25
25
  if File.file?(File.expand_path('../config/mongo.yml', __FILE__))
26
26
  config = Rails.application.config_for(:mongo)
27
- Configuration.mongo_hosts = config['hosts']
27
+ Configuration.mongo_uri = config['mongo_uri']
28
28
  Configuration.mongo_params = config['params']
29
29
  end
30
- @mongo_config || { hosts: Configuration.mongo_hosts, params: Configuration.mongo_params }
30
+ @mongo_config || { mongo_uri: Configuration.mongo_uri, params: Configuration.mongo_params }
31
31
  end
32
32
  end
33
33
  end
@@ -6,10 +6,9 @@ module Fish0
6
6
  included do
7
7
  def cache_key(*timestamp_names)
8
8
  if timestamp_names.any?
9
- timestamp = max_updated_column_timestamp(timestamp_names)
10
- "#{self.class.to_s.tableize}/#{primary_key_value}-#{timestamp.utc.to_s(:nsec)}"
11
- elsif timestamp = max_updated_column_timestamp
12
- "#{self.class.to_s.tableize}/#{primary_key_value}-#{timestamp.utc.to_s(:nsec)}"
9
+ cache_key_string(max_updated_column_timestamp(timestamp_names))
10
+ elsif (timestamp = max_updated_column_timestamp)
11
+ cache_key_string(timestamp)
13
12
  else
14
13
  "#{self.class.to_s.tableize}/#{primary_key_value}"
15
14
  end
@@ -28,6 +27,10 @@ module Fish0
28
27
  .map(&:to_time)
29
28
  .max
30
29
  end
30
+
31
+ def cache_key_string(timestamp)
32
+ "#{self.class.to_s.tableize}/#{primary_key_value}-#{timestamp.utc.to_s(:nsec)}"
33
+ end
31
34
  end
32
35
  end
33
36
  end
@@ -5,25 +5,26 @@ module Fish0
5
5
  # Usage:
6
6
  # # config/initializers/fish0.rb
7
7
  # Fish0::Configuration.configure do |config|
8
- # config.mongo_hosts = ['localhost:27017']
9
- # config.mongo_params = { database: 'your_data_development', read: { mode: :secondary } }
8
+ # config.mongo_uri = 'mongodb://user:password@host_1:27017,replica_host_2:27017/'\
9
+ # 'fish0_development?auth_source=admin'
10
+ # config.mongo_params = { read: { mode: :secondary } }
10
11
  # end
11
- ##
12
+ #
13
+
12
14
  class Configuration
13
15
  include ActiveSupport::Configurable
14
16
 
15
- config_accessor :mongo_hosts do
16
- ['localhost:27017']
17
+ # Usage:
18
+ # Enter your full mongo_uri (can include username, password, multiple hosts, ports, db name,
19
+ # and additional options as get-parameters
20
+ config_accessor :mongo_uri do
21
+ 'mongodb://localhost:27017/fish0_development'
17
22
  end
18
23
 
19
- ##
20
- # Fish0::Configuration.mongo_params
21
- #
22
24
  # Usage:
23
- # Enter your database and another params as second arguement to MongoClient::New
24
- ##
25
+ # Enter your as second argument to MongoClient::New
25
26
  config_accessor :mongo_params do
26
- { database: 'fish0_development', read: { mode: :secondary } }
27
+ { read: { mode: :secondary } }
27
28
  end
28
29
  end
29
30
  end
@@ -1,3 +1,3 @@
1
1
  module Fish0
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -1,11 +1,7 @@
1
1
  development:
2
- hosts:
3
- - 'localhost:27017'
4
- params:
5
- :database: fish0_development
2
+ mongo_uri:
3
+ - 'mongodb://localhost:27017/fish0_development'
6
4
 
7
5
  test:
8
- hosts:
9
- - 'localhost:27017'
10
- params:
11
- :database: fish0_test
6
+ mongo_uri:
7
+ - 'mongodb://localhost:27017/fish0_development'
@@ -190,3 +190,33 @@ MONGODB | Server localhost:27017 initializing.
190
190
  MONGODB | Topology type 'unknown' changed to type 'single'.
191
191
  MONGODB | Server description for localhost:27017 changed from 'unknown' to 'standalone'.
192
192
  MONGODB | There was a change in the members of the 'single' topology.
193
+ MONGODB | Topology type 'unknown' initializing.
194
+ MONGODB | Server localhost:27017 initializing.
195
+ MONGODB | Topology type 'unknown' changed to type 'single'.
196
+ MONGODB | Server description for localhost:27017 changed from 'unknown' to 'standalone'.
197
+ MONGODB | There was a change in the members of the 'single' topology.
198
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
199
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000748s
200
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
201
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000248s
202
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
203
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000263s
204
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
205
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.00021899999999999998s
206
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
207
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000244s
208
+ MONGODB | Topology type 'unknown' initializing.
209
+ MONGODB | Server localhost:27017 initializing.
210
+ MONGODB | Topology type 'unknown' changed to type 'single'.
211
+ MONGODB | Server description for localhost:27017 changed from 'unknown' to 'standalone'.
212
+ MONGODB | There was a change in the members of the 'single' topology.
213
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
214
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000656s
215
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
216
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.00027299999999999997s
217
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
218
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000223s
219
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
220
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.00024s
221
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | STARTED | {"dropDatabase"=>1}
222
+ MONGODB | localhost:27017 | fish0_development.dropDatabase | SUCCEEDED | 0.000215s
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.describe Fish0::Repository do
4
- let(:repository) { Fish0::Repository.new('articles') }
5
- let(:scoped_repository) { Fish0::Repository.new('articles') }
4
+ let(:repository) { Fish0::Repository.new(collection: 'articles') }
5
+ let(:scoped_repository) { Fish0::Repository.new(collection: 'articles') }
6
6
 
7
7
  describe '#scope' do
8
8
  before do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fish0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Zuev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-16 00:00:00.000000000 Z
11
+ date: 2017-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport