url_2_event 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +302 -0
  5. data/CONTRIBUTING.md +124 -0
  6. data/Gemfile +2 -0
  7. data/Guardfile +16 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +64 -0
  10. data/Rakefile +2 -0
  11. data/lib/url_2_event.rb +52 -0
  12. data/lib/url_2_event/adapters/eventbrite.rb +68 -0
  13. data/lib/url_2_event/adapters/meetup.rb +72 -0
  14. data/lib/url_2_event/base.rb +43 -0
  15. data/lib/url_2_event/event.rb +4 -0
  16. data/lib/url_2_event/version.rb +3 -0
  17. data/script/console.rb +8 -0
  18. data/spec/cassettes/Url2Event/_parse_event_from_uri/.yml +95 -0
  19. data/spec/cassettes/Url2Event_Eventbrite/get_event/.yml +270 -0
  20. data/spec/cassettes/Url2Event_Eventbrite/get_event/begin_at/.yml +270 -0
  21. data/spec/cassettes/Url2Event_Eventbrite/get_event/description/.yml +270 -0
  22. data/spec/cassettes/Url2Event_Eventbrite/get_event/end_at/.yml +270 -0
  23. data/spec/cassettes/Url2Event_Eventbrite/get_event/link/.yml +270 -0
  24. data/spec/cassettes/Url2Event_Eventbrite/get_event/location/.yml +270 -0
  25. data/spec/cassettes/Url2Event_Eventbrite/get_event/title/.yml +270 -0
  26. data/spec/cassettes/Url2Event_Meetup/get_event/.yml +209 -0
  27. data/spec/cassettes/Url2Event_Meetup/get_event/begin_at/.yml +209 -0
  28. data/spec/cassettes/Url2Event_Meetup/get_event/description/.yml +209 -0
  29. data/spec/cassettes/Url2Event_Meetup/get_event/end_at/.yml +209 -0
  30. data/spec/cassettes/Url2Event_Meetup/get_event/location/.yml +209 -0
  31. data/spec/cassettes/Url2Event_Meetup/get_event/price/.yml +209 -0
  32. data/spec/cassettes/Url2Event_Meetup/get_event/title/.yml +209 -0
  33. data/spec/eventbrite_spec.rb +33 -0
  34. data/spec/meetup_spec.rb +31 -0
  35. data/spec/spec_helper.rb +32 -0
  36. data/spec/url_2_event_spec.rb +33 -0
  37. data/url_2_event.gemspec +35 -0
  38. metadata +295 -0
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe Url2Event::Eventbrite do
4
+ let(:url) { URI.parse("http://www.eventbrite.com/e/startup-weekend-seattle-0822-tickets-12095703575?aff=eac2") }
5
+ let(:uk_url) { URI.parse("http://www.eventbrite.co.uk/e/london-fintech-startups-tmufintech-tickets-10220306211?aff=es2&rank=11") }
6
+
7
+ describe ".is_parser_for?" do
8
+ it { expect(described_class.is_parser_for?(url)).to eql(true) }
9
+ it { expect(described_class.is_parser_for?(uk_url)).to eql(true) }
10
+ end
11
+
12
+ describe "get_event", :vcr do
13
+ let(:begin_at) { Time.parse("2014-10-03 18:00:00 +0000") }
14
+ let(:end_at) { Time.parse("2014-10-05 21:00:00 +0000") }
15
+ let(:parser) { described_class.new(url) }
16
+ subject { parser.get_event }
17
+
18
+ it { should be_instance_of(Event) }
19
+ its(:title) { should eql("Startup Weekend Seattle 10/3") }
20
+ its(:location) { should eql("Zillow Seattle Headquarters") }
21
+ its(:description) { should_not include("<") }
22
+ its(:begin_at) { should eql(begin_at) }
23
+ its(:end_at) { should eql(end_at) }
24
+ its(:link) { should eql("http://swseattle0814.eventbrite.com") }
25
+
26
+ context "when the url is unparsable" do
27
+ let(:unparsable) { URI.parse("http://www.eventbrite.com/home") }
28
+ let(:parser) { described_class.new(unparsable) }
29
+ subject { -> {parser.get_event } }
30
+ it { should raise_error(Url2Event::UnparsableSourceError) }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe Url2Event::Meetup do
4
+ let(:url) { URI.parse("http://www.meetup.com/Startup-Grind-Seattle/events/187282242/") }
5
+ describe ".is_parser_for?" do
6
+ it { expect(described_class.is_parser_for?(url)).to eql(true) }
7
+ end
8
+
9
+ describe "get_event", :vcr do
10
+ let(:begin_at) { Time.parse("2014-07-29 18:00:00 +0000") }
11
+ let(:end_at) { Time.parse("2014-07-29 21:00:00 +0000") }
12
+ let(:parser) { described_class.new(url) }
13
+
14
+ subject { parser.get_event }
15
+
16
+ it { should be_instance_of(Event) }
17
+ its(:title) { should eql("Startup Grind Seattle Hosts Robert Scoble, Tech Geek (Rackspace)") }
18
+ its(:begin_at) { should eql(begin_at) }
19
+ its(:end_at) { should eql(end_at) }
20
+ its(:location) { should eql("Dice Cabana at SURF, 821 2nd Avenue #410, Seattle") }
21
+ its(:description) { should_not include("<") }
22
+ its(:price) { should be_nil }
23
+
24
+ context "when the url is unparsable" do
25
+ let(:unparsable) { URI.parse("http://www.meetup.com/Startup-Grind-Seattle") }
26
+ let(:parser) { described_class.new(unparsable) }
27
+ subject { -> { parser.get_event } }
28
+ it { should raise_error(Url2Event::UnparsableSourceError) }
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
9
+
10
+ require 'bundler/setup'
11
+ Bundler.setup
12
+
13
+ require 'url_2_event' # and any other gems you need
14
+
15
+ require 'vcr'
16
+ require 'rspec/its'
17
+ require 'ap'
18
+
19
+ require 'dotenv'
20
+ Dotenv.load
21
+
22
+ VCR.configure do |c|
23
+ c.cassette_library_dir = 'spec/cassettes'
24
+ c.hook_into :webmock
25
+ c.configure_rspec_metadata!
26
+ c.filter_sensitive_data('<EVENTBRITE_TOKEN>') { ENV['EVENTBRITE_TOKEN'] }
27
+ c.filter_sensitive_data('<MEETUP_API_KEY>') { ENV['MEETUP_API_KEY'] }
28
+ end
29
+
30
+ RSpec.configure do |config|
31
+ # some (optional) config here
32
+ end
@@ -0,0 +1,33 @@
1
+ describe Url2Event, :vcr do
2
+ describe ".parse_event_from_uri" do
3
+ let(:url) { "http://www.meetup.com/BKtechmeetup/events/191161262/" }
4
+ subject { Url2Event.parse_event_from_uri(url) }
5
+ it { should be_instance_of(Event) }
6
+
7
+ context "when given an invalid url." do
8
+ let(:bad_url) { "catscats::///////www//w////ww/coom" }
9
+ subject(:parser) {-> { Url2Event.parse_event_from_uri(bad_url) } }
10
+ it { expect(parser).to raise_error(Url2Event::InvalidURLError) }
11
+ end
12
+ end
13
+
14
+ describe ".get_parser_class" do
15
+ context "when given a meetup event" do
16
+ let(:url) { URI.parse("http://www.meetup.com/BKtechmeetup/events/191161262/") }
17
+ subject(:parser) { Url2Event.get_parser_class(url) }
18
+ it { expect(parser).to be(Url2Event::Meetup) }
19
+ end
20
+
21
+ context "when given an eventbrite event." do
22
+ let(:url) { URI.parse("http://www.eventbrite.com/e/startup-weekend-seattle-0822-tickets-12095703575?aff=eac2") }
23
+ subject(:parser) { Url2Event.get_parser_class(url) }
24
+ it { expect(parser).to be(Url2Event::Eventbrite) }
25
+ end
26
+
27
+ context "when given an unsupported url." do
28
+ let(:url) { URI.parse("http://www.geekwire.com/events/sounders-day-2014/") }
29
+ subject(:parser) { -> { Url2Event.get_parser_class(url)} }
30
+ it { expect(parser).to raise_error(Url2Event::UnsupportedSourceError) }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'url_2_event/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "url_2_event"
8
+ spec.version = Url2Event::VERSION
9
+ spec.authors = ["hank"]
10
+ spec.email = ["hstove@gmail.com"]
11
+ spec.summary = %q(A ruby gem for getting metadata from event URLs)
12
+ spec.homepage = "https://github.com/startupweekend/url_2_event"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'hashie', '~> 3.3.1'
21
+ spec.add_dependency 'httparty', '~> 0.13.3'
22
+ spec.add_dependency 'rails-html-sanitizer', '~> 1.0.1'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'vcr'
28
+ spec.add_development_dependency 'webmock'
29
+ spec.add_development_dependency 'rspec-its'
30
+ spec.add_development_dependency 'awesome_print'
31
+ spec.add_development_dependency 'dotenv'
32
+ spec.add_development_dependency 'guard-rspec'
33
+ spec.add_development_dependency 'simplecov'
34
+ spec.add_development_dependency 'coveralls'
35
+ end
metadata ADDED
@@ -0,0 +1,295 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: url_2_event
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - hank
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hashie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.13.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.13.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails-html-sanitizer
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.1
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: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.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
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec-its
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: awesome_print
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: dotenv
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: guard-rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: coveralls
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ description:
210
+ email:
211
+ - hstove@gmail.com
212
+ executables: []
213
+ extensions: []
214
+ extra_rdoc_files: []
215
+ files:
216
+ - ".gitignore"
217
+ - ".rspec"
218
+ - ".rubocop.yml"
219
+ - CONTRIBUTING.md
220
+ - Gemfile
221
+ - Guardfile
222
+ - LICENSE.txt
223
+ - README.md
224
+ - Rakefile
225
+ - lib/url_2_event.rb
226
+ - lib/url_2_event/adapters/eventbrite.rb
227
+ - lib/url_2_event/adapters/meetup.rb
228
+ - lib/url_2_event/base.rb
229
+ - lib/url_2_event/event.rb
230
+ - lib/url_2_event/version.rb
231
+ - script/console.rb
232
+ - spec/cassettes/Url2Event/_parse_event_from_uri/.yml
233
+ - spec/cassettes/Url2Event_Eventbrite/get_event/.yml
234
+ - spec/cassettes/Url2Event_Eventbrite/get_event/begin_at/.yml
235
+ - spec/cassettes/Url2Event_Eventbrite/get_event/description/.yml
236
+ - spec/cassettes/Url2Event_Eventbrite/get_event/end_at/.yml
237
+ - spec/cassettes/Url2Event_Eventbrite/get_event/link/.yml
238
+ - spec/cassettes/Url2Event_Eventbrite/get_event/location/.yml
239
+ - spec/cassettes/Url2Event_Eventbrite/get_event/title/.yml
240
+ - spec/cassettes/Url2Event_Meetup/get_event/.yml
241
+ - spec/cassettes/Url2Event_Meetup/get_event/begin_at/.yml
242
+ - spec/cassettes/Url2Event_Meetup/get_event/description/.yml
243
+ - spec/cassettes/Url2Event_Meetup/get_event/end_at/.yml
244
+ - spec/cassettes/Url2Event_Meetup/get_event/location/.yml
245
+ - spec/cassettes/Url2Event_Meetup/get_event/price/.yml
246
+ - spec/cassettes/Url2Event_Meetup/get_event/title/.yml
247
+ - spec/eventbrite_spec.rb
248
+ - spec/meetup_spec.rb
249
+ - spec/spec_helper.rb
250
+ - spec/url_2_event_spec.rb
251
+ - url_2_event.gemspec
252
+ homepage: https://github.com/startupweekend/url_2_event
253
+ licenses:
254
+ - MIT
255
+ metadata: {}
256
+ post_install_message:
257
+ rdoc_options: []
258
+ require_paths:
259
+ - lib
260
+ required_ruby_version: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: '0'
265
+ required_rubygems_version: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ requirements: []
271
+ rubyforge_project:
272
+ rubygems_version: 2.4.1
273
+ signing_key:
274
+ specification_version: 4
275
+ summary: A ruby gem for getting metadata from event URLs
276
+ test_files:
277
+ - spec/cassettes/Url2Event/_parse_event_from_uri/.yml
278
+ - spec/cassettes/Url2Event_Eventbrite/get_event/.yml
279
+ - spec/cassettes/Url2Event_Eventbrite/get_event/begin_at/.yml
280
+ - spec/cassettes/Url2Event_Eventbrite/get_event/description/.yml
281
+ - spec/cassettes/Url2Event_Eventbrite/get_event/end_at/.yml
282
+ - spec/cassettes/Url2Event_Eventbrite/get_event/link/.yml
283
+ - spec/cassettes/Url2Event_Eventbrite/get_event/location/.yml
284
+ - spec/cassettes/Url2Event_Eventbrite/get_event/title/.yml
285
+ - spec/cassettes/Url2Event_Meetup/get_event/.yml
286
+ - spec/cassettes/Url2Event_Meetup/get_event/begin_at/.yml
287
+ - spec/cassettes/Url2Event_Meetup/get_event/description/.yml
288
+ - spec/cassettes/Url2Event_Meetup/get_event/end_at/.yml
289
+ - spec/cassettes/Url2Event_Meetup/get_event/location/.yml
290
+ - spec/cassettes/Url2Event_Meetup/get_event/price/.yml
291
+ - spec/cassettes/Url2Event_Meetup/get_event/title/.yml
292
+ - spec/eventbrite_spec.rb
293
+ - spec/meetup_spec.rb
294
+ - spec/spec_helper.rb
295
+ - spec/url_2_event_spec.rb