ruby_spark 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9324c9a6228dcc21ff13bd9d695389055af9cca7
4
- data.tar.gz: 6a858029a91ba90690a2d1a9711dae5667159fcd
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTRiOWYxYTZlNTUyNGUzZWIyYmZjMGY3ZjA5ZjAxNTQ2ZTdmNGI0Yw==
5
+ data.tar.gz: !binary |-
6
+ NjFkMjAzNmY1NzIzMTVjMTIwYWRiYjc2NThhOWZkOTIwMDRmMDVlMg==
5
7
  SHA512:
6
- metadata.gz: 9e5516528e6443dc4f54132079ac5680e4c204153e3a592241c5e24670e34fb60f5346be0b3367253f5ebdc87fd169c61bcc0af1bfab4eba2d685e02c0ca8b07
7
- data.tar.gz: 1dc2900c9ba70089e4310268e166e55a68729894101b6683244815ce15029c1769c8b9fec4a29509697b98dc0ee0a81cdb5a3c44ebf5ac113f862024edec874b
8
+ metadata.gz: !binary |-
9
+ NzE1NzVlMzQwZDJmYjFhMjU0ZGNhYmZhNTU2MzM4ZjA0MGU2ODIzMzQ5N2I2
10
+ Mzg1M2M5Y2YzNWNiMDRhNzM2ZjFjMDAyYjYzYWNhMDcwNzg5MDhhMTg0OGQy
11
+ ODM1OWQ1NDQ4NWZiMzBlYWEwNTQ0OTIzMzIzYTZiZjM3OTQ0OTI=
12
+ data.tar.gz: !binary |-
13
+ YzI0MzA3YzI3NjRjZGEzNWQ3NWQyODMwZTUwMDRiNmVmNGJmYjFkNzUwODA0
14
+ ZmQ1MTM5ZTk2NTkwODUzMTA3Y2EwZmQ4NzE0MWQ1NzYwYzllYzJhNmFiYjc4
15
+ NTVlZDU2NDY5NjRhYmJlNDMxZDliZDgyNmMwMTViYWRkYWEyYTQ=
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Ruby Gem to make API requests to the [Spark Cloud API](http://docs.spark.io/#/api)
4
4
 
5
- ##Obtaining a Spark Core Access Token and Core ID
5
+ ## Obtaining a Spark Core Access Token and Core ID
6
6
 
7
7
  Assuming at this point you've followed the Spark Core's [Getting Started](http://docs.spark.io/#/start) guides and connected your Core with the Spark Cloud.
8
8
 
@@ -12,7 +12,9 @@ Head over to the [Spark Build IDE](https://www.spark.io/build). In the Settings
12
12
 
13
13
  To use this gem, install it with `gem install ruby_spark` or add this line to your Gemfile:
14
14
 
15
- gem 'ruby_spark'
15
+ ```ruby
16
+ gem 'ruby_spark'
17
+ ```
16
18
 
17
19
  and install it with `bundle install`
18
20
 
@@ -20,33 +22,57 @@ and install it with `bundle install`
20
22
 
21
23
  Load:
22
24
 
23
- require 'ruby_spark'
25
+ ```ruby
26
+ require 'ruby_spark'
27
+ ```
24
28
 
25
29
  Configure:
26
30
 
27
- # config/initializers/ruby_spark.rb
31
+ ```ruby
32
+ # config/initializers/ruby_spark.rb
28
33
 
29
- RubySpark.configuration do |config|
30
- config.access_token = "very_long_spark_api_access_token"
31
- end
34
+ RubySpark.configuration do |config|
35
+ config.access_token = "spark_api_access_token"
36
+ end
37
+ ```
32
38
 
33
- Instantiate.
39
+ ### Core API
34
40
 
35
- core = RubySpark::Core.new("semi_long_core_device_id")
41
+ To instantiate a Core, you need to pass it's `device_id`. If you have your `access_token` setup ahead of time using the `config.access_token` then the second argument is optional.
36
42
 
37
- Alternitavely, you can pass your Access Token directly into your Core object and skip the configuration.
38
-
39
- core = RubySpark::Core.new("semi_long_core_device_id", "very_long_spark_api_access_token")
43
+ ```ruby
44
+ core = RubySpark::Core.new("core_device_id")
45
+ # or
46
+ core = RubySpark::Core.new("core_device_id", "spark_api_access_token")
47
+ ```
40
48
 
41
49
  Fire away:
42
50
 
43
- core.digital_write(3, "HIGH") #=> true or false
44
- core.digital_read(5) #=> "HIGH" or "LOW"
51
+ ```ruby
52
+ core.info #=> { info hash }
53
+
54
+ core.variable("something") #=> number (for now)
55
+ core.function("foo", "argument") #=> number
56
+ ```
57
+
58
+ ### Tinker API
59
+
60
+ The tinker class provides `digital_read`, `digital_write`, `analog_read`, and `analog_write` for the default spark core code. This is the same interface as the tinker app.
61
+
62
+ ```ruby
63
+ core = RubySpark::Tinker.new("core_device_id")
64
+ # or
65
+ core = RubySpark::Tinker.new("core_device_id", "spark_api_access_token")
66
+ ```
67
+
68
+ Fire away:
45
69
 
46
- core.analog_write(3, 420) #=> true or false
47
- core.analog_read(5) #=> 0 to 4096
70
+ ```ruby
71
+ core.info #=> { info hash }
48
72
 
49
- Clearly you'll need to replace "very_long_spark_api_access_token" and "semi_long_core_device_id" with real values.
73
+ core.digital_write(3, "HIGH") #=> true or false
74
+ core.digital_read(5) #=> "HIGH" or "LOW"
75
+ ```
50
76
 
51
77
  ## Contributing
52
78
 
@@ -20,7 +20,7 @@ module RubySpark
20
20
  def variable(variable_name)
21
21
  response = get(variable_name)
22
22
  handle(response) do
23
- response["TEMPORARY_allTypes"]["number"]
23
+ response["result"]
24
24
  end
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module RubySpark
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -13,58 +13,6 @@ describe RubySpark::Tinker do
13
13
  subject.digital_write(7, "HIGH").should == true
14
14
  end
15
15
  end
16
-
17
- it "returns the appropriate error when Access Token is bad" do
18
- RubySpark.access_token = "bad_token"
19
-
20
- VCR.use_cassette("bad_token") do
21
- expect {
22
- subject.digital_write(7, "HIGH")
23
- }.to raise_error(RubySpark::Core::ApiError)
24
- end
25
-
26
- VCR.use_cassette("bad_token") do
27
- begin
28
- subject.digital_write(7, "HIGH")
29
- rescue => e
30
- e.message.should == "invalid_grant: The access token provided is invalid."
31
- end
32
- end
33
- end
34
-
35
- it "returns the appropriate error when Core ID is bad" do
36
- subject = described_class.new("bad_core_id")
37
-
38
- VCR.use_cassette("bad_core_id") do
39
- expect {
40
- subject.digital_write(7, "HIGH")
41
- }.to raise_error(RubySpark::Core::ApiError)
42
- end
43
-
44
- VCR.use_cassette("bad_core_id") do
45
- begin
46
- subject.digital_write(7, "HIGH")
47
- rescue => e
48
- e.message.should == "Permission Denied: Invalid Core ID"
49
- end
50
- end
51
- end
52
-
53
- it "returns the appropriate error when the Spark API times out" do
54
- VCR.use_cassette("spark_timeout") do
55
- expect {
56
- subject.digital_write(7, "HIGH")
57
- }.to raise_error(RubySpark::Core::ApiError)
58
- end
59
-
60
- VCR.use_cassette("spark_timeout") do
61
- begin
62
- subject.digital_write(7, "HIGH")
63
- rescue => e
64
- e.message.should == "Timed out."
65
- end
66
- end
67
- end
68
16
  end
69
17
 
70
18
  describe "#digital_read" do
@@ -91,37 +39,4 @@ describe RubySpark::Tinker do
91
39
  end
92
40
  end
93
41
  end
94
-
95
- context "with Access Token passed into Core" do
96
- subject { described_class.new("good_core_id", "good_access_token") }
97
-
98
- describe "#digital_read" do
99
- it "succeeds when Access Token and Core ID are correct" do
100
- VCR.use_cassette("digital_write") do
101
- subject.digital_write(7, "HIGH").should == true
102
- end
103
- end
104
- end
105
- end
106
-
107
- context "with no Access Token defined" do
108
- before { RubySpark.access_token = nil }
109
- subject { described_class.new("good_core_id") }
110
-
111
- it "returns proper error if Access Token is not defined" do
112
- VCR.use_cassette("no_token") do
113
- expect {
114
- subject.digital_read(6)
115
- }.to raise_error(RubySpark::ConfigurationError)
116
- end
117
-
118
- VCR.use_cassette("no_token") do
119
- begin
120
- subject.digital_read(6)
121
- rescue => e
122
- e.message.should == "Access Token not defined"
123
- end
124
- end
125
- end
126
- end
127
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_spark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Fatsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-30 00:00:00.000000000 Z
11
+ date: 2014-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,84 +28,84 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: vcr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ! '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ! '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: httparty
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ! '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ! '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Ruby Gem to make API calls to the Spark Cloud
@@ -147,17 +147,17 @@ require_paths:
147
147
  - lib
148
148
  required_ruby_version: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ! '>='
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - '>='
155
+ - - ! '>='
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
159
  rubyforge_project:
160
- rubygems_version: 2.0.6
160
+ rubygems_version: 2.2.2
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Ruby Gem to make API calls to the Spark Cloud