onering-client 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/onering.rb CHANGED
@@ -2,7 +2,7 @@ $: << File.expand_path(File.dirname(__FILE__))
2
2
 
3
3
  module Onering
4
4
  module Client
5
- VERSION = "0.3.4"
5
+ VERSION = "0.4.0"
6
6
 
7
7
  class Error < Exception; end
8
8
  class FatalError < Error; end
data/lib/onering/api.rb CHANGED
@@ -214,7 +214,7 @@ module Onering
214
214
  end
215
215
 
216
216
  def status()
217
- Onering::API.get("/").parsed_response
217
+ Onering::API.new.get("/").parsed_response
218
218
  end
219
219
 
220
220
  # -----------------------------------------------------------------------------
@@ -29,10 +29,15 @@ module Onering
29
29
  when :warn then sevtag = 'WW'
30
30
  when :info then sevtag = 'II'
31
31
  when :debug then sevtag = 'DD'
32
+ when :output then sevtag = ''
32
33
  else sevtag = '??'
33
34
  end
34
35
 
35
- logline = ["#{sevtag} ", (source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
36
+ if options[:sevtag] == false
37
+ logline = [(source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
38
+ else
39
+ logline = ["#{sevtag} ", (source.nil? ? nil : "[#{source}]"), msg].compact.join(' ')
40
+ end
36
41
 
37
42
  if options[:destination] === STDOUT or options[:destination] === STDERR
38
43
  case severity.downcase.to_sym
@@ -50,10 +55,10 @@ module Onering
50
55
  options[:destination].puts(logline)
51
56
  })
52
57
 
53
- self.level = options[:threshold]
58
+ self.level = (options[:threshold] || :info)
54
59
 
55
60
  self.debug("onering-client v#{Onering::Client::VERSION} started")
56
- self.debug("Logger is initialized. Output is #{outputfn}, threshold: #{options[:threshold]} or worse", "Onering::Logger")
61
+ self.debug("Logger is initialized. Output is #{outputfn || 'stderr'}, threshold: #{options[:threshold]} or worse", "Onering::Logger")
57
62
  end
58
63
 
59
64
 
@@ -113,6 +118,10 @@ module Onering
113
118
  self.log(:debug, message, source, 3)
114
119
  end
115
120
 
121
+ def self.output(message, source=nil)
122
+ self.log(:output, message, source)
123
+ end
124
+
116
125
  def self._get_level(severity)
117
126
  case severity.to_sym
118
127
  when :fatal
data/lib/onering/util.rb CHANGED
@@ -78,12 +78,16 @@ module Onering
78
78
  }
79
79
 
80
80
  def gem_path(name)
81
- if Gem::Specification.respond_to?(:find_by_name)
82
- return Gem::Specification.find_by_name(name).gem_dir
83
- else
84
- return Gem::SourceIndex.from_installed_gems.find_name(name).sort{|a,b|
85
- a.version.to_s <=> b.version.to_s
86
- }.last.full_gem_path
81
+ begin
82
+ if Gem::Specification.respond_to?(:find_by_name)
83
+ return Gem::Specification.find_by_name(name).gem_dir
84
+ else
85
+ return Gem::SourceIndex.from_installed_gems.find_name(name).sort{|a,b|
86
+ a.version.to_s <=> b.version.to_s
87
+ }.last.full_gem_path
88
+ end
89
+ rescue Gem::LoadError
90
+ return nil
87
91
  end
88
92
  end
89
93
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: onering-client
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.4
5
+ version: 0.4.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gary Hetzel