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 ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lc_api.gemspec
4
+ gemspec
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
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
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
@@ -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
@@ -0,0 +1,4 @@
1
+ module LcApi
2
+ class Location < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LcApi
2
+ class Message < Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module LcApi
2
+ class Series < Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module LcApi
2
+ VERSION = "0.2"
3
+ end
data/lib/lc_api.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'active_resource'
2
+ require 'lc_api/base'
3
+ require 'lc_api/message'
4
+ require 'lc_api/series'
5
+ require 'lc_api/location'
6
+
7
+ module LcApi
8
+ class << self
9
+ attr_accessor :key
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe LcApi do
4
+ it "should set the key" do
5
+ LcApi.key = "1111"
6
+ expect(LcApi.key).to eq "1111"
7
+ end
8
+
9
+ it "should set the site" do
10
+ expect(LcApi::Base.site.to_s).to eq SITE_URL
11
+ end
12
+ end
@@ -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
@@ -0,0 +1,5 @@
1
+ require 'lc_api'
2
+ require 'fakeweb'
3
+ FakeWeb.allow_net_connect = false
4
+ LcApi.key = "1111"
5
+ SITE_URL = "http://lctv-api.herokuapp.com/v1"
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