little-dutch 0.0.8 → 0.0.9

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: 9e819b871e0e566d7cdb0bfc695432a80b172ef1
4
- data.tar.gz: 6a9a29c6a8412906641c0ad1d4925c654571c243
3
+ metadata.gz: 910c339774c1fc072441d17ff0d4b3549743e417
4
+ data.tar.gz: 600373a16055401f06edd5305102936a92dff76d
5
5
  SHA512:
6
- metadata.gz: 2ab8295b6476387dea9fc8477ca23aa865ef45d3302067539c3f97d100a2ca276cfb8d51592eae85174952d4548274833b4b22481933e4869f3b47e56e9431fd
7
- data.tar.gz: a83d8bb70139fa3836beb0cb417634034307f4dc3f29c80d1f8834f4a900665b18b04c0055b57a1f54476fed357f226d67663e6a37b7d637275dfc4c40533b08
6
+ metadata.gz: ef9cc921783612c37acf5e4d10fe8155d766e54ff15cf1525b02cf56a561b20fcef4a056d5f68fb295a17d057ae9c7b417491e8165db30c6c2fe10ecbe3121eb
7
+ data.tar.gz: 776fe373d7431dc99b7c85667d33146dae6d6886899e065d6bd13aae19c7b418f825e52bb5e73a32cc44586e8ab9ae7be1e5e5373d698ea3ca86e1ff4059868e
@@ -15,8 +15,8 @@ module LittleDutch
15
15
 
16
16
  class << self
17
17
 
18
- def option_reader(*names)
19
- names.each { |n| define_option_reader n }
18
+ def option(*names)
19
+ names.each { |n| define_option n }
20
20
  end
21
21
 
22
22
  def env
@@ -29,27 +29,45 @@ module LittleDutch
29
29
 
30
30
  private
31
31
 
32
- def define_option_reader(name)
32
+ def define_option(name)
33
33
  define_method name do
34
34
  @options[name.to_s]
35
35
  end
36
+
37
+ define_method "#{name}=" do |val|
38
+ @options[name.to_s] = val
39
+ end
36
40
  end
37
41
 
38
42
  end
39
43
 
40
- option_reader :endpoint, :token, :enabled, :interval, :app_name,
41
- :instance_name, :logfile
44
+ attr_writer :logger
45
+ option :endpoint, :token, :enabled, :interval, :app_name, :instance_name
42
46
  delegate :env, to: :class
43
47
 
44
48
  def initialize(file)
45
49
  @options = load(file)
46
- FileUtils.mkdir_p File.dirname logfile
50
+ FileUtils.mkdir_p File.dirname logfile if logfile.is_a? String
47
51
  end
48
52
 
49
53
  def instance_id
50
54
  @instance_id ||= [instance_name, uuid].join '.'
51
55
  end
52
56
 
57
+ def logfile=(file)
58
+ @logger = nil
59
+ @options['logfile'] = file
60
+ end
61
+
62
+ def logfile
63
+ output = @options['logfile']
64
+ if output.to_s.downcase.in? %w{stdout stderr}
65
+ output.to_s.upcase.constantize
66
+ else
67
+ output
68
+ end
69
+ end
70
+
53
71
  def logger
54
72
  @logger ||= Logger.new logfile
55
73
  end
@@ -1,5 +1,5 @@
1
1
  module Little
2
2
  module Dutch
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: little-dutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Waldrip
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday