lc_api 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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +133 -0
- data/Rakefile +7 -0
- data/lc_api.gemspec +29 -0
- data/lib/lc_api/base.rb +23 -0
- data/lib/lc_api/location.rb +4 -0
- data/lib/lc_api/message.rb +4 -0
- data/lib/lc_api/series.rb +4 -0
- data/lib/lc_api/version.rb +3 -0
- data/lib/lc_api.rb +11 -0
- data/spec/lc_api_spec.rb +12 -0
- data/spec/resources/location_spec.rb +35 -0
- data/spec/resources/message_spec.rb +35 -0
- data/spec/resources/series_spec.rb +27 -0
- data/spec/spec_helper.rb +5 -0
- metadata +148 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 LifeChurch.tv
|
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,133 @@
|
|
1
|
+
# The Lifechurch.tv API Ruby Gem
|
2
|
+
|
3
|
+
A Ruby wrapper for the Lifechurch.tv REST API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
```ruby
|
7
|
+
gem install lc_api
|
8
|
+
```
|
9
|
+
|
10
|
+
## Quick Start Guide
|
11
|
+
First, register your application with LifeChurch.tv at http://api.lifechurch.tv.
|
12
|
+
|
13
|
+
Then, copy and paste in your API Key.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
LcApi.key = "K690FKW924CKUCJTH94WK294WK029834SDFJ9862KSDF9234SDKF9421KDVDS"
|
17
|
+
```
|
18
|
+
|
19
|
+
Try finding a single resource:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
msg = LcApi::Message.find(1)
|
23
|
+
```
|
24
|
+
|
25
|
+
Try finding multiple resources:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
msg = LcApi::Message.find(:all)
|
29
|
+
```
|
30
|
+
|
31
|
+
Filter results:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
msg = LcApi::Message.find(1, :include => [:series, :speaker], :params => {quantity: 20, page: 2})
|
35
|
+
```
|
36
|
+
|
37
|
+
Access properties from the results:
|
38
|
+
```ruby
|
39
|
+
msg.title
|
40
|
+
msg.part
|
41
|
+
msg.length
|
42
|
+
msg.date_released
|
43
|
+
```
|
44
|
+
|
45
|
+
That's it, you're ready to rock!
|
46
|
+
|
47
|
+
## Configuration
|
48
|
+
You can configure both the API key and the base URI:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
LcApi.key = "K690FKW924CKUCJTH94WK294WK029834SDFJ9862KSDF9234SDKF9421KDVDS"
|
52
|
+
LcApi::Base.site = "http://0.0.0.0:3000/v1/"
|
53
|
+
```
|
54
|
+
|
55
|
+
## Usage Examples
|
56
|
+
All examples require an authenticated LifeChurch.tv consumer. See the <a href="#quick-start-guide">quick start</a> section above.
|
57
|
+
|
58
|
+
**Get a message**
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
LcApi::Message.find(1)
|
62
|
+
```
|
63
|
+
|
64
|
+
**Get all messages**
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
LcApi::Message.find(:all)
|
68
|
+
```
|
69
|
+
|
70
|
+
**Get a message and include series and speakers**
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
LcApi::Message.find(1, :include => [:series, :speaker])
|
74
|
+
```
|
75
|
+
|
76
|
+
**Get a message with include and quantity**
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
LcApi::Message.find(1, :include => [:series, :speaker], :params => {quantity: 5})
|
80
|
+
```
|
81
|
+
|
82
|
+
**Get all messages with include, quantity, and page**
|
83
|
+
```ruby
|
84
|
+
LcApi::Message.all(:include => [:series, :speaker], :params => {quantity: 5, page: 2})
|
85
|
+
```
|
86
|
+
|
87
|
+
**Access properties on a message**
|
88
|
+
```ruby
|
89
|
+
msg.title
|
90
|
+
msg.part
|
91
|
+
msg.length
|
92
|
+
msg.date_released
|
93
|
+
```
|
94
|
+
|
95
|
+
**Access properties on a set of messages**
|
96
|
+
```ruby
|
97
|
+
msg = LcApi::Message.all
|
98
|
+
msg.each do |m|
|
99
|
+
msg.title
|
100
|
+
msg.part
|
101
|
+
end
|
102
|
+
```
|
103
|
+
|
104
|
+
## Resources
|
105
|
+
|
106
|
+
* LcApi::Location
|
107
|
+
* LcApi::Message
|
108
|
+
* LcApi::Series
|
109
|
+
|
110
|
+
## Filters
|
111
|
+
|
112
|
+
***Include***
|
113
|
+
|
114
|
+
:include => [speaker,series]
|
115
|
+
|
116
|
+
***Quantity*** (for Message and Series only)
|
117
|
+
|
118
|
+
:quantity => 5
|
119
|
+
|
120
|
+
***Page*** (for Message and Series only)
|
121
|
+
|
122
|
+
:page => 2
|
123
|
+
|
124
|
+
## Coming Soon
|
125
|
+
* Link to API homepage
|
126
|
+
* Documentation Like to API
|
127
|
+
* More details on optional params (:includes, :quantity, etc.)
|
128
|
+
|
129
|
+
## Copyright
|
130
|
+
Copyright (c) 2014 LifeChurch.tv.
|
131
|
+
See [LICENSE][] for details.
|
132
|
+
|
133
|
+
[license]: LICENSE.txt
|
data/Rakefile
ADDED
data/lc_api.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 'lc_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'lc_api'
|
8
|
+
spec.version = LcApi::VERSION
|
9
|
+
spec.authors = ["Scott Lesser"]
|
10
|
+
spec.email = ["interactive@lifechurch.tv"]
|
11
|
+
spec.summary = 'LC API'
|
12
|
+
spec.description = 'A gem for consuming the LifeChurch.tv API - api.lifechurch.tv'
|
13
|
+
spec.homepage = "http://api.lifechurch.tv"
|
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
|
+
# Runtime Dependencies
|
22
|
+
spec.add_runtime_dependency('activeresource', '>= 3.0.0')
|
23
|
+
|
24
|
+
# Development Dependencies
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
29
|
+
end
|
data/lib/lc_api/base.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module LcApi
|
2
|
+
class Base < ActiveResource::Base
|
3
|
+
self.site = "http://lctv-api.herokuapp.com/v1"
|
4
|
+
|
5
|
+
class << self
|
6
|
+
attr_accessor :api_key
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.find(*args)
|
10
|
+
scope = args.slice!(0)
|
11
|
+
options = args.slice!(0) || {}
|
12
|
+
|
13
|
+
if options.has_key? :include
|
14
|
+
options[:params] = (options[:params] || {}).merge({include: options[:include].join(",")})
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
options[:params] = (options[:params] || {}).merge({key: LcApi.key})
|
19
|
+
|
20
|
+
super(scope, options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/lc_api.rb
ADDED
data/spec/lc_api_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LcApi::Location do
|
4
|
+
describe "returning all locations" do
|
5
|
+
it "should grab a collection of locations" do
|
6
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/locations.json?key=1111", :body => [{id: 1}].to_json)
|
7
|
+
@locations = LcApi::Location.find(:all)
|
8
|
+
expect(@locations.class).to eq ActiveResource::Collection
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "returning a single location" do
|
13
|
+
it "should return a location" do
|
14
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/locations/2.json?key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
15
|
+
@location = LcApi::Location.find(2)
|
16
|
+
expect(@location.class).to eq LcApi::Location
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "including the staff info" do
|
21
|
+
it "should include 'staff' in the url" do
|
22
|
+
# If this test passes, that means the url below was correctly called, no need for any expects
|
23
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/locations/2.json?include=staff&key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
24
|
+
LcApi::Location.find(2, include: [:staff])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "including the events info" do
|
29
|
+
it "should include 'events' in the url" do
|
30
|
+
# If this test passes, that means the url below was correctly called, no need for any expects
|
31
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/locations/2.json?include=events&key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
32
|
+
LcApi::Location.find(2, include: [:events])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LcApi::Message do
|
4
|
+
describe "returning all messages" do
|
5
|
+
it "should grab a collection of messages" do
|
6
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/messages.json?key=1111", :body => [{id: 1}].to_json)
|
7
|
+
@messages = LcApi::Message.find(:all)
|
8
|
+
expect(@messages.class).to eq ActiveResource::Collection
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "returning a single message" do
|
13
|
+
it "should return a message" do
|
14
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/messages/2.json?key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
15
|
+
@message = LcApi::Message.find(2)
|
16
|
+
expect(@message.class).to eq LcApi::Message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "including the series info" do
|
21
|
+
it "should include 'series' in the url" do
|
22
|
+
# If this test passes, that means the url below was correctly called, no need for any expects
|
23
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/messages/2.json?include=series&key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
24
|
+
LcApi::Message.find(2, include: [:series])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "including the speaker info" do
|
29
|
+
it "should include 'speaker' in the url" do
|
30
|
+
# If this test passes, that means the url below was correctly called, no need for any expects
|
31
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/messages/2.json?include=speaker&key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
32
|
+
LcApi::Message.find(2, include: [:speaker])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LcApi::Series do
|
4
|
+
describe "returning all series" do
|
5
|
+
it "should grab a collection of series" do
|
6
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/series.json?key=1111", :body => [{id: 1}].to_json)
|
7
|
+
@series = LcApi::Series.find(:all)
|
8
|
+
expect(@series.class).to eq ActiveResource::Collection
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "returning a single series" do
|
13
|
+
it "should return a series" do
|
14
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/series/2.json?key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
15
|
+
@series = LcApi::Series.find(2)
|
16
|
+
expect(@series.class).to eq LcApi::Series
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "including the messages info" do
|
21
|
+
it "should include 'messages' in the url" do
|
22
|
+
# If this test passes, that means the url below was correctly called, no need for any expects
|
23
|
+
FakeWeb.register_uri(:get, "#{SITE_URL}/series/2.json?include=messages&key=1111", :body => {id: 1, foo: "bar"}.to_json)
|
24
|
+
LcApi::Series.find(2, include: [:messages])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lc_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Lesser
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activeresource
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.5'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.5'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: fakeweb
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.3'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.3'
|
94
|
+
description: A gem for consuming the LifeChurch.tv API - api.lifechurch.tv
|
95
|
+
email:
|
96
|
+
- interactive@lifechurch.tv
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- LICENSE.txt
|
104
|
+
- README.md
|
105
|
+
- Rakefile
|
106
|
+
- lc_api.gemspec
|
107
|
+
- lib/lc_api.rb
|
108
|
+
- lib/lc_api/base.rb
|
109
|
+
- lib/lc_api/location.rb
|
110
|
+
- lib/lc_api/message.rb
|
111
|
+
- lib/lc_api/series.rb
|
112
|
+
- lib/lc_api/version.rb
|
113
|
+
- spec/lc_api_spec.rb
|
114
|
+
- spec/resources/location_spec.rb
|
115
|
+
- spec/resources/message_spec.rb
|
116
|
+
- spec/resources/series_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
homepage: http://api.lifechurch.tv
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
require_paths:
|
124
|
+
- lib
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.8.23
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: LC API
|
143
|
+
test_files:
|
144
|
+
- spec/lc_api_spec.rb
|
145
|
+
- spec/resources/location_spec.rb
|
146
|
+
- spec/resources/message_spec.rb
|
147
|
+
- spec/resources/series_spec.rb
|
148
|
+
- spec/spec_helper.rb
|