ninja_blocks 0.0.7 → 0.0.8
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.
- data/lib/ninja_blocks/base.rb +11 -6
- data/lib/ninja_blocks/device.rb +5 -3
- data/lib/ninja_blocks/version.rb +1 -1
- data/lib/ninja_blocks.rb +1 -0
- data/ninja_blocks.gemspec +1 -0
- metadata +17 -2
data/lib/ninja_blocks/base.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module NinjaBlocks
|
2
2
|
class Base
|
3
|
-
def get(url)
|
4
|
-
execute(:get,url)
|
3
|
+
def get(url,options={})
|
4
|
+
execute(:get,url,options)
|
5
5
|
end
|
6
6
|
def put(url)
|
7
7
|
execute(:put,url)
|
@@ -15,8 +15,8 @@ module NinjaBlocks
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def connection
|
18
|
-
@connection = Faraday.new(:url => 'https://
|
19
|
-
@connection.headers['
|
18
|
+
@connection = Faraday.new(:url => 'https://api.ninja.is')
|
19
|
+
@connection.headers['accept'] = 'application/json'
|
20
20
|
@connection.headers['Content-Type'] = 'application/json'
|
21
21
|
@connection
|
22
22
|
end
|
@@ -25,8 +25,13 @@ module NinjaBlocks
|
|
25
25
|
@token || NinjaBlocks.token
|
26
26
|
end
|
27
27
|
|
28
|
-
def execute(method,url)
|
29
|
-
|
28
|
+
def execute(method,url,options={})
|
29
|
+
|
30
|
+
unless options.empty?
|
31
|
+
response = connection.send(method,"#{url}?#{options}&user_access_token=#{self.token}")
|
32
|
+
else
|
33
|
+
response = connection.send(method,"#{url}?user_access_token=#{self.token}")
|
34
|
+
end
|
30
35
|
JSON.parse(response.body)
|
31
36
|
end
|
32
37
|
|
data/lib/ninja_blocks/device.rb
CHANGED
@@ -85,9 +85,11 @@ module NinjaBlocks
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def data(guid, from, to)
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
|
89
|
+
from = (Chronic.parse(from).utc.to_i) *1000
|
90
|
+
to = (Chronic.parse(to).utc.to_i) *1000
|
91
|
+
|
92
|
+
get("https://api.ninja.is/rest/v0/device/#{guid}/data", "from=#{from}&to=#{to}")
|
91
93
|
end
|
92
94
|
|
93
95
|
def last_heartbeat(guid)
|
data/lib/ninja_blocks/version.rb
CHANGED
data/lib/ninja_blocks.rb
CHANGED
data/ninja_blocks.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ninja_blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: active_support
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
- !ruby/object:Gem::Dependency
|
63
79
|
name: chronic
|
64
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,4 +132,3 @@ signing_key:
|
|
116
132
|
specification_version: 3
|
117
133
|
summary: Ninja Blocks!
|
118
134
|
test_files: []
|
119
|
-
has_rdoc:
|