phant_rb 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10b0b93f2d3e0ecf0156d9855314d061ad4b95c5
4
+ data.tar.gz: b0a06bb1fddcfe2c31564906224a265b9b2c877d
5
+ SHA512:
6
+ metadata.gz: d744866ff8a10dd7ca40fb277ddf251fc60b489c5550f1bf35637ae52c34384f720f59a0546510c3675392f8236131046685c06d76c85ac05664cfc9e9c5180b
7
+ data.tar.gz: 7fd43f00029bab1962cc66c2f0512d57ea8a106f3afd398ae9e9d6c4543b7d67198193f20a41726389123fe7407ecf3ec9b40f3b42490e607a9aa29cf4ebc024
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phant_rb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Girish S
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # PhantRb
2
+
3
+ A Ruby client for Phant. See [data.sparkfun.com](https://data.sparkfun.com/) for more information.
4
+
5
+ This is a work in progress.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'phant_rb'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install phant_rb
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ client = PhantRb::Client.new "PUBLIC_KEY", %w(humidity temp), private_key: 'PRIVATE_KEY'
25
+ client.log(22.7, 17.8)
26
+
27
+ data = client.get()
28
+ puts data
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/phant_rb/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
38
+
39
+
40
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color']
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ module PhantRb
2
+ VERSION = "0.0.1"
3
+ end
data/lib/phant_rb.rb ADDED
@@ -0,0 +1,36 @@
1
+ require "phant_rb/version"
2
+ require 'rest_client'
3
+ require 'pp'
4
+ require 'hashie'
5
+
6
+ module PhantRb
7
+ class Client
8
+ def initialize(public_key, fields, opts = {})
9
+ @opts = {
10
+ base_url: 'http://data.sparkfun.com/'
11
+ }.merge(opts)
12
+ @fields = fields
13
+ @public_key = public_key
14
+ end
15
+
16
+ def log(*data)
17
+ @last_response = request data
18
+ Hashie::Mash.new(JSON.parse(@last_response.body))
19
+ end
20
+
21
+ def get
22
+ @last_response = RestClient.get @opts[:base_url] + "output/" + @public_key + ".json",
23
+ 'Phant-Private-Key' => @opts[:private_key]
24
+ JSON.parse @last_response.body
25
+ end
26
+
27
+ private
28
+ def request(data)
29
+ RestClient.post(
30
+ @opts[:base_url] + "input/" + @public_key + ".json",
31
+ URI.encode_www_form(@fields.zip(data)),
32
+ 'Phant-Private-Key' => @opts[:private_key]
33
+ )
34
+ end
35
+ end
36
+ end
data/phant_rb.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'phant_rb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "phant_rb"
8
+ spec.version = PhantRb::VERSION
9
+ spec.authors = ["Girish S"]
10
+ spec.email = ["girish.sonawane@gmail.com"]
11
+ spec.summary = %q{Ruby client library for Sparkfun's Phant}
12
+ spec.description = %q{Ruby client library for Sparkfun's Phant}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'rest-client'
22
+ spec.add_runtime_dependency 'json'
23
+ spec.add_runtime_dependency 'hashie'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.6"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec"
28
+ end
29
+
@@ -0,0 +1,21 @@
1
+ require_relative '../lib/phant_rb'
2
+
3
+ describe PhantRb do
4
+ before do
5
+ @client = PhantRb::Client.new "LQQNXaOx4wUm2Ya4vl08", %w(humidity temp), private_key: 'A11G0mPKy5S4rzNEo0Z6'
6
+ end
7
+
8
+ it 'logs data' do
9
+ resp = @client.log(12.0, 23)
10
+ expect(resp.success).to be true
11
+ end
12
+
13
+ it 'reads data' do
14
+ @client.get
15
+ end
16
+
17
+ it 'completely deletes a stream'
18
+ it 'clears a stream'
19
+ it 'returns stats for a stream'
20
+ it 'returns rate limits'
21
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phant_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Girish S
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby client library for Sparkfun's Phant
98
+ email:
99
+ - girish.sonawane@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - lib/phant_rb.rb
110
+ - lib/phant_rb/version.rb
111
+ - phant_rb.gemspec
112
+ - spec/phant_rb_spec.rb
113
+ homepage: ''
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.2.2
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Ruby client library for Sparkfun's Phant
137
+ test_files:
138
+ - spec/phant_rb_spec.rb