erforscher 1.0.0.pre1 → 1.0.0.pre2

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: ec74a3e7f15636cc457795d15f7f4bb4407d849a
4
- data.tar.gz: e91330cd59d4dd4d8e52055f65590074b207227a
3
+ metadata.gz: cce5c98468b9a337ecb4b9eff30866bb0f24ad2a
4
+ data.tar.gz: 797747affc4a602020e7d5fbcb61cd7358c09c23
5
5
  SHA512:
6
- metadata.gz: e8558702da92aebe8b5cfce3182695662e630cbc6c7d02d62d5e19365c4240b2f08d1e47037d947f465f3461ceac040e9658c5126e62ee075339095dbbd608ee
7
- data.tar.gz: a6689f5c8736b24ef99e4756df726c0ecc57292043a58e338dae40a2dbe213dec7e0e84c645d42fcaa53fdbf3db0c32ccab804dc5cbcbecf585036b10800ccea
6
+ metadata.gz: bb4008443850b614d681db4a8746221afd39462810b099445fd80eafd046cfc94fc1c8e0a3617b542e093422c21dda150bb9548f35da3cf4b3d10632db49acb5
7
+ data.tar.gz: ce000ac689f404e9129035f3b2f81be9de7e9c651384a54cf74483d85cd135133d31a435b65ba662f6812b4abcf37036df74ebbf4b25414dcf09caa588296e26
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Erforscher
2
2
 
3
3
  [![Build Status](https://travis-ci.org/mthssdrbrg/erforscher.svg?branch=master)](https://travis-ci.org/mthssdrbrg/erforscher)
4
+ [![Gem Version](https://badge.fury.io/rb/erforscher.svg)](http://badge.fury.io/rb/erforscher)
4
5
 
5
6
  Erforscher, German for "explorer", is a poor man's service discovery tool that
6
7
  utilizes the AWS EC2 APIs to filter instances from a configured set of `tags`
@@ -31,7 +32,8 @@ the near future.
31
32
  ## Usage
32
33
 
33
34
  ```bash
34
- erforscher --help
35
+ erforscher -h|--help
36
+ erforscher -v|--version
35
37
  erforscher -T|--tags <K1=V1,K2=V2>
36
38
  erforscher -N|--name <TAG>
37
39
  erforscher -c|--config <PATH>
data/lib/erforscher.rb CHANGED
@@ -18,3 +18,4 @@ require 'erforscher/formatter'
18
18
  require 'erforscher/hostsfile'
19
19
  require 'erforscher/instances'
20
20
  require 'erforscher/runner'
21
+ require 'erforscher/version'
@@ -11,10 +11,12 @@ module Erforscher
11
11
  if config['print_usage']
12
12
  io.puts(@parser)
13
13
  2
14
+ elsif config['print_version']
15
+ io.puts(%(erforscher v#{Erforscher::VERSION}))
14
16
  else
15
17
  Runner.run(config)
16
- 0
17
18
  end
19
+ 0
18
20
  rescue => e
19
21
  io.puts(%(#{e.message} (#{e.class.name})))
20
22
  io.puts(@parser)
@@ -37,6 +39,10 @@ module Erforscher
37
39
  cli['name_tag'] = name_tag
38
40
  end
39
41
 
42
+ parser.on('-v', '--version', 'Display current version') do
43
+ cli['print_version'] = true
44
+ end
45
+
40
46
  parser.on('-h', '--help', 'You\'re looking at it') do
41
47
  cli['print_usage'] = true
42
48
  end
@@ -23,7 +23,7 @@ module Erforscher
23
23
 
24
24
  def find_name(tags)
25
25
  tag = tags.find { |tag| tag[:key] == @name_tag }
26
- tag.value if tag
26
+ tag[:value] if tag
27
27
  end
28
28
 
29
29
  def strip_domain(name)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Erforscher
4
- VERSION = '1.0.0.pre1'.freeze
4
+ VERSION = '1.0.0.pre2'.freeze
5
5
  end
@@ -49,20 +49,22 @@ describe 'bin/erforscher' do
49
49
  end
50
50
 
51
51
  after do
52
+ hostsfile.close
52
53
  hostsfile.delete
54
+ config_file.close
53
55
  config_file.delete
54
56
  end
55
57
 
56
58
  context 'when given --help or -h' do
57
- it 'returns 2 and prints usage' do
59
+ it 'returns 0 and prints usage' do
58
60
  code = Erforscher::Cli.run(%w[-h], io)
59
- expect(code).to eq(2)
61
+ expect(code).to eq(0)
60
62
  expect(io.string).to include 'Usage:'
61
63
 
62
64
  io.rewind
63
65
 
64
66
  code = Erforscher::Cli.run(%w[--help], io)
65
- expect(code).to eq(2)
67
+ expect(code).to eq(0)
66
68
  expect(io.string).to include 'Usage:'
67
69
  end
68
70
  end
@@ -138,4 +140,18 @@ describe 'bin/erforscher' do
138
140
  expect(new_hostsfile).to include("instance-004\t10.0.0.4")
139
141
  end
140
142
  end
143
+
144
+ context 'when given -v or --version' do
145
+ it 'returns 0 and prints current version' do
146
+ code = Erforscher::Cli.run(%w[-v], io)
147
+ expect(code).to eq(0)
148
+ expect(io.string).to match(/^erforscher v\d+\.\d+\.\d+/)
149
+
150
+ io.rewind
151
+
152
+ code = Erforscher::Cli.run(%w[--version], io)
153
+ expect(code).to eq(0)
154
+ expect(io.string).to match(/^erforscher v\d+\.\d+\.\d+/)
155
+ end
156
+ end
141
157
  end
@@ -15,7 +15,7 @@ module Erforscher
15
15
  let :instance do
16
16
  OpenStruct.new({
17
17
  tags: [
18
- OpenStruct.new({key: 'Name', value: 'hello-world-001.domain.com'})
18
+ {key: 'Name', value: 'hello-world-001.domain.com'}
19
19
  ],
20
20
  private_ip_address: '10.0.0.1',
21
21
  private_dns_name: 'private-dns-name',
@@ -2,12 +2,7 @@
2
2
 
3
3
  class FakeEc2
4
4
  def initialize(instances)
5
- @instances = instances.map do |instance|
6
- tags = instance.delete(:tags)
7
- tags = tags.map { |tag| OpenStruct.new(tag) }
8
- instance[:tags] = tags
9
- OpenStruct.new(instance)
10
- end
5
+ @instances = instances.map { |instance| OpenStruct.new(instance) }
11
6
  end
12
7
 
13
8
  def describe_instances(opts={})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erforscher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre1
4
+ version: 1.0.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Söderberg
@@ -61,9 +61,9 @@ require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - "~>"
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
- version: '2.0'
66
+ version: 1.9.3
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">"