freyr 0.3.13 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.13
1
+ 0.4.0
data/lib/freyr/service.rb CHANGED
@@ -150,7 +150,7 @@ module Freyr
150
150
  end
151
151
  end
152
152
 
153
- group
153
+ group.empty? ? nil : group
154
154
  end
155
155
 
156
156
  end
@@ -1,8 +1,13 @@
1
+ require 'delegate'
2
+
1
3
  module Freyr
2
- class ServiceGroup < Array
4
+ class ServiceGroup < DelegateClass(Array)
5
+ extend Forwardable
6
+ service_methods = Service.instance_methods - Class.instance_methods
7
+ def_delegators :first, *service_methods
3
8
 
4
- def initialize(*args)
5
- super(*args)
9
+ def initialize
10
+ super([])
6
11
  end
7
12
 
8
13
  def find_by_name(n)
@@ -83,6 +83,7 @@ module Freyr
83
83
  class << self
84
84
 
85
85
  def from_file file
86
+ @file_path = file
86
87
  file = File.expand_path(file)
87
88
  return [] unless File.exist?(file)
88
89
  @added_services = []
@@ -90,8 +91,8 @@ module Freyr
90
91
  @added_services
91
92
  end
92
93
 
93
- def method_missing *args
94
-
94
+ def method_missing name, *args
95
+ STDERR.puts "Freyr doesn't support #{name} as used in #{@file_path}"
95
96
  end
96
97
 
97
98
  private
@@ -101,18 +102,21 @@ module Freyr
101
102
  end
102
103
 
103
104
  def group name, *services
104
- puts "Trying #{name.inspect} on #{services.inspect}"
105
105
  services.each do |s|
106
- Service[s].each do |service|
107
- puts "Service: #{service.name}"
108
- service.service_info.group(name)
106
+ services = Service[s]
107
+ if services
108
+ services.each do |service|
109
+ service.service_info.group(name)
110
+ end
111
+ else
112
+ STDERR.puts "Service #{s} not found, can't add to group #{name} as attempted in #{@file_path}"
109
113
  end
110
114
  end
111
115
  end
112
116
 
113
117
  def service name=nil, &blk
114
118
  name = "#{@namespace}:#{name}" if @namespace
115
- if service = Service[name].first
119
+ if service = Service[name]
116
120
  service.service_info.instance_eval(&blk)
117
121
  else
118
122
  @added_services << new(name,&blk)
data/lib/freyr.rb CHANGED
@@ -11,6 +11,6 @@ module Freyr
11
11
  end
12
12
  end
13
13
 
14
- %w{version service_group service command service_info pinger process_info}.each do |f|
14
+ %w{version service service_group command service_info pinger process_info}.each do |f|
15
15
  require File.expand_path(File.dirname(__FILE__)+"/freyr/#{f}.rb")
16
16
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freyr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 13
10
- version: 0.3.13
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tal Atlas