akaer 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ script: bundle exec rake spec:coverage
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --exclude lib/devdnsd/patches/.+ --exclude utils/ -m markdown
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akaer (0.1.0)
5
- cowtech-extensions (~> 2.1.0)
6
- cowtech-lib (~> 1.9.8.0)
4
+ akaer (0.3.0)
5
+ cowtech-extensions (~> 2.7.0)
6
+ cowtech-lib (~> 2.0.0)
7
7
  hashie (~> 1.2.0)
8
8
  rainbow (~> 1.1.0)
9
9
 
@@ -27,27 +27,29 @@ GEM
27
27
  i18n (~> 0.6)
28
28
  multi_json (~> 1.0)
29
29
  builder (3.0.0)
30
- cowtech-extensions (2.1.0)
30
+ coderay (1.0.7)
31
+ cowtech-extensions (2.7.1)
31
32
  actionpack (~> 3.0)
32
- tzinfo (~> 0.3.33)
33
- cowtech-lib (1.9.8.1)
34
- jeweler
33
+ json (~> 1.7.0)
34
+ tzinfo (~> 0.3.0)
35
+ cowtech-lib (2.0.2)
35
36
  open4
36
37
  diff-lcs (1.1.3)
37
38
  erubis (2.7.0)
38
- git (1.2.5)
39
+ github-markup (0.7.2)
39
40
  hashie (1.2.0)
40
41
  hike (1.2.1)
41
42
  i18n (0.6.0)
42
- jeweler (1.8.4)
43
- bundler (~> 1.0)
44
- git (>= 1.2.5)
45
- rake
46
- rdoc
47
43
  journey (1.0.4)
48
44
  json (1.7.3)
45
+ method_source (0.8)
49
46
  multi_json (1.3.6)
47
+ net-dns (0.7.1)
50
48
  open4 (1.3.0)
49
+ pry (0.9.10)
50
+ coderay (~> 1.0.5)
51
+ method_source (~> 0.8)
52
+ slop (~> 3.3.1)
51
53
  rack (1.4.1)
52
54
  rack-cache (1.2)
53
55
  rack (>= 0.4)
@@ -55,26 +57,38 @@ GEM
55
57
  rack (>= 1.0)
56
58
  rainbow (1.1.4)
57
59
  rake (0.9.2.2)
58
- rdoc (3.12)
59
- json (~> 1.4)
60
- rspec (2.10.0)
61
- rspec-core (~> 2.10.0)
62
- rspec-expectations (~> 2.10.0)
63
- rspec-mocks (~> 2.10.0)
64
- rspec-core (2.10.1)
65
- rspec-expectations (2.10.0)
60
+ redcarpet (2.1.1)
61
+ rspec (2.11.0)
62
+ rspec-core (~> 2.11.0)
63
+ rspec-expectations (~> 2.11.0)
64
+ rspec-mocks (~> 2.11.0)
65
+ rspec-core (2.11.0)
66
+ rspec-expectations (2.11.1)
66
67
  diff-lcs (~> 1.1.3)
67
- rspec-mocks (2.10.1)
68
+ rspec-mocks (2.11.0)
69
+ simplecov (0.6.4)
70
+ multi_json (~> 1.0)
71
+ simplecov-html (~> 0.5.3)
72
+ simplecov-html (0.5.3)
73
+ slop (3.3.2)
68
74
  sprockets (2.1.3)
69
75
  hike (~> 1.2)
70
76
  rack (~> 1.0)
71
77
  tilt (~> 1.1, != 1.3.0)
72
78
  tilt (1.3.3)
73
79
  tzinfo (0.3.33)
80
+ yard (0.8.2.1)
74
81
 
75
82
  PLATFORMS
76
83
  ruby
77
84
 
78
85
  DEPENDENCIES
79
86
  akaer!
80
- rspec (~> 2.10.0)
87
+ github-markup (~> 0.7.0)
88
+ net-dns (~> 0.7.0)
89
+ pry (~> 0.9.10)
90
+ rake (~> 0.9.0)
91
+ redcarpet (~> 2.1.0)
92
+ rspec (~> 2.11.0)
93
+ simplecov (~> 0.6.0)
94
+ yard (~> 0.8.0)
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # akaer
1
+ # akaer
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ShogunPanda/akaer.png?branch=master)](http://travis-ci.org/ShogunPanda/akaer)
4
+ [![Dependency Status](https://gemnasium.com/ShogunPanda/akaer.png?travis)](https://gemnasium.com/ShogunPanda/akaer)
2
5
 
3
6
  A small utility to add aliases to network interfaces.
4
7
  http://github.com/ShogunPanda/akaer
data/Rakefile CHANGED
@@ -9,7 +9,10 @@ require "rspec/core/rake_task"
9
9
 
10
10
  RSpec::Core::RakeTask.new("spec")
11
11
 
12
- desc "Run all specs with rcov"
13
- RSpec::Core::RakeTask.new("spec:coverage") do |t|
14
- t.rcov_opts = %q[--exclude "spec"]
12
+ namespace :spec do
13
+ desc "Run all specs with coverage"
14
+ task :coverage do
15
+ ENV["AKAER_COVERAGE"] = "TRUE"
16
+ Rake::Task["spec"].invoke
17
+ end
15
18
  end
data/akaer.gemspec CHANGED
@@ -21,12 +21,19 @@ Gem::Specification.new do |gem|
21
21
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
22
  gem.require_paths = ["lib"]
23
23
 
24
- gem.add_dependency("cowtech-extensions", "~> 2.1.0")
25
- gem.add_dependency("cowtech-lib", "~> 1.9.8.0")
24
+ gem.add_dependency("cowtech-extensions", "~> 2.7.0")
25
+ gem.add_dependency("cowtech-lib", "~> 2.0.0")
26
26
  gem.add_dependency("hashie", "~> 1.2.0")
27
27
  gem.add_dependency("rainbow", "~> 1.1.0")
28
28
 
29
- gem.add_development_dependency("rspec", "~> 2.10.0")
29
+ gem.add_development_dependency("rspec", "~> 2.11.0")
30
+ gem.add_development_dependency("rake", "~> 0.9.0")
31
+ gem.add_development_dependency("simplecov", "~> 0.6.0")
32
+ gem.add_development_dependency("pry", "~> 0.9.10")
33
+ gem.add_development_dependency("net-dns", "~> 0.7.0")
34
+ gem.add_development_dependency("yard", "~> 0.8.0")
35
+ gem.add_development_dependency("redcarpet", "~> 2.1.0")
36
+ gem.add_development_dependency("github-markup", "~> 0.7.0")
30
37
  end
31
38
 
32
39
 
@@ -20,7 +20,6 @@ module Akaer
20
20
  end
21
21
 
22
22
  def initialize
23
- Akaer::Logger.start_time = Time.now
24
23
  super(:args => {:name => "Interface aliases", :version => 1.0, :description => "A small utility to add aliases to network interfaces.", :usage => "Usage: #{ARGV[0]} [OPTIONS] [add|remove]"})
25
24
  end
26
25
 
@@ -38,18 +37,6 @@ module Akaer
38
37
  ]
39
38
  end
40
39
 
41
- def create_logger(file, level = Logger::INFO)
42
- file = case file
43
- when "STDOUT" then $stdout
44
- when "STDERR" then $stderr
45
- else file
46
- end
47
-
48
- rv = Akaer::Logger.new(file)
49
- rv.level = level.to_i
50
- rv
51
- end
52
-
53
40
  def execute_command(interface, action, ip, prefix = "")
54
41
  prefix += " " if !prefix.blank?
55
42
  @logger.info("#{prefix}#{(action == "add" ? "Adding" : "Removing").bright} alias #{ip.bright} #{action == "add" ? "to" : "from"} interface #{interface.bright}.")
@@ -57,7 +44,7 @@ module Akaer
57
44
  end
58
45
 
59
46
  def run
60
- @logger = self.create_logger(@options_parser["log-file"], @options_parser["log-level"])
47
+ @logger = Akaer::Logger.create(@options_parser["log-file"], @options_parser["log-level"])
61
48
 
62
49
  command = (@options_parser.args[0] || "add").downcase
63
50
  aliases = []
@@ -73,7 +60,7 @@ module Akaer
73
60
  end
74
61
 
75
62
  # Instantiate the logger
76
- logger = self.create_logger(configuration.log_file, configuration.log_level)
63
+ logger = Akaer::Logger.create(configuration.log_file, configuration.log_level)
77
64
 
78
65
  # Create address
79
66
  if !["add", "remove"].include?(command) then
data/lib/akaer/logger.rb CHANGED
@@ -4,14 +4,38 @@
4
4
  # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
5
  #
6
6
 
7
+ Sickill::Rainbow.enabled = true
8
+
7
9
  module Akaer
8
10
  class Logger < ::Logger
9
- mattr_accessor :start_time
11
+ mattr_accessor :global_start_time
12
+ attr_accessor :start_time
10
13
 
11
14
  def initialize(logdev, shift_age = 0, shift_size = 1048576)
12
15
  super(logdev, shift_age, shift_size)
16
+ end
17
+
18
+ def self.create(file, level = Logger::INFO, formatter = nil)
19
+ rv = self.new(self.get_real_file(file))
20
+ rv.level = level.to_i
21
+ rv.formatter = formatter || self.default_formatter
22
+ rv
23
+ end
24
+
25
+ def self.get_real_file(file)
26
+ case file
27
+ when "STDOUT" then $stdout
28
+ when "STDERR" then $stderr
29
+ else file
30
+ end
31
+ end
32
+
33
+ def self.default_file
34
+ $stdout
35
+ end
13
36
 
14
- self.formatter = Proc.new {|severity, datetime, progname, msg|
37
+ def self.default_formatter
38
+ Proc.new {|severity, datetime, progname, msg|
15
39
  color = case severity
16
40
  when "DEBUG" then :cyan
17
41
  when "INFO" then :green
@@ -21,10 +45,14 @@ module Akaer
21
45
  else nil
22
46
  end
23
47
 
24
- header = ("[%s T+%0.5f]" %[datetime.strftime("%Y/%b/%d %H:%M:%S"), datetime.to_f - @@start_time.to_f, msg]).bright
48
+ header = ("[%s T+%0.5f] %s:" %[datetime.strftime("%Y/%b/%d %H:%M:%S"), [datetime.to_f - self.start_time.to_f, 0].max, severity.rjust(5)]).bright
25
49
  header = header.color(color) if color.present?
26
- log = "%s %s\n" % [header, msg]
50
+ "%s %s\n" % [header, msg]
27
51
  }
28
52
  end
53
+
54
+ def self.start_time
55
+ @start_time ||= Time.now
56
+ end
29
57
  end
30
- end
58
+ end
data/lib/akaer/version.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  module Akaer
8
8
  module Version
9
9
  MAJOR = 0
10
- MINOR = 1
10
+ MINOR = 3
11
11
  PATCH = 0
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
data/lib/akaer.rb CHANGED
@@ -11,8 +11,6 @@ require "hashie"
11
11
  require "rainbow"
12
12
  require "pathname"
13
13
 
14
- Sickill::Rainbow.enabled = true
15
-
16
14
  require "akaer/version" if !defined?(Akaer::Version)
17
15
  require "akaer/errors"
18
16
  require "akaer/logger"
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Akaer::Application do
10
+ pending "To all."
11
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Akaer::Configuration do
10
+ pending "To all."
11
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the devdns gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Akaer::Logger do
10
+ pending "Test all."
11
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "simplecov"
8
+ require "pathname"
9
+
10
+ if ENV["AKAER_COVERAGE"] == "TRUE" then
11
+ root = Pathname.new(File.dirname(__FILE__)) + ".."
12
+
13
+ SimpleCov.start do
14
+ add_filter do |src_file|
15
+ path = Pathname.new(src_file.filename).relative_path_from(root).to_s
16
+ path !~ /^(bin|lib)/
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the akaer gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "rubygems"
8
+ require "bundler/setup"
9
+ require "coverage_helper"
10
+ require "akaer"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akaer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-08 00:00:00.000000000 Z
12
+ date: 2012-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cowtech-extensions
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.1.0
21
+ version: 2.7.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.0
29
+ version: 2.7.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: cowtech-lib
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.9.8.0
37
+ version: 2.0.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.9.8.0
45
+ version: 2.0.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: hashie
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,119 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 2.10.0
85
+ version: 2.11.0
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.11.0
94
+ - !ruby/object:Gem::Dependency
95
+ name: rake
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.9.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 0.9.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: simplecov
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 0.6.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 0.6.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: pry
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 0.9.10
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.9.10
142
+ - !ruby/object:Gem::Dependency
143
+ name: net-dns
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: 0.7.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 0.7.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: yard
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 0.8.0
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: 0.8.0
174
+ - !ruby/object:Gem::Dependency
175
+ name: redcarpet
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: 2.1.0
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ~>
188
+ - !ruby/object:Gem::Version
189
+ version: 2.1.0
190
+ - !ruby/object:Gem::Dependency
191
+ name: github-markup
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: 0.7.0
86
198
  type: :development
87
199
  prerelease: false
88
200
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +202,7 @@ dependencies:
90
202
  requirements:
91
203
  - - ~>
92
204
  - !ruby/object:Gem::Version
93
- version: 2.10.0
205
+ version: 0.7.0
94
206
  description: A small utility to add aliases to network interfaces.
95
207
  email:
96
208
  - shogun_panda@me.com
@@ -100,6 +212,8 @@ extensions: []
100
212
  extra_rdoc_files: []
101
213
  files:
102
214
  - .gitignore
215
+ - .travis.yml
216
+ - .yardopts
103
217
  - Gemfile
104
218
  - Gemfile.lock
105
219
  - README.md
@@ -112,6 +226,11 @@ files:
112
226
  - lib/akaer/errors.rb
113
227
  - lib/akaer/logger.rb
114
228
  - lib/akaer/version.rb
229
+ - spec/akaer/application_spec.rb
230
+ - spec/akaer/configuration_spec.rb
231
+ - spec/akaer/logger_spec.rb
232
+ - spec/coverage_helper.rb
233
+ - spec/spec_helper.rb
115
234
  homepage: http://github.com/ShogunPanda/akaer
116
235
  licenses: []
117
236
  post_install_message:
@@ -126,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
245
  version: '0'
127
246
  segments:
128
247
  - 0
129
- hash: 2748666871543433517
248
+ hash: 4554862059516849580
130
249
  required_rubygems_version: !ruby/object:Gem::Requirement
131
250
  none: false
132
251
  requirements:
@@ -135,11 +254,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
254
  version: '0'
136
255
  segments:
137
256
  - 0
138
- hash: 2748666871543433517
257
+ hash: 4554862059516849580
139
258
  requirements: []
140
259
  rubyforge_project: akaer
141
260
  rubygems_version: 1.8.24
142
261
  signing_key:
143
262
  specification_version: 3
144
263
  summary: A small utility to add aliases to network interfaces.
145
- test_files: []
264
+ test_files:
265
+ - spec/akaer/application_spec.rb
266
+ - spec/akaer/configuration_spec.rb
267
+ - spec/akaer/logger_spec.rb
268
+ - spec/coverage_helper.rb
269
+ - spec/spec_helper.rb
270
+ has_rdoc: