pulse_meter_cli 0.4.15 → 0.4.17
Sign up to get free protection for your applications and to get access to all the features.
- data/pulse_meter_cli.gemspec +3 -3
- data/spec/pulse_meter/extensions/enumerable_spec.rb +12 -12
- data/spec/pulse_meter/mixins/cmd_spec.rb +15 -15
- metadata +13 -10
data/pulse_meter_cli.gemspec
CHANGED
@@ -14,10 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
15
|
gem.name = "pulse_meter_cli"
|
16
16
|
gem.require_paths = ["lib"]
|
17
|
-
gem.version = "0.4.
|
17
|
+
gem.version = "0.4.17"
|
18
18
|
|
19
19
|
gem.add_runtime_dependency('pulse_meter_core')
|
20
|
-
gem.add_runtime_dependency('terminal-table')
|
20
|
+
gem.add_runtime_dependency('terminal-table', '~> 1.4.0')
|
21
21
|
gem.add_runtime_dependency('thor')
|
22
22
|
|
23
23
|
gem.add_development_dependency('aquarium')
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_development_dependency('mock_redis')
|
26
26
|
gem.add_development_dependency('rake')
|
27
27
|
gem.add_development_dependency('redcarpet')
|
28
|
-
gem.add_development_dependency('rspec')
|
28
|
+
gem.add_development_dependency('rspec', '~> 3.0')
|
29
29
|
gem.add_development_dependency('simplecov')
|
30
30
|
gem.add_development_dependency('timecop')
|
31
31
|
gem.add_development_dependency('yard')
|
@@ -5,54 +5,54 @@ describe Enumerable do
|
|
5
5
|
let!(:time) {Time.new}
|
6
6
|
describe "#convert_time" do
|
7
7
|
it "converts Time objects to unixtime" do
|
8
|
-
[time].convert_time.
|
8
|
+
expect([time].convert_time).to eq([time.to_i])
|
9
9
|
end
|
10
10
|
|
11
11
|
it "does not change other members" do
|
12
|
-
[1, 2, 3].convert_time.
|
12
|
+
expect([1, 2, 3].convert_time).to eq([1, 2 ,3])
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#to_table" do
|
17
17
|
context "when format is csv" do
|
18
18
|
it "returns csv as string" do
|
19
|
-
[].to_table(:csv).
|
19
|
+
expect([].to_table(:csv)).to be_instance_of(String)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "returns csv containing each subarray as a row" do
|
23
|
-
[[:a, :b], [:c, :d]].to_table(:csv).
|
23
|
+
expect([[:a, :b], [:c, :d]].to_table(:csv)).to eq("a;b\nc;d\n")
|
24
24
|
end
|
25
25
|
|
26
26
|
it "converts Time objects to unixtime" do
|
27
|
-
[[time]].to_table(:csv).
|
27
|
+
expect([[time]].to_table(:csv)).to eq("#{time.to_i}\n")
|
28
28
|
end
|
29
29
|
|
30
30
|
it "takes format argument both as string and as symbol" do
|
31
|
-
[[:foo]].to_table("csv").
|
32
|
-
[[:foo]].to_table(:csv).
|
31
|
+
expect([[:foo]].to_table("csv")).to eq("foo\n")
|
32
|
+
expect([[:foo]].to_table(:csv)).to eq("foo\n")
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
context "when format is table" do
|
37
37
|
it "return Terminal::Table instance" do
|
38
|
-
[].to_table.
|
38
|
+
expect([].to_table).to be_instance_of(Terminal::Table)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns table containing each subarray as a row" do
|
42
42
|
data = [[:a, :b], [:c, :d]]
|
43
43
|
table = [[:a, :b], [:c, :d]].to_table
|
44
|
-
table.rows.map do |row|
|
44
|
+
expect(table.rows.map do |row|
|
45
45
|
row.cells.map(&:to_s).map(&:strip).map(&:to_sym)
|
46
|
-
end.
|
46
|
+
end).to eq(data)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
it "uses table format as default" do
|
51
|
-
[].to_table.
|
51
|
+
expect([].to_table).to be_instance_of(Terminal::Table)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "uses table format unless it is :csv or 'csv'" do
|
55
|
-
[].to_table(:unknown_format).
|
55
|
+
expect([].to_table(:unknown_format)).to be_instance_of(Terminal::Table)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -19,8 +19,8 @@ describe PulseMeter::Mixins::Cmd do
|
|
19
19
|
|
20
20
|
describe "#fail!" do
|
21
21
|
it "prints given message and exits" do
|
22
|
-
STDOUT.
|
23
|
-
|
22
|
+
expect(STDOUT).to receive(:puts).with(:msg)
|
23
|
+
expect {dummy.fail!(:msg)}.to raise_error(SystemExit)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ describe PulseMeter::Mixins::Cmd do
|
|
28
28
|
it "initializes redies and yields a block" do
|
29
29
|
PulseMeter.redis = nil
|
30
30
|
dummy.with_redis do
|
31
|
-
PulseMeter.redis.
|
31
|
+
expect(PulseMeter.redis).not_to be_nil
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -37,19 +37,19 @@ describe PulseMeter::Mixins::Cmd do
|
|
37
37
|
it "restores sensor by name and passes it to block" do
|
38
38
|
sensor = PulseMeter::Sensor::Counter.new(:foo)
|
39
39
|
dummy.with_safe_restore_of(:foo) do |s|
|
40
|
-
s.
|
40
|
+
expect(s).to be_instance_of(sensor.class)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
it "prints error and exits if sensor cannot be restored" do
|
45
|
-
STDOUT.
|
46
|
-
|
45
|
+
expect(STDOUT).to receive(:puts).with("Sensor nonexistant is unknown or cannot be restored")
|
46
|
+
expect {dummy.with_safe_restore_of(:nonexistant) {|s| s}}.to raise_error(SystemExit)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "#all_sensors" do
|
51
51
|
it "is just an alias to PulseMeter::Sensor::Timeline.list_objects" do
|
52
|
-
PulseMeter::Sensor::Timeline.
|
52
|
+
expect(PulseMeter::Sensor::Timeline).to receive(:list_objects)
|
53
53
|
dummy.all_sensors
|
54
54
|
end
|
55
55
|
end
|
@@ -82,32 +82,32 @@ describe PulseMeter::Mixins::Cmd do
|
|
82
82
|
|
83
83
|
if "csv" == format.to_s
|
84
84
|
it "returns csv as string" do
|
85
|
-
csv.
|
85
|
+
expect(csv).to be_instance_of(String)
|
86
86
|
end
|
87
87
|
else
|
88
88
|
it "returns Terminal::Table instance" do
|
89
|
-
table.
|
89
|
+
expect(table).to be_instance_of(Terminal::Table)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
it "has title row" do
|
94
|
-
rows(format)[0].
|
94
|
+
expect(rows(format)[0]).to eq(["Name", "Class", "ttl", "raw data ttl", "interval", "reduce delay"])
|
95
95
|
end
|
96
96
|
|
97
97
|
it "has one row for each sensor (and a title)" do
|
98
|
-
rows(format).count.
|
98
|
+
expect(rows(format).count).to eq(3)
|
99
99
|
end
|
100
100
|
|
101
101
|
it "can display timelined sensors" do
|
102
|
-
sensor_row("s2", format).
|
102
|
+
expect(sensor_row("s2", format)).to eq([
|
103
103
|
s2.name, s2.class, s2.ttl, s2.raw_data_ttl, s2.interval, s2.reduce_delay
|
104
|
-
].map(&:to_s)
|
104
|
+
].map(&:to_s))
|
105
105
|
end
|
106
106
|
|
107
107
|
it "can display static sensors" do
|
108
|
-
sensor_row("s1", format).
|
108
|
+
expect(sensor_row("s1", format)).to eq([
|
109
109
|
s1.name, s1.class, "", "", "", ""
|
110
|
-
].map(&:to_s)
|
110
|
+
].map(&:to_s))
|
111
111
|
end
|
112
112
|
|
113
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pulse_meter_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.17
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pulse_meter_core
|
@@ -33,17 +33,17 @@ dependencies:
|
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
38
|
+
version: 1.4.0
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 1.4.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: thor
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,17 +145,17 @@ dependencies:
|
|
145
145
|
requirement: !ruby/object:Gem::Requirement
|
146
146
|
none: false
|
147
147
|
requirements:
|
148
|
-
- -
|
148
|
+
- - ~>
|
149
149
|
- !ruby/object:Gem::Version
|
150
|
-
version: '0'
|
150
|
+
version: '3.0'
|
151
151
|
type: :development
|
152
152
|
prerelease: false
|
153
153
|
version_requirements: !ruby/object:Gem::Requirement
|
154
154
|
none: false
|
155
155
|
requirements:
|
156
|
-
- -
|
156
|
+
- - ~>
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0'
|
158
|
+
version: '3.0'
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: simplecov
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +249,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
249
249
|
- - ! '>='
|
250
250
|
- !ruby/object:Gem::Version
|
251
251
|
version: '0'
|
252
|
+
segments:
|
253
|
+
- 0
|
254
|
+
hash: 726435572629036197
|
252
255
|
requirements: []
|
253
256
|
rubyforge_project:
|
254
257
|
rubygems_version: 1.8.23
|