greengoose 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/greengoose/action.rb +1 -0
- data/lib/greengoose/action_collection.rb +4 -0
- data/lib/greengoose/api.rb +1 -1
- data/lib/greengoose/client.rb +5 -0
- data/lib/greengoose/stat.rb +10 -0
- data/lib/greengoose/stat_collection.rb +23 -0
- data/lib/greengoose/version.rb +1 -1
- data/spec/greengoose/stat_collection_spec.rb +38 -0
- data/spec/greengoose/stat_spec.rb +9 -0
- metadata +24 -18
data/README.md
CHANGED
data/lib/greengoose/action.rb
CHANGED
data/lib/greengoose/api.rb
CHANGED
data/lib/greengoose/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "action_collection"
|
2
|
+
require_relative "stat_collection"
|
2
3
|
|
3
4
|
module GreenGoose
|
4
5
|
# Green Goose API client
|
@@ -32,6 +33,10 @@ module GreenGoose
|
|
32
33
|
GreenGoose::ActionCollection.new(self)
|
33
34
|
end
|
34
35
|
|
36
|
+
def stats
|
37
|
+
GreenGoose::StatCollection.new(self)
|
38
|
+
end
|
39
|
+
|
35
40
|
private
|
36
41
|
|
37
42
|
def connection
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "stat"
|
2
|
+
require_relative "api"
|
3
|
+
|
4
|
+
module GreenGoose
|
5
|
+
class StatCollection
|
6
|
+
include API
|
7
|
+
|
8
|
+
attr_reader :client, :conditions
|
9
|
+
|
10
|
+
def initialize(client, conditions = {})
|
11
|
+
@client = client
|
12
|
+
@conditions = conditions
|
13
|
+
end
|
14
|
+
|
15
|
+
def klass
|
16
|
+
GreenGoose::Stat
|
17
|
+
end
|
18
|
+
|
19
|
+
def endpoint
|
20
|
+
"stats"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/greengoose/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenGoose::StatCollection do
|
4
|
+
let(:client) { stub_everything("Client") }
|
5
|
+
subject { described_class.new(client) }
|
6
|
+
|
7
|
+
it "queries the stats API" do
|
8
|
+
client.stubs(:get).
|
9
|
+
with("stats", {}).
|
10
|
+
returns(stub(body: [{id: "123abc"}, {id: "987zyx"}]))
|
11
|
+
|
12
|
+
subject.to_a.map(&:id).should == ["123abc", "987zyx"]
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#where" do
|
16
|
+
it "scopes down the search" do
|
17
|
+
scoped_to_sensor = subject.where(sensor_id: "abc123")
|
18
|
+
|
19
|
+
client.stubs(:get).
|
20
|
+
with("stats", sensor_id: "abc123").
|
21
|
+
returns(stub(body: [{id: "123abc"}]))
|
22
|
+
|
23
|
+
scoped_to_sensor.to_a.map(&:id).should == ["123abc"]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "supports chaining" do
|
27
|
+
scoped_to_sensor_and_limit = subject.where(sensor_id: "abc123").
|
28
|
+
where(limit: 5)
|
29
|
+
|
30
|
+
|
31
|
+
client.stubs(:get).
|
32
|
+
with("stats", sensor_id: "abc123", limit: 5).
|
33
|
+
returns(stub(body: [{id: "123abc"}]))
|
34
|
+
|
35
|
+
scoped_to_sensor_and_limit.to_a.map(&:id).should == ["123abc"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: greengoose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70109114232300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.7.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70109114232300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &70109114231680 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.10.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70109114231680
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: webmock
|
38
|
-
requirement: &
|
38
|
+
requirement: &70109114231200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.7.8
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70109114231200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry
|
49
|
-
requirement: &
|
49
|
+
requirement: &70109114230820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70109114230820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &70109114230300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70109114230300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: faraday
|
71
|
-
requirement: &
|
71
|
+
requirement: &70109114229760 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0.8'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70109114229760
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: multi_json
|
82
|
-
requirement: &
|
82
|
+
requirement: &70109114229120 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '1.3'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70109114229120
|
91
91
|
description: ! "The GreenGoose API enables developers to build fun applications that
|
92
92
|
interact with the GreenGoose real-world sensor platform\n "
|
93
93
|
email:
|
@@ -111,12 +111,16 @@ files:
|
|
111
111
|
- lib/greengoose/credentials/basic.rb
|
112
112
|
- lib/greengoose/middleware.rb
|
113
113
|
- lib/greengoose/middleware/json.rb
|
114
|
+
- lib/greengoose/stat.rb
|
115
|
+
- lib/greengoose/stat_collection.rb
|
114
116
|
- lib/greengoose/version.rb
|
115
117
|
- spec/greengoose/action_collection_spec.rb
|
116
118
|
- spec/greengoose/action_spec.rb
|
117
119
|
- spec/greengoose/client_spec.rb
|
118
120
|
- spec/greengoose/credentials/basic_spec.rb
|
119
121
|
- spec/greengoose/middleware/json_spec.rb
|
122
|
+
- spec/greengoose/stat_collection_spec.rb
|
123
|
+
- spec/greengoose/stat_spec.rb
|
120
124
|
- spec/spec_helper.rb
|
121
125
|
homepage: https://github.com/alindeman/greengoose
|
122
126
|
licenses: []
|
@@ -132,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
136
|
version: '0'
|
133
137
|
segments:
|
134
138
|
- 0
|
135
|
-
hash: -
|
139
|
+
hash: -4382726329904586798
|
136
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
141
|
none: false
|
138
142
|
requirements:
|
@@ -141,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
145
|
version: '0'
|
142
146
|
segments:
|
143
147
|
- 0
|
144
|
-
hash: -
|
148
|
+
hash: -4382726329904586798
|
145
149
|
requirements: []
|
146
150
|
rubyforge_project:
|
147
151
|
rubygems_version: 1.8.15
|
@@ -154,4 +158,6 @@ test_files:
|
|
154
158
|
- spec/greengoose/client_spec.rb
|
155
159
|
- spec/greengoose/credentials/basic_spec.rb
|
156
160
|
- spec/greengoose/middleware/json_spec.rb
|
161
|
+
- spec/greengoose/stat_collection_spec.rb
|
162
|
+
- spec/greengoose/stat_spec.rb
|
157
163
|
- spec/spec_helper.rb
|