sermonaudio 0.1.0

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.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rubocop.yml +15 -0
  4. data/.travis.yml +11 -0
  5. data/Gemfile +24 -0
  6. data/Gemfile.lock +127 -0
  7. data/README.md +258 -0
  8. data/Rakefile +13 -0
  9. data/lib/sermonaudio/actions.rb +99 -0
  10. data/lib/sermonaudio/client.rb +13 -0
  11. data/lib/sermonaudio/configuration.rb +37 -0
  12. data/lib/sermonaudio/version.rb +5 -0
  13. data/lib/sermonaudio.rb +13 -0
  14. data/sermonaudio.gemspec +22 -0
  15. data/spec/actions_spec.rb +236 -0
  16. data/spec/cassettes/SermonAudio_Actions/_favorite_broadcasters/should_return_the_correct_result.yml +508 -0
  17. data/spec/cassettes/SermonAudio_Actions/_favorite_sermons/should_return_the_correct_result.yml +509 -0
  18. data/spec/cassettes/SermonAudio_Actions/_favorite_speakers/should_return_the_correct_result.yml +508 -0
  19. data/spec/cassettes/SermonAudio_Actions/_get_event_types/should_return_a_larger_set_of_results.yml +521 -0
  20. data/spec/cassettes/SermonAudio_Actions/_get_event_types/should_return_a_single_result.yml +508 -0
  21. data/spec/cassettes/SermonAudio_Actions/_get_event_types/should_return_the_correct_results.yml +513 -0
  22. data/spec/cassettes/SermonAudio_Actions/_get_languages/should_return_the_correct_results.yml +506 -0
  23. data/spec/cassettes/SermonAudio_Actions/_get_newest_series_by_member_id/should_return_the_correct_results.yml +508 -0
  24. data/spec/cassettes/SermonAudio_Actions/_get_series_by_member_id/should_return_the_correct_results.yml +508 -0
  25. data/spec/cassettes/SermonAudio_Actions/_get_sermon_info/should_return_the_correct_result.yml +513 -0
  26. data/spec/cassettes/SermonAudio_Actions/_get_speakers_by_keyword/should_return_a_larger_set_of_results.yml +521 -0
  27. data/spec/cassettes/SermonAudio_Actions/_get_speakers_by_keyword/should_return_a_single_result.yml +508 -0
  28. data/spec/cassettes/SermonAudio_Actions/_get_speakers_by_member_id/should_return_the_correct_results.yml +508 -0
  29. data/spec/cassettes/SermonAudio_Actions/_newest_sermons_by_member_id/should_return_the_correct_results.yml +598 -0
  30. data/spec/cassettes/SermonAudio_Actions/_newest_sermons_by_speaker/should_return_the_correct_results.yml +599 -0
  31. data/spec/cassettes/SermonAudio_Actions/_sermon_list/should_return_a_list_of_sermons_for_the_specified_church.yml +1189 -0
  32. data/spec/cassettes/SermonAudio_Sermon/_find_newest_/success/should_find_newest_sermons_by_SpeakerName.yml +599 -0
  33. data/spec/client_spec.rb +15 -0
  34. data/spec/configuration_spec.rb +43 -0
  35. data/spec/fixtures/submit_sermon.xml +8 -0
  36. data/spec/fixtures/update_sermon.xml +6 -0
  37. data/spec/fixtures/wsdl.xml +740 -0
  38. data/spec/spec_helper.rb +46 -0
  39. metadata +134 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1bd55c912407713160da70b26af15172894f972d
