inventory-server 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa2af8dd9d05ac5a2cca7365f5fa6c4c7e8bd67e
4
- data.tar.gz: 89cfb258d7c89e880e36fe0cfae9bf88e0808f63
3
+ metadata.gz: ae35d4914717ef5ffb50b58df22542cf5bfaf5fe
4
+ data.tar.gz: 33b74f421d4c148469e2450dbc191a7287f98da8
5
5
  SHA512:
6
- metadata.gz: 1996bd0a71360d16ed1f51b4f2780032741d8205b97b0854b94f9691a05c741eccb491c7d4468571b5ebd3ef3dacd2d5da6997cee46a94e5a4cc962ee98799db
7
- data.tar.gz: 9c5427c47051827e4a4c9ef3250f3770359be8e282915cd85d61b8d1695cebd8d23241a25da23751b6f793ae2b9af8c68c476da7f1beef5e0be3ede4741b00dd
6
+ metadata.gz: cbc394386ceb1ea44fd4f511f5b5f8a8caa9e6432a0c6a4de69d1931f4ca7e616dbd2e231fa8bd6191a754982c4b1d23987db84d71cb3e448ee67d86c46153c6
7
+ data.tar.gz: fd4ca65d8efe8f2e7b9355c8fa03171507c330afcf87f690e039ab2c7aa13842f7e869b96ec42900164153eea135578779b1c73d9f9ca4f17ee868ea0e139bf1
data/Dockerfile CHANGED
@@ -27,4 +27,6 @@ RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
27
27
 
28
28
  WORKDIR /app
29
29
 
30
+ RUN cd /app && bundle install
31
+
30
32
  CMD ["/app/docker/unicorn/run-unicorn.sh"]
@@ -27,4 +27,6 @@ RUN cp /app/docker/unicorn/unicorn.conf /etc/nginx/conf.d/unicorn.conf && \
27
27
 
28
28
  WORKDIR /app
29
29
 
30
+ RUN cd /app && bundle install
31
+
30
32
  CMD ["/app/docker/unicorn/run-unicorn.sh"]
@@ -1,5 +1,5 @@
1
1
  module Inventory
2
2
  module Server
3
- VERSION = "0.0.7"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -28,10 +28,9 @@ module Inventory
28
28
  raise InventoryError.new 'id is missing' if id.nil? || id.empty?
29
29
  raise InventoryError.new 'facts is missing' if facts.nil?
30
30
 
31
- type = facts[@config[:type_key]] || @config[:type_default]
32
31
  version = facts[@config[:version_key]] || @config[:version_default]
33
32
 
34
- url = clean_string "#{@config[:es_host]}/#{@config[:es_index_prefix]}#{type}/#{version}/#{id}"
33
+ url = clean_string "#{@config[:es_host]}/#{@config[:es_index_prefix]}#{week_number}/#{version}/#{id}"
35
34
 
36
35
  begin
37
36
  response = RestClient.put(url, facts.to_json)
@@ -52,6 +51,10 @@ module Inventory
52
51
  def clean_string(str)
53
52
  str.gsub('.', '-').gsub(' ', '_').encode(Encoding.find('ASCII'), :invalid => :replace, :undef => :replace, :replace => '')
54
53
  end
54
+
55
+ def week_number
56
+ Time.now.strftime('%W')
57
+ end
55
58
  end
56
59
  end
57
60
  end
@@ -16,6 +16,10 @@ RSpec.describe Inventory::Server::Index, '#call' do
16
16
  WebMock.allow_net_connect!
17
17
  end
18
18
 
19
+ before() do
20
+ allow_any_instance_of(Inventory::Server::Index).to receive(:week_number).and_return 15
21
+ end
22
+
19
23
  context "without id" do
20
24
  env = {:facts => { :key => 'value' }}
21
25
  it "should throw an error" do
@@ -50,7 +54,7 @@ RSpec.describe Inventory::Server::Index, '#call' do
50
54
  env = {:id => 'MY_UUID', :facts => { :key => 'value' } }
51
55
 
52
56
  it "should throw an error" do
53
- stub_request(:put, "#{config[:es_host]}/inventory_facts/1-0-0/MY_UUID").to_return(:status => [500, "Internal Server Error"], :body => '{"OK": false}')
57
+ stub_request(:put, "#{config[:es_host]}/inventory_15/1-0-0/MY_UUID").to_return(:status => [500, "Internal Server Error"], :body => '{"OK": false}')
54
58
 
55
59
  expect {
56
60
  Inventory::Server::Index.new(noop, config).call(env)
@@ -61,7 +65,7 @@ RSpec.describe Inventory::Server::Index, '#call' do
61
65
  context "with an ElasticSearch Server" do
62
66
  it "should call ElasticSearch" do
63
67
  env = {:id => 'MY_UUID', :facts => { :key => 'value' } }
64
- stub = stub_request(:put, "#{config[:es_host]}/inventory_facts/1-0-0/MY_UUID").to_return(:body => '{"OK": true}')
68
+ stub = stub_request(:put, "#{config[:es_host]}/inventory_15/1-0-0/MY_UUID").to_return(:body => '{"OK": true}')
65
69
 
66
70
  result = Inventory::Server::Index.new(noop, config).call(env)
67
71
  expect(result).to eq({ :key => 'value' })
@@ -70,8 +74,8 @@ RSpec.describe Inventory::Server::Index, '#call' do
70
74
  end
71
75
 
72
76
  it "should change url depending on the type and version" do
73
- env = {:id => 'MY_UUID', :facts => { 'key' => 'value', 'type' => 'my_type', 'version' => 'my_version' } }
74
- stub = stub_request(:put, "#{config[:es_host]}/inventory_my_type/my_version/MY_UUID").to_return(:body => '{"OK": true}')
77
+ env = {:id => 'MY_UUID', :facts => { 'key' => 'value', 'version' => 'my_version' } }
78
+ stub = stub_request(:put, "#{config[:es_host]}/inventory_15/my_version/MY_UUID").to_return(:body => '{"OK": true}')
75
79
 
76
80
  Inventory::Server::Index.new(noop, config).call(env)
77
81
 
@@ -79,8 +83,8 @@ RSpec.describe Inventory::Server::Index, '#call' do
79
83
  end
80
84
 
81
85
  it "should change not pass dot, spaces and utf8 to elasticsearch" do
82
- env = {:id => 'MY_UUID', :facts => { 'key' => 'value', 'type' => 'my typé.1', 'version' => 'my vérsion.1' } }
83
- stub = stub_request(:put, "#{config[:es_host]}/inventory_my_typ-1/my_vrsion-1/MY_UUID").to_return(:body => '{"OK": true}')
86
+ env = {:id => 'MY_UUID', :facts => { 'key' => 'value', 'version' => 'my vérsion.1' } }
87
+ stub = stub_request(:put, "#{config[:es_host]}/inventory_15/my_vrsion-1/MY_UUID").to_return(:body => '{"OK": true}')
84
88
 
85
89
  Inventory::Server::Index.new(noop, config).call(env)
86
90
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inventory-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filirom1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: midi-smtp-server