mongo_http_sync 0.1.0 → 0.3.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 +4 -4
- data/lib/mongo_http_sync/entity.rb +7 -0
- data/lib/mongo_http_sync/exportable_document.rb +14 -0
- data/lib/mongo_http_sync/importer.rb +4 -3
- data/lib/mongo_http_sync/mongo_importer.rb +1 -1
- data/lib/mongo_http_sync/mongoid_importer.rb +1 -1
- data/lib/mongo_http_sync/parser.rb +1 -1
- data/lib/mongo_http_sync/version.rb +1 -1
- data/lib/mongo_http_sync.rb +5 -3
- data/mongo_http_sync.gemspec +1 -0
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7577fa07921f970382f96c1441d662a4d4d15ba
|
4
|
+
data.tar.gz: ce199bafe2291c6566c8cf3a3d1cabe9f1949666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e77eb4731b00282bdd87afc33f6b20e118d3a6fb81af99c6aa5bf9508ede7c9f93d9bdc66116f442b1357865c58945b7769b483a572410fd464fd0cd9d84b6bb
|
7
|
+
data.tar.gz: e0314114dd6114b29e4df52d2f21a70362e0a0fa2993f6efa6629b04864be73b32fb9622eefc9b48e23b33c67b940da416890b3af222e24964b992d36e39a60f
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
require 'active_support/concern'
|
3
|
+
|
4
|
+
module MongoHTTPSync
|
5
|
+
module ExportableDocument
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
include Mongoid::Timestamps::Updated
|
8
|
+
|
9
|
+
included do
|
10
|
+
scope :updated_since, ->(time) { where(updated_at: { '$gte' => time }) }
|
11
|
+
index updated_on: 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -9,15 +9,16 @@ module MongoHTTPSync
|
|
9
9
|
@output = output
|
10
10
|
end
|
11
11
|
|
12
|
-
def import(url, key:
|
12
|
+
def import(url, key: :id, entity: nil)
|
13
13
|
last_updated_doc = find_last_updated_doc
|
14
14
|
newest_update = last_updated_doc['updated_at'] unless last_updated_doc.nil?
|
15
15
|
unless newest_update.nil?
|
16
16
|
url = append_query_param(url, 'updated_since', newest_update.utc.strftime('%Y-%m-%d %H:%M:%S.%L UTC'))
|
17
17
|
end
|
18
|
-
puts url
|
19
18
|
Parser.parse(HTTP.get(url).body) do |json|
|
20
|
-
json[
|
19
|
+
json[:_id] = json.delete(key)
|
20
|
+
json[:updated_at] = Time.parse(json[:updated_at])
|
21
|
+
json = entity.represent(json).as_json if entity.present?
|
21
22
|
upsert(json)
|
22
23
|
end
|
23
24
|
end
|
data/lib/mongo_http_sync.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require "mongo_http_sync/version"
|
2
2
|
|
3
3
|
module MongoHTTPSync
|
4
|
-
autoload :MongoImporter,
|
5
|
-
autoload :MongoidImporter,
|
6
|
-
autoload :Parser,
|
4
|
+
autoload :MongoImporter, 'mongo_http_sync/mongo_importer'
|
5
|
+
autoload :MongoidImporter, 'mongo_http_sync/mongoid_importer'
|
6
|
+
autoload :Parser, 'mongo_http_sync/parser'
|
7
|
+
autoload :Entity, 'mongo_http_sync/entity'
|
8
|
+
autoload :ExportableDocument, 'mongo_http_sync/exportable_document'
|
7
9
|
end
|
data/mongo_http_sync.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo_http_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- André Aizim Kelmanson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: grape-entity
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Synchronizes HTTP services with MongoDB
|
140
154
|
email:
|
141
155
|
- akelmanson@gmail.com
|
@@ -155,6 +169,8 @@ files:
|
|
155
169
|
- bin/console
|
156
170
|
- bin/setup
|
157
171
|
- lib/mongo_http_sync.rb
|
172
|
+
- lib/mongo_http_sync/entity.rb
|
173
|
+
- lib/mongo_http_sync/exportable_document.rb
|
158
174
|
- lib/mongo_http_sync/importer.rb
|
159
175
|
- lib/mongo_http_sync/mongo_importer.rb
|
160
176
|
- lib/mongo_http_sync/mongoid_importer.rb
|
@@ -181,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
197
|
version: '0'
|
182
198
|
requirements: []
|
183
199
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
200
|
+
rubygems_version: 2.4.8
|
185
201
|
signing_key:
|
186
202
|
specification_version: 4
|
187
203
|
summary: MongoDB HTTP Synchronizer
|