wlw_seeds_client 0.0.2
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 +7 -0
- data/.gitignore +3 -0
- data/.gitlab-ci.yml +26 -0
- data/.rspec +1 -0
- data/.rubocop.yml +36 -0
- data/.rubocop_custom.yml +27 -0
- data/.ruby-version +1 -0
- data/.slim-lint.yml +38 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +12 -0
- data/README.md +48 -0
- data/Rakefile +15 -0
- data/lib/tasks/seed.rake +6 -0
- data/lib/wlw_seeds_client/image.rb +63 -0
- data/lib/wlw_seeds_client/model.rb +22 -0
- data/lib/wlw_seeds_client/version.rb +5 -0
- data/lib/wlw_seeds_client/wlw_seeds_client.rb +54 -0
- data/lib/wlw_seeds_client/wlw_sneakers_overwrite.rb +9 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/test_model.rb +23 -0
- data/spec/wlw_seeds_client/image_spec.rb +51 -0
- data/spec/wlw_seeds_client/model_spec.rb +54 -0
- data/spec/wlw_seeds_client/wlw_seeds_client_spec.rb +65 -0
- data/wlw_seeds_client.gemspec +26 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e61b0d7e66137f470feaa2fbfe4f25bb7b70bc2b
|
4
|
+
data.tar.gz: 9d0b95587e5b471ed71619d185721656a6a4bd3b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b139be4b0081e9084eb8ba09b2b175b7f8ab89db16c36c79af48f05413ce9ac30964bf3648b87914dce7f0c86eec8b698e930f0ef56700a4d622a52d444553c3
|
7
|
+
data.tar.gz: 2d92cd2ab913f6228f3c87d1b82f13271121276cc8dc42735278103af31239ea3eae42ac4a0c9880f359970b7d1c122306e9570177427f2a60a2500e3f4eed53
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
stages:
|
2
|
+
- test
|
3
|
+
|
4
|
+
image: docker.webdev.wlw.de/wlw_ruby:2.4.1
|
5
|
+
|
6
|
+
variables:
|
7
|
+
BUNDLE_DIR: vendor/bundle
|
8
|
+
|
9
|
+
cache:
|
10
|
+
key: "${CI_PROJECT_NAME}"
|
11
|
+
paths:
|
12
|
+
- "${BUNDLE_DIR}"
|
13
|
+
|
14
|
+
before_script:
|
15
|
+
- bundle config --local path "${BUNDLE_DIR}"
|
16
|
+
- bundle install
|
17
|
+
|
18
|
+
rspec:
|
19
|
+
stage: test
|
20
|
+
script:
|
21
|
+
- bundle exec rspec
|
22
|
+
|
23
|
+
linter:
|
24
|
+
stage: test
|
25
|
+
script:
|
26
|
+
- bundle exec rake wlw_code_conventions:ruby
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
require: rubocop-rspec
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- db/**/*
|
7
|
+
- tmp/**/*
|
8
|
+
- vendor/**/*
|
9
|
+
- wlw_seeds_client.gemspec
|
10
|
+
Lint/AmbiguousBlockAssociation:
|
11
|
+
Exclude:
|
12
|
+
- spec/**/*
|
13
|
+
Rails:
|
14
|
+
Enabled: false
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Enabled: false
|
17
|
+
Documentation:
|
18
|
+
Enabled: false
|
19
|
+
Metrics/LineLength:
|
20
|
+
Max: 150
|
21
|
+
RSpec/DescribeClass:
|
22
|
+
Exclude:
|
23
|
+
- spec/views/**/*
|
24
|
+
- spec/requests/**/*
|
25
|
+
- spec/routing/**/*
|
26
|
+
- spec/**/*examples.rb
|
27
|
+
Metrics/ClassLength:
|
28
|
+
Max: 300
|
29
|
+
Lint/UselessAssignment:
|
30
|
+
Enabled: false
|
31
|
+
Style/DateTime:
|
32
|
+
Enabled: false
|
33
|
+
Style/MethodName:
|
34
|
+
Enabled: false
|
35
|
+
Style/VariableNumber:
|
36
|
+
Enabled: false
|
data/.rubocop_custom.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
require: rubocop-rspec
|
3
|
+
AllCops:
|
4
|
+
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- wlw_seeds_client.gemspec
|
7
|
+
Lint/AmbiguousBlockAssociation:
|
8
|
+
Exclude:
|
9
|
+
- spec/**/*
|
10
|
+
Rails:
|
11
|
+
Enabled: false
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
Documentation:
|
15
|
+
Enabled: false
|
16
|
+
Metrics/LineLength:
|
17
|
+
Max: 150
|
18
|
+
Metrics/ClassLength:
|
19
|
+
Max: 300
|
20
|
+
Lint/UselessAssignment:
|
21
|
+
Enabled: false
|
22
|
+
Style/DateTime:
|
23
|
+
Enabled: false
|
24
|
+
Style/MethodName:
|
25
|
+
Enabled: false
|
26
|
+
Style/VariableNumber:
|
27
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/.slim-lint.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
linters:
|
3
|
+
LineLength:
|
4
|
+
max: 150
|
5
|
+
RuboCop:
|
6
|
+
ignored_cops:
|
7
|
+
- Layout/AlignParameters
|
8
|
+
- Layout/IndentationWidth
|
9
|
+
- Layout/TrailingBlankLines
|
10
|
+
- Layout/AlignHash
|
11
|
+
- Layout/FirstParameterIndentation
|
12
|
+
- Layout/IndentArray
|
13
|
+
- Layout/IndentationConsistency
|
14
|
+
- Layout/IndentHash
|
15
|
+
- Layout/MultilineOperationIndentation
|
16
|
+
- Layout/TrailingWhitespace
|
17
|
+
- Lint/BlockAlignment
|
18
|
+
- Lint/EndAlignment
|
19
|
+
- Lint/Void
|
20
|
+
- Metrics/BlockLength
|
21
|
+
- Metrics/LineLength
|
22
|
+
- Style/AlignHash
|
23
|
+
- Style/AlignParameters
|
24
|
+
- Style/BlockNesting
|
25
|
+
- Style/FileName
|
26
|
+
- Style/FirstParameterIndentation
|
27
|
+
- Style/FrozenStringLiteralComment
|
28
|
+
- Style/IdenticalConditionalBranches
|
29
|
+
- Style/IfUnlessModifier
|
30
|
+
- Style/IndentArray
|
31
|
+
- Style/IndentationConsistency
|
32
|
+
- Style/IndentationWidth
|
33
|
+
- Style/IndentHash
|
34
|
+
- Style/MultilineOperationIndentation
|
35
|
+
- Style/Next
|
36
|
+
- Style/TrailingBlankLines
|
37
|
+
- Style/TrailingWhitespace
|
38
|
+
- Style/WhileUntilModifier
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'http://gems.webdev.wlw.de'
|
4
|
+
ruby File.read(File.expand_path('.ruby-version', File.dirname(__FILE__))).chomp
|
5
|
+
|
6
|
+
group :test, :development do
|
7
|
+
gem 'rubocop', require: false
|
8
|
+
gem 'rubocop-rspec', require: false
|
9
|
+
gem 'wlw_sneakers'
|
10
|
+
end
|
11
|
+
|
12
|
+
gemspec
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
Gem: WlwSeedsClient
|
2
|
+
===================
|
3
|
+
|
4
|
+
This gem lets you seed remote (from webdevs/wlw_seeds) seed data.
|
5
|
+
|
6
|
+
Read sth. about the main intent of seeding data between apps:
|
7
|
+
[Seeding Data](https://gitlab.webdev.wlw.de/webdevs/knowledge/blob/master/seeds.md)
|
8
|
+
|
9
|
+
|
10
|
+
Usage
|
11
|
+
=====
|
12
|
+
|
13
|
+
Add dependency
|
14
|
+
--------------
|
15
|
+
|
16
|
+
Add this gem to your Gemfile
|
17
|
+
|
18
|
+
`gem wlw_seeds_client`
|
19
|
+
|
20
|
+
Seed data
|
21
|
+
---------
|
22
|
+
|
23
|
+
Example for usage with product_categories data:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# To requesting seeding data for one model you can do:
|
27
|
+
WlwSeedsClient.all('product_category').all.each do |product_category|
|
28
|
+
|
29
|
+
# now you have access to all seeding data with:
|
30
|
+
puts product_category.data
|
31
|
+
|
32
|
+
# To get all images for one model you can do this:
|
33
|
+
product_category.images.each do |image|
|
34
|
+
|
35
|
+
# here you have direct access to data or others methods like:
|
36
|
+
# 'content', 'extension', 'type', 'image_url'
|
37
|
+
puts image.data
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Convenience functionality
|
44
|
+
-------------------------
|
45
|
+
|
46
|
+
It is often necessary to disable communication to queues. You can do this easily with:
|
47
|
+
|
48
|
+
`WlwSeedsClient.silence_wlw_sneakers`
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
require 'wlw_code_conventions/tasks'
|
7
|
+
defined?(WlwCodeConventions) && WlwCodeConventions.configure do |config|
|
8
|
+
config.rubocop = File.expand_path('../.rubocop_custom.yml', __FILE__)
|
9
|
+
config.default_task = true
|
10
|
+
end
|
11
|
+
|
12
|
+
RSpec::Core::RakeTask.new(:spec)
|
13
|
+
Rake::Task[:default].prerequisites << :spec
|
14
|
+
|
15
|
+
Dir.glob('lib/tasks/*.rake').each { |r| load r }
|
data/lib/tasks/seed.rake
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module WlwSeedsClient
|
4
|
+
class Image
|
5
|
+
attr_accessor :model, :branch, :data
|
6
|
+
|
7
|
+
REMOTE_BASE_PATH = 'https://gitlab.webdev.wlw.de/<namespace>/<project>/raw/<ref>/lib/wlw_seeds/images/<path_to_file>'
|
8
|
+
MIME_TYPE_MAP = {
|
9
|
+
'image/jpeg' => 'jpg',
|
10
|
+
'image/png' => 'png',
|
11
|
+
'image/gif' => 'gif'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
def initialize(model, branch = 'master', data = {})
|
15
|
+
@model = model
|
16
|
+
@branch = branch
|
17
|
+
@data = data
|
18
|
+
end
|
19
|
+
|
20
|
+
def image_url
|
21
|
+
replaces = {
|
22
|
+
'<namespace>' => 'webdevs',
|
23
|
+
'<project>' => 'wlw_seeds',
|
24
|
+
'<ref>' => @branch,
|
25
|
+
'<path_to_file>' => @data[:name]
|
26
|
+
}
|
27
|
+
path = REMOTE_BASE_PATH.dup
|
28
|
+
path.gsub(Regexp.union(replaces.keys), replaces)
|
29
|
+
end
|
30
|
+
|
31
|
+
def id
|
32
|
+
@data[:id].to_s.to_i
|
33
|
+
end
|
34
|
+
|
35
|
+
def content
|
36
|
+
response = WlwSeedsClient.response_with_redirect(image_url)
|
37
|
+
::Base64.encode64(response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def original
|
41
|
+
{
|
42
|
+
content: content,
|
43
|
+
'mime-type' => type
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
def type
|
48
|
+
MIME_TYPE_MAP.key(extension)
|
49
|
+
end
|
50
|
+
|
51
|
+
def extension
|
52
|
+
File.extname(image_url).gsub(/^\./, '')
|
53
|
+
end
|
54
|
+
|
55
|
+
def width
|
56
|
+
0
|
57
|
+
end
|
58
|
+
|
59
|
+
def height
|
60
|
+
0
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module WlwSeedsClient
|
6
|
+
class Model
|
7
|
+
attr_accessor :model, :branch, :data, :images
|
8
|
+
|
9
|
+
def initialize(model, branch, data)
|
10
|
+
@data = data
|
11
|
+
@images = []
|
12
|
+
return unless @data.key?(:images)
|
13
|
+
@data[:images].collect do |key, value|
|
14
|
+
@images << WlwSeedsClient::Image.new(model, branch, id: key, name: value, ref_id: data[:id])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def id
|
19
|
+
@data[:id]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/hash_with_indifferent_access'
|
5
|
+
require 'bundler'
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module WlwSeedsClient
|
9
|
+
REMOTE_BASE_PATH = 'https://gitlab.webdev.wlw.de/<namespace>/<project>/-/jobs/artifacts/<ref>/raw/<path_to_file>?job=<job_name>'
|
10
|
+
|
11
|
+
def self.data_url(model, branch)
|
12
|
+
replaces = {
|
13
|
+
'<namespace>' => 'webdevs',
|
14
|
+
'<project>' => 'wlw_seeds',
|
15
|
+
'<ref>' => branch,
|
16
|
+
'<path_to_file>' => "seed_data/#{model}.json",
|
17
|
+
'<job_name>' => 'generate'
|
18
|
+
}
|
19
|
+
path = REMOTE_BASE_PATH.dup
|
20
|
+
path.gsub(Regexp.union(replaces.keys), replaces)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.all(model, branch = 'master')
|
24
|
+
json_data = WlwSeedsClient.json_response(WlwSeedsClient.data_url(model, branch))
|
25
|
+
json_data.collect { |model_data| WlwSeedsClient::Model.new(model, branch, model_data) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.response_with_redirect(url)
|
29
|
+
response = Net::HTTP.get_response(URI(url))
|
30
|
+
if response.code.to_i == 301 || response.code.to_i == 302
|
31
|
+
response = Net::HTTP.get_response(URI(response['Location']))
|
32
|
+
end
|
33
|
+
response
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.json_response(url)
|
37
|
+
response = WlwSeedsClient.response_with_redirect(url)
|
38
|
+
begin
|
39
|
+
data = JSON.parse(response.body)
|
40
|
+
return data.collect(&:deep_symbolize_keys)
|
41
|
+
rescue JSON::ParserError
|
42
|
+
return []
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.silence_wlw_sneakers
|
47
|
+
require 'wlw_sneakers'
|
48
|
+
require File.join(File.dirname(__FILE__), 'wlw_sneakers_overwrite')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# base classes
|
53
|
+
require 'wlw_seeds_client/model'
|
54
|
+
require 'wlw_seeds_client/image'
|
data/spec/spec_helper.rb
ADDED
data/spec/test_model.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class TestModel
|
4
|
+
@data = {}
|
5
|
+
attr_reader :data
|
6
|
+
|
7
|
+
def initialize(data_init = {})
|
8
|
+
@data = data_init
|
9
|
+
end
|
10
|
+
|
11
|
+
def method_missing(name, *args) # rubocop:disable Style/MethodMissing, Lint/UnusedMethodArgument
|
12
|
+
return @data[name.to_sym] if @data[name.to_sym]
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def save!(args)
|
17
|
+
args
|
18
|
+
end
|
19
|
+
|
20
|
+
def respond_to_missing?
|
21
|
+
false
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
describe WlwSeedsClient::Image do
|
6
|
+
let(:model_name) { 'model_name' }
|
7
|
+
let(:branch_name) { 'branch_name' }
|
8
|
+
|
9
|
+
let(:ref_id) { 12_345 }
|
10
|
+
let(:image_id) { 123_451 }
|
11
|
+
let(:image_name) { 'file_name.jpg' }
|
12
|
+
let(:image_body) { 'image_body' }
|
13
|
+
|
14
|
+
describe 'receives and returns model basics' do
|
15
|
+
subject(:model) { described_class.new(model_name, branch_name, id: image_id, name: image_name, ref_id: ref_id) }
|
16
|
+
|
17
|
+
before do
|
18
|
+
response = instance_double('response', code: 200, body: image_body)
|
19
|
+
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns the id' do
|
23
|
+
expect(model.id).to eq(image_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'returns the id from data' do
|
27
|
+
expect(model.data[:id]).to eq(image_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the ref_id from data' do
|
31
|
+
expect(model.data[:ref_id]).to eq(ref_id)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'returns the image url' do
|
35
|
+
url = "https://gitlab.webdev.wlw.de/webdevs/wlw_seeds/raw/#{branch_name}/lib/wlw_seeds/images/#{image_name}"
|
36
|
+
expect(model.image_url).to eq(url)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns file type' do
|
40
|
+
expect(model.type).to eq('image/jpeg')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns file extension' do
|
44
|
+
expect(model.extension).to eq('jpg')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns file content' do
|
48
|
+
expect(model.content).to eq(::Base64.encode64(image_body))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
describe WlwSeedsClient::Model do
|
6
|
+
let(:model_name) { 'model_name' }
|
7
|
+
let(:branch_name) { 'branch_name' }
|
8
|
+
|
9
|
+
describe 'receiving and parsing of correct data' do
|
10
|
+
before do
|
11
|
+
response = instance_double('response', code: 200, body: '[{
|
12
|
+
"images": {
|
13
|
+
"1231": "model_name/123.jpg"
|
14
|
+
},
|
15
|
+
"id": 123,
|
16
|
+
"name": {
|
17
|
+
"de": "Deutsch",
|
18
|
+
"en": "Englisch"
|
19
|
+
}
|
20
|
+
}]')
|
21
|
+
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
subject(:model) { WlwSeedsClient.all(model_name, branch_name).first }
|
25
|
+
|
26
|
+
it 'first id of data is filled' do
|
27
|
+
expect(model.data[:id]).to eq(123)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns id from data' do
|
31
|
+
expect(model.id).to eq(123)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'nested keys of data is filled' do
|
35
|
+
expect(model.data[:name][:de]).to eq('Deutsch')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'return image size of model' do
|
39
|
+
expect(model.images.size).to eq(1)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'return image id of model function' do
|
43
|
+
expect(model.images.first.id).to eq(1231)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'return image id of model data' do
|
47
|
+
expect(model.images.first.data[:id]).to eq(:'1231')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'return image data of model' do
|
51
|
+
expect(model.images.first.data[:ref_id]).to eq(123)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe WlwSeedsClient do
|
4
|
+
let(:model_name) { 'model_name' }
|
5
|
+
let(:branch_name) { 'branch_name' }
|
6
|
+
|
7
|
+
describe 'public methods' do
|
8
|
+
it 'returns the model url' do
|
9
|
+
url = "https://gitlab.webdev.wlw.de/webdevs/wlw_seeds/-/jobs/artifacts/#{branch_name}/raw/seed_data/#{model_name}.json?job=generate"
|
10
|
+
expect(described_class.data_url(model_name, branch_name)).to eq(url)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'receiving and parsing of correct data' do
|
15
|
+
before do
|
16
|
+
response = instance_double('response', code: 200, body: '[{
|
17
|
+
"images": {
|
18
|
+
"1231": "model_name/123.jpg"
|
19
|
+
},
|
20
|
+
"id": 123,
|
21
|
+
"name": {
|
22
|
+
"de": "Deutsch",
|
23
|
+
"en": "Englisch"
|
24
|
+
}
|
25
|
+
}]')
|
26
|
+
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'get size of responze' do
|
30
|
+
expect(described_class.all(model_name, branch_name).size).to eq(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'first id of data is filled' do
|
34
|
+
expect(described_class.all(model_name, branch_name).first.data[:id]).to eq(123)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'returns id from data' do
|
38
|
+
expect(described_class.all(model_name, branch_name).first.id).to eq(123)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns all data' do
|
42
|
+
expect(described_class.all(model_name, branch_name).collect(&:id)).to eq([123])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe 'helper functions for disabling queue publishing' do
|
47
|
+
it 'pushes to queue' do
|
48
|
+
expect { WlwSneakers::Publisher.publish('message', routing_key: 'routing.key') }.to raise_error(NoMethodError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'pushes json to queue' do
|
52
|
+
expect { WlwSneakers::JsonPublisher.publish({ id: 1 }, routing_key: 'routing.key') }.to raise_error(NoMethodError)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'monkey-patched pushing to queue' do
|
56
|
+
described_class.silence_wlw_sneakers
|
57
|
+
expect(WlwSneakers::Publisher.publish('message', routing_key: 'routing.key')).to be(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'monkey-patched pushing json to queue' do
|
61
|
+
described_class.silence_wlw_sneakers
|
62
|
+
expect(WlwSneakers::JsonPublisher.publish({ id: 1 }, routing_key: 'routing.key')).to be(true)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'wlw_seeds_client/version'
|
7
|
+
require 'date'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.author = 'Wer liefert Was'
|
11
|
+
spec.files = `git ls-files`.split($RS)
|
12
|
+
spec.name = 'wlw_seeds_client'
|
13
|
+
spec.platform = Gem::Platform::RUBY
|
14
|
+
spec.require_paths = ['lib']
|
15
|
+
spec.summary = 'remote seeding for wlw projects.'
|
16
|
+
spec.version = WlwSeedsClient::VERSION
|
17
|
+
spec.date = Date.today.to_s
|
18
|
+
spec.test_files = spec.files.grep('spec')
|
19
|
+
spec.add_development_dependency 'pry'
|
20
|
+
spec.add_development_dependency 'rspec'
|
21
|
+
spec.add_development_dependency 'wlw_code_conventions'
|
22
|
+
spec.add_runtime_dependency 'wlw_sluggy'
|
23
|
+
spec.add_runtime_dependency 'virtus'
|
24
|
+
spec.add_runtime_dependency 'activesupport'
|
25
|
+
spec.add_runtime_dependency 'bundler'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wlw_seeds_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wer liefert Was
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: wlw_code_conventions
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: wlw_sluggy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: virtus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: activesupport
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- ".gitignore"
|
118
|
+
- ".gitlab-ci.yml"
|
119
|
+
- ".rspec"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".rubocop_custom.yml"
|
122
|
+
- ".ruby-version"
|
123
|
+
- ".slim-lint.yml"
|
124
|
+
- CHANGELOG.md
|
125
|
+
- Gemfile
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- lib/tasks/seed.rake
|
129
|
+
- lib/wlw_seeds_client/image.rb
|
130
|
+
- lib/wlw_seeds_client/model.rb
|
131
|
+
- lib/wlw_seeds_client/version.rb
|
132
|
+
- lib/wlw_seeds_client/wlw_seeds_client.rb
|
133
|
+
- lib/wlw_seeds_client/wlw_sneakers_overwrite.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/test_model.rb
|
136
|
+
- spec/wlw_seeds_client/image_spec.rb
|
137
|
+
- spec/wlw_seeds_client/model_spec.rb
|
138
|
+
- spec/wlw_seeds_client/wlw_seeds_client_spec.rb
|
139
|
+
- wlw_seeds_client.gemspec
|
140
|
+
homepage:
|
141
|
+
licenses: []
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.6.11
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: remote seeding for wlw projects.
|
163
|
+
test_files: []
|