fish0 0.0.5 → 0.0.6
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/fish0/collection.rb +21 -0
- data/lib/fish0/concerns/base.rb +2 -2
- data/lib/fish0/configuration.rb +29 -0
- data/lib/fish0/engine.rb +2 -2
- data/lib/fish0/repository.rb +1 -1
- data/lib/fish0/version.rb +1 -1
- data/lib/fish0.rb +9 -2
- metadata +31 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0d8c5d6b6d9c34b27abe4e2d6c9e6a56332a34
|
4
|
+
data.tar.gz: 61709857c463321cfa11b987d01420c1d1cf2a43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28fbf425d5d62dfd31966a701a7bbb093aec2f27bde60c6f3b73b5349ab26593adb54d1797db5a5fb8e37fea0d0987f94230f703a7f5ed99ef999ccb9970153a
|
7
|
+
data.tar.gz: 009725b2871b44eb8adfca8e2ea0eee43afd8093ebd11405e81f68bcdb67ec25275dc78ecd084d4bc5bd1e45ad34bdf3e1132bbba450fcedefe77b919e4730da
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fish0
|
2
|
+
class Collection < Array
|
3
|
+
def cache_key
|
4
|
+
most_recent = select(&:updated_at).sort_by(&:updated_at).last
|
5
|
+
|
6
|
+
timestamp = time_to_string(most_recent ? most_recent.updated_at : Time.zone.now)
|
7
|
+
|
8
|
+
"#{objects_key}-#{timestamp}"
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def objects_key
|
14
|
+
Digest::MD5.hexdigest(map(&:slug).join)
|
15
|
+
end
|
16
|
+
|
17
|
+
def time_to_string(timestamp)
|
18
|
+
timestamp.strftime('%Y%m%d%H%M%S%9N')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fish0/concerns/base.rb
CHANGED
@@ -50,8 +50,8 @@ module Fish0
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def repository
|
53
|
-
if "#{entity
|
54
|
-
return "#{entity
|
53
|
+
if "#{entity}Repository".safe_constantize
|
54
|
+
return "#{entity}Repository".constantize.new(collection, entity)
|
55
55
|
end
|
56
56
|
Fish0::Repository.new(collection, entity)
|
57
57
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fish0
|
2
|
+
##
|
3
|
+
# Fish0::Configuration
|
4
|
+
#
|
5
|
+
# Usage:
|
6
|
+
# # config/initializers/fish0.rb
|
7
|
+
# Fish0::Configuration.configure do |config|
|
8
|
+
# config.mongo_hosts = ['localhost:27017']
|
9
|
+
# config.mongo_params = { database: 'your_data_development', read: { mode: :secondary } }
|
10
|
+
# end
|
11
|
+
##
|
12
|
+
class Configuration
|
13
|
+
include ActiveSupport::Configurable
|
14
|
+
|
15
|
+
config_accessor :mongo_hosts do
|
16
|
+
['localhost:27017']
|
17
|
+
end
|
18
|
+
|
19
|
+
##
|
20
|
+
# Fish0::Configuration.mongo_params
|
21
|
+
#
|
22
|
+
# Usage:
|
23
|
+
# Enter your database and another params as second arguement to MongoClient::New
|
24
|
+
##
|
25
|
+
config_accessor :mongo_params do
|
26
|
+
{ database: 'fish0_development', read: { mode: :secondary } }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/fish0/engine.rb
CHANGED
@@ -3,8 +3,8 @@ module Fish0
|
|
3
3
|
isolate_namespace Fish0
|
4
4
|
|
5
5
|
config.generators do |g|
|
6
|
-
g.test_framework :rspec, :
|
7
|
-
g.fixture_replacement :factory_girl, :
|
6
|
+
g.test_framework :rspec, fixture: false
|
7
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
8
8
|
g.assets false
|
9
9
|
g.helper false
|
10
10
|
end
|
data/lib/fish0/repository.rb
CHANGED
data/lib/fish0/version.rb
CHANGED
data/lib/fish0.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'mongo'
|
2
2
|
require 'virtus'
|
3
3
|
require 'fish0/version'
|
4
|
+
require 'fish0/configuration'
|
4
5
|
require 'fish0/engine'
|
5
6
|
require 'fish0/exceptions'
|
6
7
|
require 'fish0/repository'
|
@@ -9,17 +10,23 @@ require 'fish0/concerns/cacheable'
|
|
9
10
|
require 'fish0/concerns/paginatable'
|
10
11
|
require 'fish0/concerns/view_model'
|
11
12
|
require 'fish0/concerns/base'
|
13
|
+
require 'fish0/collection'
|
12
14
|
require 'fish0/model'
|
13
15
|
|
14
16
|
module Fish0
|
15
17
|
class << self
|
16
18
|
def mongo_reader
|
17
19
|
Mongo::Logger.logger = mongo_config['logger'] || Rails.logger
|
18
|
-
Mongo::Client.new(mongo_config[
|
20
|
+
Mongo::Client.new(mongo_config[:hosts], mongo_config[:params])
|
19
21
|
end
|
20
22
|
|
21
23
|
def mongo_config
|
22
|
-
|
24
|
+
if File.file?(File.expand_path('../config/mongo.yml', __FILE__))
|
25
|
+
config = Rails.application.config_for(:mongo)
|
26
|
+
Configuration.mongo_hosts = config['hosts']
|
27
|
+
Configuration.mongo_params = config['params']
|
28
|
+
end
|
29
|
+
@mongo_config || { hosts: Configuration.mongo_hosts, params: Configuration.mongo_params }
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fish0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Zuev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
@@ -98,30 +112,30 @@ dependencies:
|
|
98
112
|
name: capybara
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - "
|
115
|
+
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
117
|
+
version: '2.7'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- - "
|
122
|
+
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
124
|
+
version: '2.7'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: factory_girl_rails
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '4.7'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '4.7'
|
125
139
|
description: |-
|
126
140
|
Plugin for read-only content websites with MongoDB storage.
|
127
141
|
Works perfect with Rambler&Co CQRS projects
|
@@ -135,10 +149,12 @@ files:
|
|
135
149
|
- README.md
|
136
150
|
- Rakefile
|
137
151
|
- lib/fish0.rb
|
152
|
+
- lib/fish0/collection.rb
|
138
153
|
- lib/fish0/concerns/base.rb
|
139
154
|
- lib/fish0/concerns/cacheable.rb
|
140
155
|
- lib/fish0/concerns/paginatable.rb
|
141
156
|
- lib/fish0/concerns/view_model.rb
|
157
|
+
- lib/fish0/configuration.rb
|
142
158
|
- lib/fish0/engine.rb
|
143
159
|
- lib/fish0/exceptions.rb
|
144
160
|
- lib/fish0/model.rb
|
@@ -189,7 +205,9 @@ homepage: https://github.com/rambler-digital-solutions/fish0
|
|
189
205
|
licenses:
|
190
206
|
- MIT
|
191
207
|
metadata: {}
|
192
|
-
post_install_message:
|
208
|
+
post_install_message: "\n WARNING if updating from version prior 0.0.6 you need to
|
209
|
+
change\n mongo configuration.\n Configure mongo using config/initializers/fish0.rb\n
|
210
|
+
\ Read examples in README.md\n "
|
193
211
|
rdoc_options: []
|
194
212
|
require_paths:
|
195
213
|
- lib
|
@@ -250,3 +268,4 @@ test_files:
|
|
250
268
|
- spec/dummy/README.rdoc
|
251
269
|
- spec/models/model_spec.rb
|
252
270
|
- spec/spec_helper.rb
|
271
|
+
has_rdoc:
|