eventify 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -0
- data/.ruby-version +1 -1
- data/.travis.yml +0 -1
- data/Gemfile +14 -14
- data/Guardfile +0 -0
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/Rakefile +0 -0
- data/eventify.gemspec +2 -2
- data/lib/eventify.rb +4 -4
- data/lib/eventify/configuration.rb +0 -0
- data/lib/eventify/database.rb +0 -0
- data/lib/eventify/mail.rb +0 -0
- data/lib/eventify/provider/apollo_kino.rb +21 -0
- data/lib/eventify/provider/base.rb +55 -55
- data/lib/eventify/provider/livenation.rb +21 -0
- data/lib/eventify/provider/piletilevi.rb +1 -1
- data/lib/eventify/version.rb +1 -1
- data/spec/eventify/configuration_spec.rb +51 -51
- data/spec/eventify/database_spec.rb +9 -9
- data/spec/eventify/mail_spec.rb +33 -33
- data/spec/eventify/provider/apollo_kino_spec.rb +25 -0
- data/spec/eventify/provider/base_spec.rb +145 -145
- data/spec/eventify/provider/livenation_spec.rb +25 -0
- data/spec/eventify/provider/piletilevi_spec.rb +46 -46
- data/spec/eventify_spec.rb +155 -155
- data/spec/spec_helper.rb +7 -0
- data/spec/support/apollo_kino.html +1021 -0
- data/spec/support/livenation.html +1444 -0
- data/spec/support/piletilevi.json +0 -0
- metadata +21 -23
- data/lib/eventify/provider/fbi.rb +0 -17
- data/lib/eventify/provider/solaris_kino.rb +0 -30
- data/spec/eventify/provider/fbi_spec.rb +0 -25
- data/spec/eventify/provider/solaris_kino_spec.rb +0 -31
- data/spec/support/fbi.html +0 -802
- data/spec/support/solaris_kino.html +0 -542
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e069144a441b2ca98eb2c985c7f4ba4ce06c44723c8821937185d566eab225a7
|
4
|
+
data.tar.gz: 2bd32d243eaf11b5080295606715d18b2ed9a35576cfa1377a4ad1c571eb879f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e81cef2358780927c2d9ebce6668641385c54d8c1a526b75a42649901bd19709943eed031a07f5c5ac0575f48a639a6dc8275153d42d1957539f07951b60c40d
|
7
|
+
data.tar.gz: 8085db677f434f04fa5fd793a2c74b9e7d095d20a36660e54b55ea3f541774687e85c1b7bb75ce8858061aba72db9adfdbb75dac406b454bf95cdbf744ac2457
|
data/.gitignore
CHANGED
File without changes
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.5
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
group :development do
|
4
|
-
gem "guard"
|
5
|
-
gem "guard-rspec"
|
6
|
-
gem "guard-bundler"
|
7
|
-
gem "wdm", platform: :mingw
|
8
|
-
gem "win32console", platform: :mingw
|
9
|
-
gem "ruby_gntp"
|
10
|
-
end
|
11
|
-
|
12
|
-
gemspec
|
13
|
-
|
14
|
-
gem "coveralls", require: false
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem "guard"
|
5
|
+
gem "guard-rspec"
|
6
|
+
gem "guard-bundler"
|
7
|
+
gem "wdm", platform: :mingw
|
8
|
+
gem "win32console", platform: :mingw
|
9
|
+
gem "ruby_gntp"
|
10
|
+
end
|
11
|
+
|
12
|
+
gemspec
|
13
|
+
|
14
|
+
gem "coveralls", require: false
|
data/Guardfile
CHANGED
File without changes
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -38,9 +38,9 @@ providers/organizers in an aggregate way.
|
|
38
38
|
|
39
39
|
The following providers are currently supported:
|
40
40
|
|
41
|
-
* [
|
41
|
+
* [Livenation](https://livenation.ee)
|
42
42
|
* [Piletilevi](http://www.piletilevi.ee/)
|
43
|
-
* [
|
43
|
+
* [Apollo Kino](https://www.apollokino.ee/)
|
44
44
|
|
45
45
|
## Adding New Providers
|
46
46
|
|
data/Rakefile
CHANGED
File without changes
|
data/eventify.gemspec
CHANGED
@@ -19,9 +19,9 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "simple-rss"
|
22
|
-
spec.add_dependency "nokogiri"
|
22
|
+
spec.add_dependency "nokogiri", "~> 1.11.0"
|
23
23
|
spec.add_dependency "sqlite3"
|
24
|
-
spec.add_dependency "mail"
|
24
|
+
spec.add_dependency "mail", "~> 2.7.0.rc1"
|
25
25
|
spec.add_dependency "faraday"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
data/lib/eventify.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require File.expand_path("eventify/version", __dir__)
|
2
2
|
require File.expand_path("eventify/configuration", __dir__)
|
3
3
|
require File.expand_path("eventify/provider/base", __dir__)
|
4
|
-
require File.expand_path("eventify/provider/
|
4
|
+
require File.expand_path("eventify/provider/livenation", __dir__)
|
5
5
|
require File.expand_path("eventify/provider/piletilevi", __dir__)
|
6
|
-
require File.expand_path("eventify/provider/
|
6
|
+
require File.expand_path("eventify/provider/apollo_kino", __dir__)
|
7
7
|
require File.expand_path("eventify/database", __dir__)
|
8
8
|
require File.expand_path("eventify/mail", __dir__)
|
9
9
|
|
@@ -35,8 +35,8 @@ class Eventify
|
|
35
35
|
def providers
|
36
36
|
@providers ||= [
|
37
37
|
Eventify::Provider::Piletilevi,
|
38
|
-
Eventify::Provider::
|
39
|
-
Eventify::Provider::
|
38
|
+
Eventify::Provider::Livenation,
|
39
|
+
Eventify::Provider::ApolloKino
|
40
40
|
]
|
41
41
|
end
|
42
42
|
end
|
File without changes
|
data/lib/eventify/database.rb
CHANGED
File without changes
|
data/lib/eventify/mail.rb
CHANGED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "nokogiri"
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
module Eventify::Provider
|
6
|
+
class ApolloKino < Base
|
7
|
+
URL = "https://www.apollokino.ee/"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def fetch
|
11
|
+
doc = Nokogiri::HTML(open(URI.join(URL, "eng/soon"), {"Accept-Encoding" => "gzip,deflate"}))
|
12
|
+
doc.search(".EventList-container > div").map do |item|
|
13
|
+
title_node = item.at("h2 a")
|
14
|
+
url = URI.join(URL, title_node["href"]).to_s
|
15
|
+
date = Time.strptime(item.at(".event-releaseDate b").content, "%d.%m.%Y")
|
16
|
+
new id: url, title: title_node.content, link: url, date: date
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
class Eventify
|
2
|
-
module Provider
|
3
|
-
class Base
|
4
|
-
include Comparable
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def fetch
|
8
|
-
raise NotImplementedError
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
attr_reader :id, :title, :link, :date
|
13
|
-
|
14
|
-
def initialize(event)
|
15
|
-
@id = event[:id] or raise MissingAttributeError.new("id is missing")
|
16
|
-
@title = event[:title] or raise MissingAttributeError.new("title is missing")
|
17
|
-
@link = event[:link] or raise MissingAttributeError.new("link is missing")
|
18
|
-
@date = event[:date]
|
19
|
-
end
|
20
|
-
|
21
|
-
def provider
|
22
|
-
@provider ||= self.class.name
|
23
|
-
end
|
24
|
-
|
25
|
-
def save
|
26
|
-
Database.save self
|
27
|
-
self
|
28
|
-
end
|
29
|
-
|
30
|
-
def exists?
|
31
|
-
Database.exists? self
|
32
|
-
end
|
33
|
-
|
34
|
-
def ==(other)
|
35
|
-
id == other.id &&
|
36
|
-
provider == other.provider &&
|
37
|
-
title == other.title &&
|
38
|
-
link == other.link &&
|
39
|
-
date.to_i == other.date.to_i
|
40
|
-
end
|
41
|
-
|
42
|
-
alias_method :eql?, :==
|
43
|
-
|
44
|
-
def hash
|
45
|
-
"#{id}-#{provider}-#{title}-#{link}-#{date.to_i}".hash
|
46
|
-
end
|
47
|
-
|
48
|
-
def <=>(other)
|
49
|
-
title <=> other.title
|
50
|
-
end
|
51
|
-
|
52
|
-
MissingAttributeError = Class.new(RuntimeError)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
class Eventify
|
2
|
+
module Provider
|
3
|
+
class Base
|
4
|
+
include Comparable
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def fetch
|
8
|
+
raise NotImplementedError
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_reader :id, :title, :link, :date
|
13
|
+
|
14
|
+
def initialize(event)
|
15
|
+
@id = event[:id] or raise MissingAttributeError.new("id is missing")
|
16
|
+
@title = event[:title] or raise MissingAttributeError.new("title is missing")
|
17
|
+
@link = event[:link] or raise MissingAttributeError.new("link is missing")
|
18
|
+
@date = event[:date]
|
19
|
+
end
|
20
|
+
|
21
|
+
def provider
|
22
|
+
@provider ||= self.class.name
|
23
|
+
end
|
24
|
+
|
25
|
+
def save
|
26
|
+
Database.save self
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def exists?
|
31
|
+
Database.exists? self
|
32
|
+
end
|
33
|
+
|
34
|
+
def ==(other)
|
35
|
+
id == other.id &&
|
36
|
+
provider == other.provider &&
|
37
|
+
title == other.title &&
|
38
|
+
link == other.link &&
|
39
|
+
date.to_i == other.date.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
alias_method :eql?, :==
|
43
|
+
|
44
|
+
def hash
|
45
|
+
"#{id}-#{provider}-#{title}-#{link}-#{date.to_i}".hash
|
46
|
+
end
|
47
|
+
|
48
|
+
def <=>(other)
|
49
|
+
title <=> other.title
|
50
|
+
end
|
51
|
+
|
52
|
+
MissingAttributeError = Class.new(RuntimeError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
require "nokogiri"
|
3
|
+
require "json"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Eventify::Provider
|
7
|
+
class Livenation < Base
|
8
|
+
URL = "https://www.livenation.ee/event/allevents"
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def fetch
|
12
|
+
doc = Nokogiri::HTML(open(URL))
|
13
|
+
doc.search("script[type='application/ld+json']").map do |raw_item|
|
14
|
+
item = JSON.parse(raw_item.content)
|
15
|
+
next unless item["name"]
|
16
|
+
new id: item["url"], title: item["name"], link: item["url"], date: Time.parse(item["startDate"])
|
17
|
+
end.compact
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -3,7 +3,7 @@ require "json"
|
|
3
3
|
|
4
4
|
module Eventify::Provider
|
5
5
|
class Piletilevi < Base
|
6
|
-
URL = URI.parse("
|
6
|
+
URL = URI.parse("https://www.piletilevi.ee/ajaxCaller/method:getConcertsListInfo/id:1089/type:catalog_category")
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def fetch
|
data/lib/eventify/version.rb
CHANGED
@@ -1,51 +1,51 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Eventify::Configuration do
|
4
|
-
before do
|
5
|
-
stub_const "Eventify::Configuration::PATH", File.join(Dir.tmpdir, "eventify-config.yml")
|
6
|
-
File.delete Eventify::Configuration::PATH if File.exists? Eventify::Configuration::PATH
|
7
|
-
end
|
8
|
-
|
9
|
-
context "#initialize" do
|
10
|
-
it "has default settings by default" do
|
11
|
-
configuration = Eventify::Configuration.new
|
12
|
-
configuration[:subscribers].
|
13
|
-
configuration[:mail].
|
14
|
-
end
|
15
|
-
|
16
|
-
it "allows to override settings" do
|
17
|
-
File.open(Eventify::Configuration::PATH, "w") { |f| f.write YAML.dump(foo: "baz") }
|
18
|
-
|
19
|
-
configuration = Eventify::Configuration.new(foo: "bar")
|
20
|
-
configuration[:foo].
|
21
|
-
configuration[:subscribers].
|
22
|
-
end
|
23
|
-
|
24
|
-
it "loads settings from file too" do
|
25
|
-
File.open(Eventify::Configuration::PATH, "w") { |f| f.write YAML.dump(bar: "foo") }
|
26
|
-
|
27
|
-
configuration = Eventify::Configuration.new(foo: "bar")
|
28
|
-
configuration[:foo].
|
29
|
-
configuration[:bar].
|
30
|
-
configuration[:subscribers].
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "#save" do
|
35
|
-
it "saves config as yaml" do
|
36
|
-
Eventify::Configuration.new(foo: "bar").save
|
37
|
-
YAML.load(File.read(Eventify::Configuration::PATH))[:foo].
|
38
|
-
end
|
39
|
-
|
40
|
-
it "saves subscribers as an array even if it is specified as a string" do
|
41
|
-
Eventify::Configuration.new(subscribers: "foo@bar.com").save
|
42
|
-
YAML.load(File.read(Eventify::Configuration::PATH))[:subscribers].
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "#[]" do
|
47
|
-
it "retrieves configuration setting" do
|
48
|
-
Eventify::Configuration.new(baz: "bar")[:baz].
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Eventify::Configuration do
|
4
|
+
before do
|
5
|
+
stub_const "Eventify::Configuration::PATH", File.join(Dir.tmpdir, "eventify-config.yml")
|
6
|
+
File.delete Eventify::Configuration::PATH if File.exists? Eventify::Configuration::PATH
|
7
|
+
end
|
8
|
+
|
9
|
+
context "#initialize" do
|
10
|
+
it "has default settings by default" do
|
11
|
+
configuration = Eventify::Configuration.new
|
12
|
+
expect(configuration[:subscribers]).to eq(["user@example.org"])
|
13
|
+
expect(configuration[:mail]).to eq(Mail.delivery_method.settings.merge(openssl_verify_mode: "none"))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "allows to override settings" do
|
17
|
+
File.open(Eventify::Configuration::PATH, "w") { |f| f.write YAML.dump(foo: "baz") }
|
18
|
+
|
19
|
+
configuration = Eventify::Configuration.new(foo: "bar")
|
20
|
+
expect(configuration[:foo]).to eq("bar")
|
21
|
+
expect(configuration[:subscribers]).to eq(["user@example.org"])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "loads settings from file too" do
|
25
|
+
File.open(Eventify::Configuration::PATH, "w") { |f| f.write YAML.dump(bar: "foo") }
|
26
|
+
|
27
|
+
configuration = Eventify::Configuration.new(foo: "bar")
|
28
|
+
expect(configuration[:foo]).to eq("bar")
|
29
|
+
expect(configuration[:bar]).to eq("foo")
|
30
|
+
expect(configuration[:subscribers]).to eq(["user@example.org"])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "#save" do
|
35
|
+
it "saves config as yaml" do
|
36
|
+
Eventify::Configuration.new(foo: "bar").save
|
37
|
+
expect(YAML.load(File.read(Eventify::Configuration::PATH))[:foo]).to eq("bar")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "saves subscribers as an array even if it is specified as a string" do
|
41
|
+
Eventify::Configuration.new(subscribers: "foo@bar.com").save
|
42
|
+
expect(YAML.load(File.read(Eventify::Configuration::PATH))[:subscribers]).to eq(["foo@bar.com"])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "#[]" do
|
47
|
+
it "retrieves configuration setting" do
|
48
|
+
expect(Eventify::Configuration.new(baz: "bar")[:baz]).to eq("bar")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -19,8 +19,8 @@ describe Eventify::Database do
|
|
19
19
|
)
|
20
20
|
Eventify::Database.save event2
|
21
21
|
|
22
|
-
Eventify::Database.events.size.
|
23
|
-
Eventify::Database.events.
|
22
|
+
expect(Eventify::Database.events.size).to eq(2)
|
23
|
+
expect(Eventify::Database.events).to eq([event1, event2])
|
24
24
|
end
|
25
25
|
|
26
26
|
it "raises an error when event already exists" do
|
@@ -34,7 +34,7 @@ describe Eventify::Database do
|
|
34
34
|
|
35
35
|
expect {
|
36
36
|
Eventify::Database.save event
|
37
|
-
}.to raise_error
|
37
|
+
}.to raise_error(SQLite3::ConstraintException)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -48,7 +48,7 @@ describe Eventify::Database do
|
|
48
48
|
)
|
49
49
|
Eventify::Database.save(event)
|
50
50
|
|
51
|
-
Eventify::Database.
|
51
|
+
expect(Eventify::Database).to exist(event)
|
52
52
|
end
|
53
53
|
|
54
54
|
it "false when event does not exist" do
|
@@ -59,7 +59,7 @@ describe Eventify::Database do
|
|
59
59
|
date: Time.parse("2013-12-27 12:30:11"),
|
60
60
|
)
|
61
61
|
|
62
|
-
Eventify::Database.
|
62
|
+
expect(Eventify::Database).not_to exist(event)
|
63
63
|
end
|
64
64
|
|
65
65
|
it "false when event id is different" do
|
@@ -78,7 +78,7 @@ describe Eventify::Database do
|
|
78
78
|
date: Time.parse("2013-12-27 12:30:11"),
|
79
79
|
)
|
80
80
|
|
81
|
-
Eventify::Database.
|
81
|
+
expect(Eventify::Database).not_to exist(event2)
|
82
82
|
end
|
83
83
|
|
84
84
|
it "false when event link is different" do
|
@@ -97,7 +97,7 @@ describe Eventify::Database do
|
|
97
97
|
date: Time.parse("2013-12-27 12:30:11"),
|
98
98
|
)
|
99
99
|
|
100
|
-
Eventify::Database.
|
100
|
+
expect(Eventify::Database).not_to exist(event2)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "false when event provider is different" do
|
@@ -116,7 +116,7 @@ describe Eventify::Database do
|
|
116
116
|
date: Time.parse("2013-12-27 12:30:11"),
|
117
117
|
)
|
118
118
|
|
119
|
-
Eventify::Database.
|
119
|
+
expect(Eventify::Database).not_to exist(event2)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -137,6 +137,6 @@ describe Eventify::Database do
|
|
137
137
|
)
|
138
138
|
Eventify::Database.save(event2)
|
139
139
|
|
140
|
-
Eventify::Database.events.
|
140
|
+
expect(Eventify::Database.events).to eq([event1, event2])
|
141
141
|
end
|
142
142
|
end
|