erforscher 1.0.0.pre0 → 1.0.0.pre1

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: f81b9781cb741624366f9c8dfa9bf16aea4732ad
4
- data.tar.gz: dadbf7c5d3ff00598569d819ccb9ec119ca566e5
3
+ metadata.gz: ec74a3e7f15636cc457795d15f7f4bb4407d849a
4
+ data.tar.gz: e91330cd59d4dd4d8e52055f65590074b207227a
5
5
  SHA512:
6
- metadata.gz: cd64bb14f561e9407d536c35f1891f12d9f1b23defd37f6286c8b9e14076a4904cf995a84d216dbb644cf19044ff55d59b77c0416dad22d6354d6018d44b3d3a
7
- data.tar.gz: 2e5a3a567b4f3352f6ce2e8a61eb69f2111008790c6bb594209588c323c11e9eb77657a0d03d62ac9517553f7efe1392a9aa791b5b3b8ebd1828d0daa7cfafc7
6
+ metadata.gz: e8558702da92aebe8b5cfce3182695662e630cbc6c7d02d62d5e19365c4240b2f08d1e47037d947f465f3461ceac040e9658c5126e62ee075339095dbbd608ee
7
+ data.tar.gz: a6689f5c8736b24ef99e4756df726c0ecc57292043a58e338dae40a2dbe213dec7e0e84c645d42fcaa53fdbf3db0c32ccab804dc5cbcbecf585036b10800ccea
data/README.md CHANGED
@@ -1,15 +1,17 @@
1
1
  # Erforscher
2
2
 
3
- Erforscher is a poor man's service discovery tool that uses the AWS EC2 APIs to
4
- (optionally) filter instance from a configured set of `tags` and writes
5
- hostnames (derived from a configured `name` tag) and private IP address mappings
6
- to `/etc/hosts` (or any file of your choosing).
3
+ [![Build Status](https://travis-ci.org/mthssdrbrg/erforscher.svg?branch=master)](https://travis-ci.org/mthssdrbrg/erforscher)
4
+
5
+ Erforscher, German for "explorer", is a poor man's service discovery tool that
6
+ utilizes the AWS EC2 APIs to filter instances from a configured set of `tags`
7
+ and writes hostnames (derived from a configured `name` tag) and private IP address
8
+ mappings to `/etc/hosts` (or any file of your choosing).
7
9
 
8
10
  By default, Erforscher will look for a configuration file in the following
9
11
  places (and in the given order);
10
12
 
11
- * $HOME/.erforscher.yml
12
- * /etc/erforscher.yml
13
+ * `$HOME/.erforscher.yml`
14
+ * `/etc/erforscher.yml`
13
15
 
14
16
  As indicated below it's also possible to give the path to a configuration file
15
17
  using the `-c|--config` option, and in that case the given path will be used.
@@ -19,8 +21,12 @@ to merge settings if there should be files in the above mentioned places.
19
21
 
20
22
  ## Installation
21
23
 
22
- No, not currently, but it will be available as a `gem` and as `omnibus`
23
- packages, whenever it's ready for releasing out into the wild.
24
+ ```
25
+ gem install erforscher --pre
26
+ ```
27
+
28
+ It will be available as `omnibus` packages and most likely a `Chef` cookbook in
29
+ the near future.
24
30
 
25
31
  ## Usage
26
32
 
@@ -42,3 +48,19 @@ tags:
42
48
  - environment: 'production'
43
49
  service: 'database'
44
50
  ```
51
+
52
+ ## Copyright
53
+
54
+ Copyright :: 2014 Mathias Söderberg
55
+
56
+ Licensed under the Apache License, Version 2.0 (the "License");
57
+ you may not use this file except in compliance with the License.
58
+ You may obtain a copy of the License at
59
+
60
+ http://www.apache.org/licenses/LICENSE-2.0
61
+
62
+ Unless required by applicable law or agreed to in writing, software
63
+ distributed under the License is distributed on an "AS IS" BASIS,
64
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65
+ See the License for the specific language governing permissions and
66
+ limitations under the License.
@@ -13,6 +13,7 @@ module Erforscher
13
13
  2
14
14
  else
15
15
  Runner.run(config)
16
+ 0
16
17
  end
17
18
  rescue => e
18
19
  io.puts(%(#{e.message} (#{e.class.name})))
@@ -16,26 +16,30 @@ module Erforscher
16
16
  write_footer
17
17
  discard_old_entries
18
18
  copy_after_footer
19
+ nil
19
20
  end
20
21
 
21
- def switchero
22
+ def switch
22
23
  @new_file.close
24
+ @current_file.close
23
25
  @fileutils.mv(current_path, current_prev_path)
24
26
  @fileutils.mv(new_path, current_path)
27
+ @fileutils.chmod(0644, current_path)
28
+ nil
25
29
  end
26
30
 
27
31
  private
28
32
 
29
33
  def new_path
30
- @new_file.path
34
+ @new_path ||= @new_file.path
31
35
  end
32
36
 
33
37
  def current_path
34
- absolute_path(@current_file)
38
+ @current_path ||= absolute_path(@current_file)
35
39
  end
36
40
 
37
41
  def current_prev_path
38
- %(#{absolute_path(@current_file)}.prev)
42
+ @current_prev_path ||= %(#{absolute_path(@current_file)}.prev)
39
43
  end
40
44
 
41
45
  def absolute_path(f)
@@ -12,9 +12,9 @@ module Erforscher
12
12
 
13
13
  def run
14
14
  explored = explorer.discover(@config['tags'])
15
- entries = explored.sort.map { |ex| formatter.format(ex) }
16
- hostsfile.write(entries)
17
- hostsfile.switchero
15
+ entries = explored.map { |ex| formatter.format(ex) }
16
+ hostsfile.write(entries.sort)
17
+ hostsfile.switch
18
18
  end
19
19
 
20
20
  private
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Erforscher
4
- VERSION = '1.0.0.pre0'.freeze
4
+ VERSION = '1.0.0.pre1'.freeze
5
5
  end
@@ -100,7 +100,7 @@ module Erforscher
100
100
  end
101
101
  end
102
102
 
103
- describe '#switchero' do
103
+ describe '#switch' do
104
104
  let :new_file do
105
105
  Tempfile.new('new_file')
106
106
  end
@@ -118,13 +118,17 @@ module Erforscher
118
118
  end
119
119
 
120
120
  before do
121
- hostsfile.switchero
121
+ hostsfile.switch
122
122
  end
123
123
 
124
124
  it 'closes the new file' do
125
125
  new_file.should be_closed
126
126
  end
127
127
 
128
+ it 'closes the old file' do
129
+ current_file.should be_closed
130
+ end
131
+
128
132
  it 'backups the previous file' do
129
133
  fileutils.should have_received(:mv).with(absolute_current_path, %(#{absolute_current_path}.prev))
130
134
  end
@@ -132,6 +136,10 @@ module Erforscher
132
136
  it 'renames the new file' do
133
137
  fileutils.should have_received(:mv).with(absolute_new_path, absolute_current_path)
134
138
  end
139
+
140
+ it 'applies 0644 permissions on the new file' do
141
+ fileutils.should have_received(:chmod).with(0644, absolute_current_path)
142
+ end
135
143
  end
136
144
  end
137
145
  end
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.pre0
4
+ version: 1.0.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Söderberg