multiforecast-client 0.80.0.2 → 0.80.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e05fb5d0476e998fd94384fcada44dad95b49c90
4
- data.tar.gz: e2c8e233d42d092ebcc31e4fe417c912607202fa
3
+ metadata.gz: 96f83be23b81f12918dbe3cf40c7576fe3b6022b
4
+ data.tar.gz: 32f6ee8e8916fbf64b987b416dbe3c2e72384c9d
5
5
  SHA512:
6
- metadata.gz: 6dec979c161addb240c65b1b687d0c4c7d9b2adb1b7a4f3daf33342b3832de4cff128dac61297b456c699d3b568efd0b61028b7b60362a66de134cb35c5583b2
7
- data.tar.gz: c02f71a74c95572b54bfd1a73a002ba5a7efd10daa98e6af0226e0fe6671bfc71e6808a502289983010ca10cc82efd9b632bd6a800d985bee30f91a6d317bcca
6
+ metadata.gz: b7db46a9fc0bec24f355d5c2438be9e8877b3d1480a7517827624736660196e85f7b57155d8f73aab48d1cabd79f463a6c69f908b77786ca5ca958339a4e6565
7
+ data.tar.gz: 1f15dbda185edb03c315e91be151a2159bc3f5d89f1f3c4f822d495e55dc0303d8b02ee0036065bfc5c85eca21e07bbc0a5fd927f80ea21e29eee9b04e7eb98d
@@ -1,3 +1,9 @@
1
+ # 0.80.0.3 (2014/03/20)
2
+
3
+ Enhancement
4
+
5
+ * Add regexp option for delete command
6
+
1
7
  # 0.80.0.2 (2014/03/04)
2
8
 
3
9
  Fixes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.80.0.2
1
+ 0.80.0.3
@@ -51,13 +51,15 @@ class MultiForecast::CLI < Thor
51
51
  ex) multiforecast delete 'test/test' -c multiforecast.yml
52
52
  LONGDESC
53
53
  option :graph_names, :type => :array, :aliases => '-g'
54
+ option :regexp, :type => :string, :aliases => '-r'
54
55
  def delete(base_path)
55
56
  base_path = lstrip(base_path, '/')
57
+ regexp = Regexp.new(@options['regexp']) if @options['regexp']
56
58
 
57
- graphs = @client.list_graph(base_path)
59
+ graphs = @client.list_graph(base_path, regexp)
58
60
  delete_graphs(graphs, @options['graph_names'])
59
61
 
60
- complexes = @client.list_complex(base_path)
62
+ complexes = @client.list_complex(base_path, regexp)
61
63
  delete_complexes(complexes, @options['graph_names'])
62
64
  $stderr.puts "Not found" if graphs.empty? and complexes.empty? unless @options['silent']
63
65
  end
@@ -82,6 +82,7 @@ module MultiForecast
82
82
 
83
83
  # Get the list of graphs, /json/list/graph
84
84
  # @param [String] base_path
85
+ # @param [Regexp] regexp list only matched graphs
85
86
  # @return [Hash] list of graphs
86
87
  # @example
87
88
  # [
@@ -98,13 +99,15 @@ module MultiForecast
98
99
  # "path"=>"test/hostname/<1sec_count",
99
100
  # "id"=>3},
100
101
  # ]
101
- def list_graph(base_path = nil)
102
+ def list_graph(base_path = nil, regexp = nil)
102
103
  clients(base_path).inject([]) do |ret, client|
103
104
  graphs = []
104
105
  client.list_graph.each do |graph|
105
106
  graph['base_uri'] = client.base_uri
106
107
  graph['path'] = path(graph['service_name'], graph['section_name'], graph['graph_name'])
107
- graphs << graph if base_path.nil? or graph['path'].index(base_path) == 0
108
+ if base_path.nil? or graph['path'].index(base_path) == 0
109
+ graphs << graph if !regexp or regexp.match(graph['path'])
110
+ end
108
111
  end
109
112
  ret = ret + graphs
110
113
  end
@@ -173,6 +176,8 @@ module MultiForecast
173
176
  end
174
177
 
175
178
  # Get the list of complex graphs, /json/list/complex
179
+ # @param [String] base_path
180
+ # @param [Regexp] regexp list only matched graphs
176
181
  # @return [Hash] list of complex graphs
177
182
  # @example
178
183
  # [
@@ -189,13 +194,15 @@ module MultiForecast
189
194
  # "graph_name"=>"test%2Fhostname%2F%3C1sec_count",
190
195
  # "id"=>3},
191
196
  # ]
192
- def list_complex(base_path = nil)
197
+ def list_complex(base_path = nil, regexp = nil)
193
198
  clients(base_path).inject([]) do |ret, client|
194
199
  graphs = []
195
200
  client.list_complex.each do |graph|
196
201
  graph['base_uri'] = client.base_uri
197
202
  graph['path'] = path(graph['service_name'], graph['section_name'], graph['graph_name'])
198
- graphs << graph if base_path.nil? or graph['path'].index(base_path) == 0
203
+ if base_path.nil? or graph['path'].index(base_path) == 0
204
+ graphs << graph if !regexp or regexp.match(graph['path'])
205
+ end
199
206
  end
200
207
  ret = ret + graphs
201
208
  end
@@ -51,7 +51,15 @@ describe MultiForecast::Client do
51
51
 
52
52
  context "#list_graph" do
53
53
  include_context "stub_list_graph" if ENV['MOCK'] == 'on'
54
- subject { graphs }
54
+ subject { multiforecast.list_graph }
55
+ its(:size) { should > 0 }
56
+ id_keys.each {|key| its(:first) { should have_key(key) } }
57
+ end
58
+
59
+ context "#list_graph(regexp)" do
60
+ include_context "stub_list_graph" if ENV['MOCK'] == 'on'
61
+ let(:graph) { multiforecast.list_graph.first }
62
+ subject { multiforecast.list_graph('', Regexp.new(graph['graph_name'])) }
55
63
  its(:size) { should > 0 }
56
64
  id_keys.each {|key| its(:first) { should have_key(key) } }
57
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiforecast-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.80.0.2
4
+ version: 0.80.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: growthforecast-client