eventify 1.5.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cf2de810d16c9e34e479540bef9bc61f7a9469877b38b3ef602e40815dd7c56
4
- data.tar.gz: 82c61a8c2a5a43cced1a816f6fc6bd283d108e4a7e752a341afa461512450932
3
+ metadata.gz: e069144a441b2ca98eb2c985c7f4ba4ce06c44723c8821937185d566eab225a7
4
+ data.tar.gz: 2bd32d243eaf11b5080295606715d18b2ed9a35576cfa1377a4ad1c571eb879f
5
5
  SHA512:
6
- metadata.gz: deb55b2cd663ff8947ad496b48b84076b3f59c48eab5bc94389ef125d4180e4affd8a3e723fb05117bb00db90f7b8e3b0a667c8f8bceecf85e5d6f9d8d38b901
7
- data.tar.gz: 597fd8b493717b0030ca2431689501cbe53431b0b995a3a7196f3ce878e04b628f4d519950b84633cf62d385aa08e920660711956f112c883f7149b7b1712573
6
+ metadata.gz: e81cef2358780927c2d9ebce6668641385c54d8c1a526b75a42649901bd19709943eed031a07f5c5ac0575f48a639a6dc8275153d42d1957539f07951b60c40d
7
+ data.tar.gz: 8085db677f434f04fa5fd793a2c74b9e7d095d20a36660e54b55ea3f541774687e85c1b7bb75ce8858061aba72db9adfdbb75dac406b454bf95cdbf744ac2457
data/.gitignore CHANGED
File without changes
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.5.5
File without changes
data/Gemfile CHANGED
File without changes
data/Guardfile CHANGED
File without changes
data/LICENSE CHANGED
File without changes
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
- * [FBI](http://fbi.ee)
41
+ * [Livenation](https://livenation.ee)
42
42
  * [Piletilevi](http://www.piletilevi.ee/)
43
- * [Solaris Kino](http://solariskino.ee/)
43
+ * [Apollo Kino](https://www.apollokino.ee/)
44
44
 
45
45
  ## Adding New Providers
46
46
 
data/Rakefile CHANGED
File without changes
@@ -19,7 +19,7 @@ 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", "~> 1.8.5"
22
+ spec.add_dependency "nokogiri", "~> 1.11.0"
23
23
  spec.add_dependency "sqlite3"
24
24
  spec.add_dependency "mail", "~> 2.7.0.rc1"
25
25
  spec.add_dependency "faraday"
@@ -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/fbi", __dir__)
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/solaris_kino", __dir__)
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::FBI,
39
- Eventify::Provider::SolarisKino
38
+ Eventify::Provider::Livenation,
39
+ Eventify::Provider::ApolloKino
40
40
  ]
41
41
  end
42
42
  end
File without changes
File without changes
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
File without changes
@@ -1,3 +1,3 @@
1
1
  class Eventify
2
- VERSION = "1.5.4"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -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].should == ["user@example.org"]
13
- configuration[:mail].should == 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
- configuration[:foo].should == "bar"
21
- configuration[:subscribers].should == ["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
- configuration[:foo].should == "bar"
29
- configuration[:bar].should == "foo"
30
- configuration[:subscribers].should == ["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
- YAML.load(File.read(Eventify::Configuration::PATH))[:foo].should == "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
- YAML.load(File.read(Eventify::Configuration::PATH))[:subscribers].should == ["foo@bar.com"]
43
- end
44
- end
45
-
46
- context "#[]" do
47
- it "retrieves configuration setting" do
48
- Eventify::Configuration.new(baz: "bar")[:baz].should == "bar"
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.should == 2
23
- Eventify::Database.events.should == [event1, event2]
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.should exist(event)
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.should_not exist(event)
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.should_not exist(event2)
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.should_not exist(event2)
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.should_not exist(event2)
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.should == [event1, event2]
140
+ expect(Eventify::Database.events).to eq([event1, event2])
141
141
  end
142
142
  end
@@ -1,33 +1,33 @@
1
- require "spec_helper"
2
-
3
- describe Eventify::Mail do
4
- context ".deliver" do
5
- it "sends e-mail to all subscribers" do
6
- ::Mail.should_receive(:deliver).twice
7
-
8
- Eventify::Mail.deliver([], Eventify::Configuration.new(subscribers: ["foo@example.org", "bar@example.org"]))
9
- end
10
- end
11
-
12
- it ".format" do
13
- new_events = [
14
- Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org/1", date: Time.now),
15
- Eventify::Provider::Piletilevi.new(id: "456", title: "bar", link: "http://example.org/2", date: Time.now),
16
- Eventify::Provider::Base.new(id: "456", title: "bar3", link: "http://example.org/3", date: Time.now)
17
- ]
18
-
19
- Eventify::Mail.format(new_events).should == "There are some rumours going on about 3 possible awesome events:
20
-
21
- * bar
22
- http://example.org/2
23
-
24
- * bar3
25
- http://example.org/3
26
-
27
- * foo
28
- http://example.org/1
29
-
30
- Your Humble Servant,
31
- Eventify"
32
- end
33
- end
1
+ require "spec_helper"
2
+
3
+ describe Eventify::Mail do
4
+ context ".deliver" do
5
+ it "sends e-mail to all subscribers" do
6
+ expect(::Mail).to receive(:deliver).twice
7
+
8
+ Eventify::Mail.deliver([], Eventify::Configuration.new(subscribers: ["foo@example.org", "bar@example.org"]))
9
+ end
10
+ end
11
+
12
+ it ".format" do
13
+ new_events = [
14
+ Eventify::Provider::Base.new(id: "123", title: "foo", link: "http://example.org/1", date: Time.now),
15
+ Eventify::Provider::Piletilevi.new(id: "456", title: "bar", link: "http://example.org/2", date: Time.now),
16
+ Eventify::Provider::Base.new(id: "456", title: "bar3", link: "http://example.org/3", date: Time.now)
17
+ ]
18
+
19
+ expect(Eventify::Mail.format(new_events)).to eq("There are some rumours going on about 3 possible awesome events:
20
+
21
+ * bar
22
+ http://example.org/2
23
+
24
+ * bar3
25
+ http://example.org/3
26
+
27
+ * foo
28
+ http://example.org/1
29
+
30
+ Your Humble Servant,
31
+ Eventify")
32
+ end
33
+ end