4
+ data.tar.gz: 01ea84cc6e8a36ece118cbd2ab0fe22df9ec7e2a
5
+ SHA512:
6
+ metadata.gz: 628ea7e97b6bcddabbd76e0594bad2f45eb0b9fe880c6f4c9ca93cfedc47e31fc97ea4562364a6cc6a0e983112d35bf62e160c4853363b82591e0f3f2b28b52e
7
+ data.tar.gz: ebd565d6b3a57095045b955822c6fd3c29e58e83d6a1880e2f8afc232aae4974d847aa986487c55db667bc997fd91e1bd1d61f5b9e7d047217b7be2f0c3a2493
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ pkg/*
4
+ coverage/
5
+ .tags*
6
+ tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,15 @@
1
+ AllCops:
2
+ Excludes:
3
+ - spec/**
4
+
5
+ AccessorMethodName:
6
+ Enabled: false
7
+
8
+ AmbiguousOperator:
9
+ Enabled: false
10
+
11
+ Documentation:
12
+ Enabled: false
13
+
14
+ LineLength:
15
+ Max: 80
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
6
+ env: SERMONAUDIO_MEMBER_ID=example SERMONAUDIO_PASSWORD=example
7
+ before_install:
8
+ - gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
9
+ bundler_args: --without development
10
+ notifications:
11
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sermonaudio-savon.gemspec
4
+
5
+ group :development do
6
+ gem 'ruby2ruby'
7
+ gem 'rubyntlm'
8
+ end
9
+
10
+ group :development, :test do
11
+ gem 'rake'
12
+ gem 'pry'
13
+ gem 'rubocop', require: false
14
+ end
15
+
16
+ group :test do
17
+ gem 'rspec'
18
+ gem 'vcr'
19
+ gem 'webmock'
20
+ gem 'coveralls', require: false
21
+ gem 'simplecov', require: false
22
+ end
23
+
24
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,127 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sermonaudio (0.1.0)
5
+ nokogiri (= 1.6.2.1)
6
+ savon (~> 2.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ addressable (2.3.6)
12
+ akami (1.2.2)
13
+ gyoku (>= 0.4.0)
14
+ nokogiri
15
+ ast (2.0.0)
16
+ builder (3.2.2)
17
+ coderay (1.1.0)
18
+ coveralls (0.7.0)
19
+ multi_json (~> 1.3)
20
+ rest-client
21
+ simplecov (>= 0.7)
22
+ term-ansicolor
23
+ thor
24
+ crack (0.4.2)
25
+ safe_yaml (~> 1.0.0)
26
+ diff-lcs (1.2.5)
27
+ gyoku (1.1.1)
28
+ builder (>= 2.1.2)
29
+ httpi (2.2.4)
30
+ rack
31
+ json (1.8.1)
32
+ macaddr (1.7.1)
33
+ systemu (~> 2.6.2)
34
+ method_source (0.8.2)
35
+ mime-types (1.25.1)
36
+ mini_portile (0.6.0)
37
+ multi_json (1.10.1)
38
+ netrc (0.7.7)
39
+ nokogiri (1.6.2.1)
40
+ mini_portile (= 0.6.0)
41
+ nori (2.4.0)
42
+ parser (2.2.0.pre.3)
43
+ ast (>= 1.1, < 3.0)
44
+ slop (~> 3.4, >= 3.4.5)
45
+ powerpack (0.0.9)
46
+ pry (0.10.0)
47
+ coderay (~> 1.1.0)
48
+ method_source (~> 0.8.1)
49
+ slop (~> 3.4)
50
+ rack (1.5.2)
51
+ rainbow (2.0.0)
52
+ rake (10.3.2)
53
+ rest-client (1.7.2)
54
+ mime-types (>= 1.16, < 3.0)
55
+ netrc (~> 0.7)
56
+ rspec (3.0.0)
57
+ rspec-core (~> 3.0.0)
58
+ rspec-expectations (~> 3.0.0)
59
+ rspec-mocks (~> 3.0.0)
60
+ rspec-core (3.0.2)
61
+ rspec-support (~> 3.0.0)
62
+ rspec-expectations (3.0.2)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.0.0)
65
+ rspec-mocks (3.0.2)
66
+ rspec-support (~> 3.0.0)
67
+ rspec-support (3.0.2)
68
+ rubocop (0.24.1)
69
+ json (>= 1.7.7, < 2)
70
+ parser (>= 2.2.0.pre.3, < 3.0)
71
+ powerpack (~> 0.0.6)
72
+ rainbow (>= 1.99.1, < 3.0)
73
+ ruby-progressbar (~> 1.4)
74
+ ruby-progressbar (1.5.1)
75
+ ruby2ruby (2.1.1)
76
+ ruby_parser (~> 3.1)
77
+ sexp_processor (~> 4.0)
78
+ ruby_parser (3.6.2)
79
+ sexp_processor (~> 4.1)
80
+ rubyntlm (0.4.0)
81
+ safe_yaml (1.0.3)
82
+ savon (2.6.0)
83
+ akami (~> 1.2.0)
84
+ builder (>= 2.1.2)
85
+ gyoku (~> 1.1.0)
86
+ httpi (~> 2.2.3)
87
+ nokogiri (>= 1.4.0)
88
+ nori (~> 2.4.0)
89
+ uuid (~> 2.3.7)
90
+ wasabi (~> 3.3.0)
91
+ sexp_processor (4.4.3)
92
+ simplecov (0.7.1)
93
+ multi_json (~> 1.0)
94
+ simplecov-html (~> 0.7.1)
95
+ simplecov-html (0.7.1)
96
+ slop (3.6.0)
97
+ systemu (2.6.4)
98
+ term-ansicolor (1.3.0)
99
+ tins (~> 1.0)
100
+ thor (0.19.1)
101
+ tins (1.3.0)
102
+ uuid (2.3.7)
103
+ macaddr (~> 1.0)
104
+ vcr (2.9.2)
105
+ wasabi (3.3.0)
106
+ httpi (~> 2.0)
107
+ mime-types (< 2.0.0)
108
+ nokogiri (>= 1.4.0)
109
+ webmock (1.15.2)
110
+ addressable (>= 2.2.7)
111
+ crack (>= 0.3.2)
112
+
113
+ PLATFORMS
114
+ ruby
115
+
116
+ DEPENDENCIES
117
+ coveralls
118
+ pry
119
+ rake
120
+ rspec
121
+ rubocop
122
+ ruby2ruby
123
+ rubyntlm
124
+ sermonaudio!
125
+ simplecov
126
+ vcr
127
+ webmock
data/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # SermonAudio gem
2
+
3
+ The SermonAudio gem enables church ruby developers who need easily access sermons and information right from SermonAudio without having to configure any SOAP clients.
4
+
5
+ [![Build Status](https://secure.travis-ci.org/mattdbridges/sermonaudio.png)](http://travis-ci.org/mattdbridges/sermonaudio)
6
+ [![Code Climate](https://codeclimate.com/github/mattdbridges/sermonaudio.png)](https://codeclimate.com/github/mattdbridges/sermonaudio)
7
+ [![Coverage Status](https://coveralls.io/repos/mattdbridges/sermonaudio/badge.png?branch=master)](https://coveralls.io/r/mattdbridges/sermonaudio?branch=master)
8
+ [![Inline docs](http://inch-ci.org/github/mattdbridges/sermonaudio.png?branch=master)](http://inch-ci.org/github/mattdbridges/sermonaudio)
9
+
10
+ ## Installation
11
+
12
+ To install sermonaudio, add the following line to your Gemfile:
13
+
14
+ gem 'sermonaudio'
15
+
16
+ Then run bundle to install it:
17
+
18
+ bundle install
19
+
20
+ ## General Use
21
+
22
+ ### `#submit_sermon`
23
+
24
+ ```ruby
25
+ info = {
26
+ 'MemberID' => 'cbcelgin',
27
+ 'Password' => 'password',
28
+ 'Title' => 'Example Sermon',
29
+ 'ShortTitle' => 'Even Shorter',
30
+ 'SubTitle' => 'Series Name',
31
+ 'EventType' => 'Sunday Service',
32
+ 'DatePreached' => DateTime.new(2014, 7, 24),
33
+ 'Speaker' => 'Mitchell Jones',
34
+ 'BibleText' => '1 Peter 2:21-25',
35
+ 'Language' => 'English',
36
+ 'Keywords' => 'bible jesus gospel',
37
+ 'MoreInfoText' => 'This is more info about the sermon'
38
+ }
39
+ SermonAudio.submit_sermon(info)
40
+ # => "70812308178"
41
+ ```
42
+
43
+ ### `#update_sermon`
44
+
45
+ ```ruby
46
+ info = {
47
+ 'MemberID' => 'cbcelgin',
48
+ 'Password' => 'password',
49
+ 'SermonID' => '12097128382'
50
+ 'Title' => 'Example Sermon',
51
+ 'ShortTitle' => 'Even Shorter',
52
+ 'SubTitle' => 'Series Name',
53
+ 'EventType' => 'Sunday Service',
54
+ 'DatePreached' => DateTime.new(2014, 7, 24),
55
+ 'Speaker' => 'Mitchell Jones',
56
+ 'BibleText' => '1 Peter 2:21-25',
57
+ 'Language' => 'English',
58
+ 'Keywords' => 'bible jesus gospel',
59
+ 'MoreInfoText' => 'This is more info about the sermon'
60
+ }
61
+ SermonAudio.update_sermon(info)
62
+ # => nil
63
+ ```
64
+
65
+ ### `#get_sermon_info`
66
+
67
+ ```ruby
68
+ sermon_id = "720141933368"
69
+ SermonAudio.get_sermon_info(sermon_id)
70
+ # => {:sermon_id=>"720141933368",
71
+ # :title=>"Facing Death",
72
+ # :short_title=>"Facing Death",
73
+ # :sub_title=>"Psalm 23",
74
+ # :speaker=>"Mitchell Jones",
75
+ # :event_type=>"Sunday - PM",
76
+ # :bible_text=>"Psalm 23:4",
77
+ # ...
78
+ #}
79
+ ```
80
+
81
+ ### `#favorite_sermons`
82
+
83
+ ```ruby
84
+ SermonAudio.favorite_sermons
85
+ # => [{:sermon_id=>"7101111626",
86
+ # :title=>"This Is My Comfort",
87
+ # :sub_title=>nil,
88
+ # :speaker=>"Mitchell Jones",
89
+ # :event_type=>"Sunday Service",
90
+ # :bible_text=>nil,
91
+ # :date=>#<DateTime: 2011-07-10T00:00:00+00:00 ((2455753j,0s,0n),+0s,2299161j)>,
92
+ # :download_count=>"0",
93
+ # :mp3_duration=>nil,
94
+ # :mp3_filename=>nil}]
95
+ ```
96
+
97
+ ### `#favorite_speakers`
98
+
99
+ ```ruby
100
+ SermonAudio.favorite_speakers
101
+ # [{:speaker_name=>"Pastor Tim Goad", :sort_name=>"Goad, Tim", :counter=>"470"},
102
+ # {:speaker_name=>"Mitchell Jones", :sort_name=>"Jones, Mitchell", :counter=>"216"}]
103
+ ```
104
+
105
+ ### `#favorite_broadcasters`
106
+
107
+ ```ruby
108
+ SermonAudio.favorite_broadcasters
109
+ # => [{:source_id=>"cbcelgin",
110
+ # :source_desc=>"Cornerstone Baptist Church",
111
+ # :source_location=>"Elgin, Texas",
112
+ # :minister=>"Pastor Mitchell Jones"}]
113
+ ```
114
+
115
+ ### `#get_speakers_by_member_id`
116
+
117
+ ```ruby
118
+ member_id = :cbcelgin
119
+ SermonAudio.get_speakers_by_member_id(member_id)
120
+ # => ["Kevin Bridges",
121
+ # "Jim Bryant",
122
+ # "Josh Bryant",
123
+ # "Pastor Tim Goad",
124
+ # "Mitchell Jones",
125
+ # "Charles Wilson"]
126
+ ```
127
+
128
+ ### `#get_speakers_by_keyword`
129
+
130
+ ```ruby
131
+ SermonAudio.get_speakers_by_keyword("Mitchell")
132
+ # => ["Mitchell Buck",
133
+ # "Mitchell Dees",
134
+ # "Rev. Mitchell C. Dick",
135
+ # "Mitchell Gali",
136
+ # "Mitchell Jones",
137
+ # "Mitchell Mahan",
138
+ # "Esther McMitchell",
139
+ # "Rev. Ben Mitchell",
140
+ # "Benjamin Mitchell",
141
+ # "Billy Mitchell",
142
+
143
+ SermonAudio.get_speakers_by_keyword("Mitchell Jones")
144
+ # => "Mitchell Jones"
145
+ ```
146
+
147
+ ### `#get_series_by_member_id`
148
+
149
+ ```ruby
150
+ SermonAudio.get_series_by_member_id(:cbcelgin)
151
+ # => ["1 Corinthians 13", "1 Peter", "Psalm 23", "The Beatitudes", "The Nature Of Repentance"]
152
+ ```
153
+
154
+ ### `#get_newest_series_by_member_id`
155
+
156
+ ```ruby
157
+ SermonAudio.get_newest_series_by_member_id(:cbcelgin)
158
+ # => ["Psalm 23", "1 Peter", "1 Corinthians 13"]
159
+ ```
160
+
161
+ ### `#get_event_types`
162
+
163
+ ```ruby
164
+ SermonAudio.get_event_types
165
+ # => ["Audio Book",
166
+ # "Bible Study",
167
+ # "Camp Meeting",
168
+ # "Chapel Service",
169
+ # "Children",
170
+ # "Classic Audio",
171
+ # "Conference",
172
+ # "Current Events",
173
+ # "Debate",
174
+ # "Devotional",
175
+ # "Funeral Service",
176
+ # "Midweek Service",
177
+ # "Podcast",
178
+ # ....
179
+ ```
180
+
181
+ ### `#get_languages`
182
+
183
+ ```ruby
184
+ SermonAudio.get_languages
185
+ # => ["Afrikaans",
186
+ # "Arabic",
187
+ # "Burundi",
188
+ # "Catalan",
189
+ # "Chinese",
190
+ # "Choctaw",
191
+ # "Czech",
192
+ # "Danish",
193
+ # "Dutch",
194
+ # ....
195
+ ```
196
+
197
+ ### `#newest_sermons_by_member_id`
198
+
199
+ ```ruby
200
+ SermonAudio.newest_sermons_by_member_id(:cbcelgin)
201
+ # => [{:sermon_id=>"720141933368",
202
+ # :title=>"Facing Death",
203
+ # :sub_title=>"Psalm 23",
204
+ # :speaker=>"Mitchell Jones",
205
+ # :event_type=>"Sunday - PM",
206
+ # :bible_text=>"Psalm 23:4",
207
+ # :date=>#<DateTime: 2014-07-20T18:00:00+00:00 ((2456859j,64800s,0n),+0s,2299161j)>,
208
+ # :download_count=>"9",
209
+ # :mp3_duration=>"39 minutes",
210
+ # :mp3_filename=>"http://mp3.sa-media.com/filearea/720141933368/720141933368.mp3"},
211
+ # {:sermon_id=>"720141118528",
212
+ # :title=>"How to Trust God in Trying Times",
213
+ # :sub_title=>nil,
214
+ # :speaker=>"Mitchell Jones",
215
+ # ....
216
+ ```
217
+
218
+ ### `#newest_sermons_by_speaker`
219
+
220
+ ```ruby
221
+ SermonAudio.newest_sermons_by_speaker("Mitchell Jones")
222
+ # => [{:sermon_id=>"720141933368",
223
+ # :title=>"Facing Death",
224
+ # :sub_title=>"Psalm 23",
225
+ # :speaker=>"Mitchell Jones",
226
+ # :event_type=>"Sunday - PM",
227
+ # :bible_text=>"Psalm 23:4",
228
+ # :date=>#<DateTime: 2014-07-20T18:00:00+00:00 ((2456859j,64800s,0n),+0s,2299161j)>,
229
+ # :download_count=>"9",
230
+ # :mp3_duration=>"39 minutes",
231
+ # :mp3_filename=>"http://mp3.sa-media.com/filearea/720141933368/720141933368.mp3"},
232
+ # {:sermon_id=>"720141118528",
233
+ # :title=>"How to Trust God in Trying Times",
234
+ # :sub_title=>nil,
235
+ # :speaker=>"Mitchell Jones",
236
+ # ....
237
+ ```
238
+
239
+ ### `#sermon_list`
240
+
241
+ ```ruby
242
+ SermonAudio.sermon_list(:cbcelgin)
243
+ # => [{:sermon_id=>"720141933368",
244
+ # :title=>"Facing Death",
245
+ # :sub_title=>"Psalm 23",
246
+ # :speaker=>"Mitchell Jones",
247
+ # :event_type=>"Sunday - PM",
248
+ # :bible_text=>"Psalm 23:4",
249
+ # :date=>#<DateTime: 2014-07-20T18:00:00+00:00 ((2456859j,64800s,0n),+0s,2299161j)>,
250
+ # :download_count=>"9",
251
+ # :mp3_duration=>"39 minutes",
252
+ # :mp3_filename=>"http://mp3.sa-media.com/filearea/720141933368/720141933368.mp3"},
253
+ # {:sermon_id=>"720141118528",
254
+ # :title=>"How to Trust God in Trying Times",
255
+ # :sub_title=>nil,
256
+ # :speaker=>"Mitchell Jones",
257
+ # ....
258
+ ```
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
8
+ task :console do
9
+ require 'pry'
10
+ require 'sermonaudio' # You know what to do.
11
+ ARGV.clear
12
+ Pry.start
13
+ end
@@ -0,0 +1,99 @@
1
+ require 'sermonaudio/configuration'
2
+
3
+ module SermonAudio
4
+ # Actions that the SermonAudio module can call to
5
+ # retrieve data from sermonaudio.com
6
+ module Actions
7
+ def submit_sermon(info)
8
+ execute_call(__callee__, info)
9
+ end
10
+
11
+ def update_sermon(info)
12
+ execute_call(__callee__, info)
13
+ end
14
+
15
+ def get_sermon_info(sermon_id)
16
+ execute_call(__callee__,
17
+ 'MemberID' => SermonAudio.member_id,
18
+ 'Password' => SermonAudio.password,
19
+ 'SermonID' => sermon_id
20
+ )
21
+ end
22
+
23
+ def favorite_sermons
24
+ get_favorite(__callee__, within_namespace: :sermon)
25
+ end
26
+
27
+ def favorite_speakers
28
+ get_favorite(__callee__, within_namespace: :speaker)
29
+ end
30
+
31
+ def favorite_broadcasters
32
+ get_favorite(__callee__, within_namespace: :member)
33
+ end
34
+
35
+ def get_series_by_member_id(member_id)
36
+ response = execute_call(__callee__, 'MemberID' => member_id)
37
+ response[:string] || []
38
+ end
39
+
40
+ def get_speakers_by_member_id(member_id)
41
+ response = execute_call(__callee__, 'MemberID' => member_id)
42
+ response[:string] || []
43
+ end
44
+
45
+ def get_newest_series_by_member_id(member_id)
46
+ response = execute_call(__callee__, 'MemberID' => member_id)
47
+ response[:string] || []
48
+ end
49
+
50
+ def newest_sermons_by_member_id(member_id)
51
+ response = execute_call(__callee__, 'MemberID' => member_id)
52
+ response[:sermon] || []
53
+ end
54
+
55
+ def newest_sermons_by_speaker(name)
56
+ response = execute_call(__callee__, 'SpeakerName' => name)
57
+ response[:sermon] || []
58
+ end
59
+
60
+ def get_event_types
61
+ response = execute_call(__callee__)
62
+ response[:string] || []
63
+ end
64
+
65
+ def get_languages
66
+ response = execute_call(__callee__)
67
+ response[:string] || []
68
+ end
69
+
70
+ def get_speakers_by_keyword(word)
71
+ response = execute_call(__callee__, 'Keyword' => word)
72
+ response[:string] || []
73
+ end
74
+
75
+ def sermon_list(member_id)
76
+ response = execute_call(__callee__, 'MemberID' => member_id)
77
+ response[:sermon] || []
78
+ end
79
+
80
+ private
81
+
82
+ def execute_call(name, opts = {})
83
+ response = SermonAudio.client.call(name, message: opts)
84
+ response.body[:"#{name}_response"][:"#{name}_result"]
85
+ end
86
+
87
+ def array_wrap(obj)
88
+ obj.is_a?(Hash) ? [obj] : Array(obj)
89
+ end
90
+
91
+ def get_favorite(action, opts = {})
92
+ response = execute_call(action,
93
+ 'MemberID' => SermonAudio.member_id,
94
+ 'Password' => SermonAudio.password
95
+ )
96
+ array_wrap(response[opts.fetch(:within_namespace)]).compact
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,13 @@
1
+ module SermonAudio
2
+ module_function
3
+
4
+ WSDL_ENDPOINT = 'http://web4.sa-media.com/SASoapAPI/service.asmx?WSDL'
5
+
6
+ ## Setup the client
7
+ def client
8
+ Savon.client do
9
+ wsdl WSDL_ENDPOINT
10
+ soap_version 2
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,37 @@
1
+ module SermonAudio
2
+ module Configuration
3
+ class MissingConfiguration < KeyError; end
4
+
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ attr_writer :member_id, :password
11
+
12
+ def member_id
13
+ defined_or_env :member_id
14
+ end
15
+
16
+ def password
17
+ defined_or_env :password
18
+ end
19
+
20
+ private
21
+
22
+ def defined_or_env(value)
23
+ instance_variable_get("@#{value}") || environment_value(value)
24
+ end
25
+
26
+ def environment_value(name)
27
+ ENV.fetch("SERMONAUDIO_#{name.upcase}") do
28
+ message = (<<-MSG).gsub(/\s+/, ' ')
29
+ You must define a configuration.#{name}=(:value) or
30
+ set environment 'SERMONAUDIO_#{name.upcase}'.
31
+ MSG
32
+ fail MissingConfiguration, message
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ module SermonAudio
2
+ module Version
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
2
+ require 'sermonaudio/version' # Always require version
3
+ require 'savon'
4
+
5
+ # Load SermonAudio specific files
6
+ require 'sermonaudio/configuration'
7
+ require 'sermonaudio/actions'
8
+ require 'sermonaudio/client'
9
+
10
+ module SermonAudio
11
+ extend Actions
12
+ include Configuration
13
+ end
@@ -0,0 +1,22 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "sermonaudio/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "sermonaudio"
6
+ s.version = SermonAudio::Version::VERSION
7
+ s.authors = ["Matt Bridges"]
8
+ s.email = ["mbridges.91@gmail.com"]
9
+ s.homepage = "https://github.com/mattdbridges/sermonaudio"
10
+ s.summary = %q{SermonAudio API interface for Ruby.}
11
+ s.description = %q{sermonaudio uses the Savon gem to interface with SermonAudio as easily as possible.}
12
+
13
+ s.rubyforge_project = s.name
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency "savon", "~> 2.0"
21
+ s.add_dependency "nokogiri", "1.6.2.1"
22
+ end