eventify 3.0.0 → 4.0.1
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.
- checksums.yaml +4 -4
- data/README.md +67 -69
- data/lib/eventify/database.rb +3 -3
- data/lib/eventify/provider/apollo_kino.rb +6 -6
- data/lib/eventify/provider/piletilevi.rb +7 -8
- data/lib/eventify/version.rb +1 -1
- data/lib/eventify.rb +42 -42
- data/spec/eventify/provider/apollo_kino_spec.rb +9 -9
- data/spec/eventify/provider/piletilevi_spec.rb +14 -14
- data/spec/support/apollo_kino.html +2752 -986
- data/spec/support/piletilevi-page1.json +1 -1
- data/spec/support/piletilevi-page2.json +1 -1
- metadata +2 -3
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfd7ad797c2f6b778904c736597f27989ba121c13ec8993acfef3f342531534b
|
4
|
+
data.tar.gz: 43814be3826b24b4c67c6e480c58cf5abd9e1ffea0680bbd35f63c5904d178f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9ef84b47f8f77ae3d18eff968fb938efab4b4e73e8412a4db209eecf315168e249c775caf873b959f57c8a7ba7c6de3312305536461a5e30cbde5064185e3c4
|
7
|
+
data.tar.gz: 9ca8da1b182aa553ddfc0d06fdbc2fb07b0ef68d06cf67349d4ba8be5cfb397936024365aa888129d1874ec21ea7d1b3085987cff94c56b4f0cad69f9f9f34a6
|
data/README.md
CHANGED
@@ -1,69 +1,67 @@
|
|
1
|
-
# Eventify
|
2
|
-
[](http://badge.fury.io/rb/eventify)
|
3
|
-
[.
|
1
|
+
# Eventify
|
2
|
+
[](http://badge.fury.io/rb/eventify)
|
3
|
+
[](https://coveralls.io/r/jarmo/eventify)
|
4
|
+
[](https://codeclimate.com/github/jarmo/eventify)
|
5
|
+
|
6
|
+
Are you tired of missing some cool concerts/events because you just didn't know them
|
7
|
+
happening? Are you tired of not getting good sitting places because you heard
|
8
|
+
of some event too late?
|
9
|
+
|
10
|
+
If the answer was yes to either of these questions then Eventify can help you!
|
11
|
+
|
12
|
+
Eventify will notify you about upcoming events from different
|
13
|
+
providers/organizers in an aggregated way.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
$ gem install eventify
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
* Create configuration file with your e-mail address:
|
22
|
+
|
23
|
+
`$ ruby -reventify -e "Eventify::Configuration.new(subscribers: ['foo@bar.com']).save"`
|
24
|
+
|
25
|
+
* Run it from command line and add it into `cron`:
|
26
|
+
|
27
|
+
`$ ruby -reventify -e "Eventify.new.process_new_events"`
|
28
|
+
|
29
|
+
* Check your e-mail for information about upcoming events.
|
30
|
+
|
31
|
+
* Edit configuration settings if defaults won't work for you:
|
32
|
+
|
33
|
+
`$ vi ~/.eventify/config.yaml`
|
34
|
+
|
35
|
+
## Supported Providers
|
36
|
+
|
37
|
+
The following providers are currently supported:
|
38
|
+
|
39
|
+
* [Livenation](https://livenation.ee)
|
40
|
+
* [Piletilevi](http://www.piletilevi.ee/)
|
41
|
+
* [Apollo Kino](https://www.apollokino.ee/)
|
42
|
+
|
43
|
+
## Adding New Providers
|
44
|
+
|
45
|
+
Adding new providers is easy. You just need to create a class with one method
|
46
|
+
satisfying the contract:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require "eventify"
|
50
|
+
|
51
|
+
class MyCustomProvider < Eventify::Provider::Base
|
52
|
+
def self.fetch
|
53
|
+
# fetch some atom feed
|
54
|
+
rss = SimpleRSS.parse open("http://example.org/rss.xml")
|
55
|
+
rss.entries.map { |entry| new id: entry.guid, title: entry.title, link: entry.link, date: entry.pubDate }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# use that provider with Eventify
|
60
|
+
eventify = Eventify.new
|
61
|
+
eventify.providers = [MyCustomProvider]
|
62
|
+
eventify.process_new_events
|
63
|
+
```
|
64
|
+
|
65
|
+
## License
|
66
|
+
|
67
|
+
See [LICENSE](https://github.com/jarmo/eventify/blob/master/LICENSE).
|
data/lib/eventify/database.rb
CHANGED
@@ -5,17 +5,17 @@ class Eventify::Database
|
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def exists?(event)
|
8
|
-
results = sqlite.execute "select 1 from event where id=? and provider=? and link=?", event.id, event.provider, event.link
|
8
|
+
results = sqlite.execute "select 1 from event where id=? and provider=? and link=?", [event.id, event.provider, event.link]
|
9
9
|
!results.empty?
|
10
10
|
end
|
11
11
|
|
12
12
|
def save(event)
|
13
13
|
sqlite.execute "insert into event values(?, ?, ?, ?, ?)",
|
14
|
-
event.id,
|
14
|
+
[event.id,
|
15
15
|
event.provider,
|
16
16
|
event.title,
|
17
17
|
event.link,
|
18
|
-
event.date.to_s
|
18
|
+
event.date.to_s]
|
19
19
|
end
|
20
20
|
|
21
21
|
def events
|
@@ -4,15 +4,15 @@ require "time"
|
|
4
4
|
|
5
5
|
module Eventify::Provider
|
6
6
|
class ApolloKino < Base
|
7
|
-
URL = "https://www.apollokino.ee/"
|
7
|
+
URL = "https://www.apollokino.ee/eng/movies?3064-actionType=1"
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def fetch
|
11
|
-
doc = Nokogiri::HTML(URI.open(
|
12
|
-
doc.search(".
|
13
|
-
title_node = item.at("
|
14
|
-
url =
|
15
|
-
date = Time.strptime(item.at(".
|
11
|
+
doc = Nokogiri::HTML(URI.open(URL))
|
12
|
+
doc.search(".schedule__item").map do |item|
|
13
|
+
title_node = item.at(".movie-card__title a")
|
14
|
+
url = title_node["href"]
|
15
|
+
date = Time.strptime(item.at(".movie-card__label").content.gsub(/In Cinemas /, ""), "%m/%d/%Y")
|
16
16
|
new id: url, title: title_node.content, link: url, date: date
|
17
17
|
end
|
18
18
|
end
|
@@ -3,13 +3,13 @@ require "json"
|
|
3
3
|
|
4
4
|
module Eventify::Provider
|
5
5
|
class Piletilevi < Base
|
6
|
-
URL = URI.parse("https://www.piletilevi.ee/
|
6
|
+
URL = URI.parse("https://www.piletilevi.ee/api/v1/events?language=et&page=:PAGE:&pageSize=36&sortBy=date&sortOrder=ASC")
|
7
|
+
EVENT_BASE_URL = URI.parse("https://www.piletilevi.ee/piletid/:ID:/:SLUG:")
|
7
8
|
|
8
9
|
class << self
|
9
10
|
def fetch
|
10
11
|
first_page_json = fetch_page(1)
|
11
|
-
|
12
|
-
total_pages = list_info["total"] / list_info["pageSize"] + 1
|
12
|
+
total_pages = first_page_json["totalPages"]
|
13
13
|
result = events(first_page_json) + (2..total_pages).flat_map { |page_number| events(fetch_page(page_number)) }
|
14
14
|
result
|
15
15
|
end
|
@@ -17,15 +17,14 @@ module Eventify::Provider
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def fetch_page(number)
|
20
|
-
JSON.parse(URI.open("
|
20
|
+
JSON.parse(URI.open(URL.to_s.gsub(":PAGE:", number.to_s)).read)
|
21
21
|
end
|
22
22
|
|
23
23
|
def events(json)
|
24
|
-
entries = json["
|
24
|
+
entries = json["items"]
|
25
25
|
entries.map do |entry|
|
26
|
-
link = URI.parse(entry["
|
27
|
-
|
28
|
-
new id: entry["id"], title: entry["title"], link: link.to_s, date: Time.at(entry["startTime"]["stamp"])
|
26
|
+
link = URI.parse(EVENT_BASE_URL.to_s.gsub(":ID:", entry["id"]).gsub(":SLUG:", entry["sluggedName"]))
|
27
|
+
new id: entry["id"], title: entry["name"], link: link.to_s, date: Time.parse(entry["eventStartAt"])
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/lib/eventify/version.rb
CHANGED
data/lib/eventify.rb
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
require File.expand_path("eventify/version", __dir__)
|
2
|
-
require File.expand_path("eventify/configuration", __dir__)
|
3
|
-
require File.expand_path("eventify/provider/base", __dir__)
|
4
|
-
require File.expand_path("eventify/provider/livenation", __dir__)
|
5
|
-
require File.expand_path("eventify/provider/piletilevi", __dir__)
|
6
|
-
require File.expand_path("eventify/provider/apollo_kino", __dir__)
|
7
|
-
require File.expand_path("eventify/database", __dir__)
|
8
|
-
require File.expand_path("eventify/mail", __dir__)
|
9
|
-
|
10
|
-
class Eventify
|
11
|
-
attr_reader :configuration
|
12
|
-
|
13
|
-
def initialize(configuration=Eventify::Configuration.new)
|
14
|
-
@configuration = configuration
|
15
|
-
end
|
16
|
-
|
17
|
-
def all_events
|
18
|
-
@all_events ||= providers.flat_map(&:fetch).uniq
|
19
|
-
end
|
20
|
-
|
21
|
-
def new_events
|
22
|
-
@new_events ||= all_events.reject(&:exists?)
|
23
|
-
end
|
24
|
-
|
25
|
-
def process_new_events
|
26
|
-
all_new_events = new_events
|
27
|
-
return if all_new_events.empty?
|
28
|
-
|
29
|
-
Eventify::Mail.deliver all_new_events, @configuration
|
30
|
-
all_new_events.each(&:save)
|
31
|
-
end
|
32
|
-
|
33
|
-
attr_writer :providers
|
34
|
-
|
35
|
-
def providers
|
36
|
-
@providers ||= [
|
37
|
-
Eventify::Provider::Piletilevi,
|
38
|
-
Eventify::Provider::Livenation,
|
39
|
-
Eventify::Provider::ApolloKino
|
40
|
-
]
|
41
|
-
end
|
42
|
-
end
|
1
|
+
require File.expand_path("eventify/version", __dir__)
|
2
|
+
require File.expand_path("eventify/configuration", __dir__)
|
3
|
+
require File.expand_path("eventify/provider/base", __dir__)
|
4
|
+
require File.expand_path("eventify/provider/livenation", __dir__)
|
5
|
+
require File.expand_path("eventify/provider/piletilevi", __dir__)
|
6
|
+
require File.expand_path("eventify/provider/apollo_kino", __dir__)
|
7
|
+
require File.expand_path("eventify/database", __dir__)
|
8
|
+
require File.expand_path("eventify/mail", __dir__)
|
9
|
+
|
10
|
+
class Eventify
|
11
|
+
attr_reader :configuration
|
12
|
+
|
13
|
+
def initialize(configuration=Eventify::Configuration.new)
|
14
|
+
@configuration = configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def all_events
|
18
|
+
@all_events ||= providers.flat_map(&:fetch).uniq
|
19
|
+
end
|
20
|
+
|
21
|
+
def new_events
|
22
|
+
@new_events ||= all_events.reject(&:exists?)
|
23
|
+
end
|
24
|
+
|
25
|
+
def process_new_events
|
26
|
+
all_new_events = new_events
|
27
|
+
return if all_new_events.empty?
|
28
|
+
|
29
|
+
Eventify::Mail.deliver all_new_events, @configuration
|
30
|
+
all_new_events.each(&:save)
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_writer :providers
|
34
|
+
|
35
|
+
def providers
|
36
|
+
@providers ||= [
|
37
|
+
Eventify::Provider::Piletilevi,
|
38
|
+
Eventify::Provider::Livenation,
|
39
|
+
Eventify::Provider::ApolloKino
|
40
|
+
]
|
41
|
+
end
|
42
|
+
end
|
@@ -3,21 +3,21 @@ require "spec_helper"
|
|
3
3
|
describe Eventify::Provider::ApolloKino do
|
4
4
|
context "#fetch" do
|
5
5
|
it "fetches events" do
|
6
|
-
stub_request(:get,
|
6
|
+
stub_request(:get, Eventify::Provider::ApolloKino::URL.to_s).to_return(body: File.read(File.expand_path("../../support/apollo_kino.html", __dir__)))
|
7
7
|
|
8
8
|
events = Eventify::Provider::ApolloKino.fetch
|
9
9
|
expect(events).to eq([
|
10
10
|
Eventify::Provider::ApolloKino.new(
|
11
|
-
title: "
|
12
|
-
link: "https://www.apollokino.ee/eng/event/
|
13
|
-
date: Time.parse("
|
14
|
-
id: "https://www.apollokino.ee/eng/event/
|
11
|
+
title: "Ingeborg Bachmann - Journey Into the Desert",
|
12
|
+
link: "https://www.apollokino.ee/eng/event/5325/ingeborg_bachmann_-_journey_into_the_desert?theatreAreaID=1004",
|
13
|
+
date: Time.parse("2024-06-14"),
|
14
|
+
id: "https://www.apollokino.ee/eng/event/5325/ingeborg_bachmann_-_journey_into_the_desert?theatreAreaID=1004"
|
15
15
|
),
|
16
16
|
Eventify::Provider::ApolloKino.new(
|
17
|
-
title: "
|
18
|
-
link: "https://www.apollokino.ee/eng/event/
|
19
|
-
date: Time.parse("
|
20
|
-
id: "https://www.apollokino.ee/eng/event/
|
17
|
+
title: "Inside Out 2",
|
18
|
+
link: "https://www.apollokino.ee/eng/event/5395/inside_out_2?theatreAreaID=1004",
|
19
|
+
date: Time.parse("2024-07-15"),
|
20
|
+
id: "https://www.apollokino.ee/eng/event/5395/inside_out_2?theatreAreaID=1004",
|
21
21
|
),
|
22
22
|
])
|
23
23
|
end
|
@@ -3,28 +3,28 @@ require "spec_helper"
|
|
3
3
|
describe Eventify::Provider::Piletilevi do
|
4
4
|
context "#fetch" do
|
5
5
|
it "fetches events" do
|
6
|
-
stub_request(:get, "
|
7
|
-
stub_request(:get, "
|
6
|
+
stub_request(:get, "https://www.piletilevi.ee/api/v1/events?language=et&page=1&pageSize=36&sortBy=date&sortOrder=ASC").to_return(body: File.read(File.expand_path("../../support/piletilevi-page1.json", __dir__)))
|
7
|
+
stub_request(:get, "https://www.piletilevi.ee/api/v1/events?language=et&page=2&pageSize=36&sortBy=date&sortOrder=ASC").to_return(body: File.read(File.expand_path("../../support/piletilevi-page2.json", __dir__)))
|
8
8
|
|
9
9
|
events = Eventify::Provider::Piletilevi.fetch
|
10
10
|
expect(events).to eq([
|
11
11
|
Eventify::Provider::Piletilevi.new(
|
12
|
-
title:"
|
13
|
-
link: "https://www.piletilevi.ee/
|
14
|
-
date: Time.
|
15
|
-
id:
|
12
|
+
title:"Eesti Kontserdi kinkepilet",
|
13
|
+
link: "https://www.piletilevi.ee/piletid/4XLFLKGPOI/eesti-kontserdi-kinkepilet",
|
14
|
+
date: Time.parse("2018-10-25T20:59:00Z"),
|
15
|
+
id: "4XLFLKGPOI"
|
16
16
|
),
|
17
17
|
Eventify::Provider::Piletilevi.new(
|
18
|
-
title: "
|
19
|
-
link: "https://www.
|
20
|
-
date: Time.
|
21
|
-
id:
|
18
|
+
title: "Vaba Lava Kinkepilet",
|
19
|
+
link: "https://www.piletilevi.ee/piletid/JM77KMXFXY/vaba-lava-kinkepilet",
|
20
|
+
date: Time.parse("2018-12-31T10:00:00Z"),
|
21
|
+
id: "JM77KMXFXY"
|
22
22
|
),
|
23
23
|
Eventify::Provider::Piletilevi.new(
|
24
|
-
title: "
|
25
|
-
link: "https://www.piletilevi.ee/
|
26
|
-
date: Time.
|
27
|
-
id:
|
24
|
+
title: "Misiganes",
|
25
|
+
link: "https://www.piletilevi.ee/piletid/5XLFLKGPOI/misiganes",
|
26
|
+
date: Time.parse("2019-10-25T20:59:00Z"),
|
27
|
+
id: "5XLFLKGPOI"
|
28
28
|
)
|
29
29
|
])
|
30
30
|
end
|