choir 0.0.2
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/choir.gemspec +19 -0
- data/lib/choir.rb +23 -0
- data/spec/choir_spec.rb +37 -0
- data/spec/spec_helper.rb +6 -0
- metadata +54 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: a5cd3294fb18350d91cfa36ba11351c33e9987c0
|
|
4
|
+
data.tar.gz: 64e592dcb37806b8cdaac78347bbffbf9dca6e49
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 928f9a6ceccac5f116bcdf03d76f74ae59e085f43d3de7461df398fe10bf24e8b3ae4980ca536b3dd53b6af79279f762c7d1e9f4c18a78cc25fca5d653a0fe76
|
|
7
|
+
data.tar.gz: 382f19b1198aec1260403156bc26b4aba434c7bbd3a90304705cb8f701672b8926bb7b98c86b960f7df0b8a7a6148026f99aaa2fd63e22fd0905c6363ed14a79
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2013 Neil Pullman
|
|
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,34 @@
|
|
|
1
|
+
# Choir
|
|
2
|
+
|
|
3
|
+
Ruby API wrapper for Choir.io. Fetch stream and post events.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'choir'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install choir
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
require 'choir'
|
|
22
|
+
|
|
23
|
+
choir = Choir::API.new
|
|
24
|
+
|
|
25
|
+
choir.get_stream(<your stream id>)
|
|
26
|
+
choir.post_event(<your source key>, { sound: "g/1", label: "hello", text: "hello choir" })
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
1. Fork it
|
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
34
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/choir.gemspec
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'choir'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = "choir"
|
|
8
|
+
gem.version = Choir::API::VERSION
|
|
9
|
+
gem.authors = ["Neil Pullman"]
|
|
10
|
+
gem.email = ["neil@descend.org"]
|
|
11
|
+
gem.description = %q{ Basic API wrapper for choir.io }
|
|
12
|
+
gem.summary = gem.description
|
|
13
|
+
gem.homepage = ""
|
|
14
|
+
|
|
15
|
+
gem.files = `git ls-files`.split($/)
|
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
gem.require_paths = ["lib"]
|
|
19
|
+
end
|
data/lib/choir.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'httparty'
|
|
2
|
+
|
|
3
|
+
module Choir
|
|
4
|
+
class API
|
|
5
|
+
|
|
6
|
+
VERSION = "0.0.2"
|
|
7
|
+
|
|
8
|
+
include HTTParty
|
|
9
|
+
base_uri 'https://api.choir.io'
|
|
10
|
+
|
|
11
|
+
def post_event (key, data)
|
|
12
|
+
|
|
13
|
+
raise ArgumentError, "Must specify a key" if key.nil?
|
|
14
|
+
raise ArgumentError, "Must specify a sound" if data[:sound].nil?
|
|
15
|
+
|
|
16
|
+
self.class.post( "/#{key}", body: data )
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class API::Error < ::StandardError; end
|
|
23
|
+
end
|
data/spec/choir_spec.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe Choir::API do
|
|
4
|
+
|
|
5
|
+
before(:all) do
|
|
6
|
+
|
|
7
|
+
@api = Choir::API.new
|
|
8
|
+
|
|
9
|
+
FakeWeb.register_uri(:post, "https://api.choir.io/myeventid", :status => ["201"])
|
|
10
|
+
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
describe "post_event" do
|
|
15
|
+
|
|
16
|
+
it "returns status 201 after posting an event" do
|
|
17
|
+
|
|
18
|
+
resp = @api.post_event( 'myeventid', { :sound => "g/1", :label => "hello", :text => "hello choir" } )
|
|
19
|
+
resp.code.should == 201
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "throws an argument error if no sound is specified" do
|
|
24
|
+
|
|
25
|
+
expect{ resp = @api.post_event( 'myeventid', {} ) }.to raise_error(ArgumentError)
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "throws an argument error if no key is specified" do
|
|
30
|
+
|
|
31
|
+
expect{ resp = @api.post_event( {} ) }.to raise_error(ArgumentError)
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: choir
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Neil Pullman
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: " Basic API wrapper for choir.io "
|
|
14
|
+
email:
|
|
15
|
+
- neil@descend.org
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".gitignore"
|
|
21
|
+
- Gemfile
|
|
22
|
+
- LICENSE.txt
|
|
23
|
+
- README.md
|
|
24
|
+
- Rakefile
|
|
25
|
+
- choir.gemspec
|
|
26
|
+
- lib/choir.rb
|
|
27
|
+
- spec/choir_spec.rb
|
|
28
|
+
- spec/spec_helper.rb
|
|
29
|
+
homepage: ''
|
|
30
|
+
licenses: []
|
|
31
|
+
metadata: {}
|
|
32
|
+
post_install_message:
|
|
33
|
+
rdoc_options: []
|
|
34
|
+
require_paths:
|
|
35
|
+
- lib
|
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
requirements:
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
requirements: []
|
|
47
|
+
rubyforge_project:
|
|
48
|
+
rubygems_version: 2.2.2
|
|
49
|
+
signing_key:
|
|
50
|
+
specification_version: 4
|
|
51
|
+
summary: Basic API wrapper for choir.io
|
|
52
|
+
test_files:
|
|
53
|
+
- spec/choir_spec.rb
|
|
54
|
+
- spec/spec_helper.rb
|