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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd35658a298a68c09bba8dd2fb5d1fece295d85896d413f9ff71e3f6bec59045
4
- data.tar.gz: 992323d93ed64553ccc2d92f26c98082a75cda566ca91eebc2529bee796d257f
3
+ metadata.gz: cfd7ad797c2f6b778904c736597f27989ba121c13ec8993acfef3f342531534b
4
+ data.tar.gz: 43814be3826b24b4c67c6e480c58cf5abd9e1ffea0680bbd35f63c5904d178f0
5
5
  SHA512:
6
- metadata.gz: 2a516c267b2f36c12e5e8698d164b8e0e343177f8a440eb2841443d9e4c8fa7e27dd2d4f12d969d58f3f2cdc01009318a2983fd5b0f3b17c841df8e20bd790e0
7
- data.tar.gz: c2471416f81f9a3ed312149205ac0e0ee4772b511e6085a0d3d105354a721dcd17a445122799aa543d9e815b80bd93311e63adb3c07d4a26473ec9dc39518a2a
6
+ metadata.gz: d9ef84b47f8f77ae3d18eff968fb938efab4b4e73e8412a4db209eecf315168e249c775caf873b959f57c8a7ba7c6de3312305536461a5e30cbde5064185e3c4
7
+ data.tar.gz: 9ca8da1b182aa553ddfc0d06fdbc2fb07b0ef68d06cf67349d4ba8be5cfb397936024365aa888129d1874ec21ea7d1b3085987cff94c56b4f0cad69f9f9f34a6
data/README.md CHANGED
@@ -1,69 +1,67 @@
1
- # Eventify
2
- [![Gem Version](https://badge.fury.io/rb/eventify.png)](http://badge.fury.io/rb/eventify)
3
- [![Build Status](https://api.travis-ci.org/jarmo/eventify.png)](http://travis-ci.org/jarmo/eventify)
4
- [![Coverage](https://coveralls.io/repos/jarmo/eventify/badge.png?branch=master)](https://coveralls.io/r/jarmo/eventify)
5
- [![Dependency Status](https://gemnasium.com/jarmo/eventify.png)](https://gemnasium.com/jarmo/eventify)
6
- [![Code Climate](https://codeclimate.com/github/jarmo/eventify.png)](https://codeclimate.com/github/jarmo/eventify)
7
-
8
- Are you tired of missing some cool concerts/events because you just didn't know them
9
- happening? Are you tired of not getting good sitting places because you heard
10
- of some event too late?
11
-
12
- If the answer was yes to either of these questions then Eventify can help you!
13
-
14
- Eventify will notify you about upcoming events from different
15
- providers/organizers in an aggregate way.
16
-
17
- ## Installation
18
-
19
- $ gem install eventify
20
-
21
- ## Usage
22
-
23
- * Create configuration file with your e-mail address:
24
-
25
- `$ ruby -reventify -e "Eventify::Configuration.new(subscribers: ['foo@bar.com']).save"`
26
-
27
- * Run it from command line and add it into `cron`:
28
-
29
- `$ ruby -reventify -e "Eventify.new.process_new_events"`
30
-
31
- * Check your e-mail for information about upcoming events.
32
-
33
- * Edit configuration settings if defaults won't work for you:
34
-
35
- `$ vi ~/.eventify/config.yaml`
36
-
37
- ## Supported Providers
38
-
39
- The following providers are currently supported:
40
-
41
- * [Livenation](https://livenation.ee)
42
- * [Piletilevi](http://www.piletilevi.ee/)
43
- * [Apollo Kino](https://www.apollokino.ee/)
44
-
45
- ## Adding New Providers
46
-
47
- Adding new providers is easy. You just need to create a class with one method
48
- satisfying the contract:
49
-
50
- ```ruby
51
- require "eventify"
52
-
53
- class MyCustomProvider < Eventify::Provider::Base
54
- def self.fetch
55
- # fetch some atom feed
56
- rss = SimpleRSS.parse open("http://example.org/rss.xml")
57
- rss.entries.map { |entry| new id: entry.guid, title: entry.title, link: entry.link, date: entry.pubDate }
58
- end
59
- end
60
-
61
- # use that provider with Eventify
62
- eventify = Eventify.new
63
- eventify.providers = [MyCustomProvider]
64
- eventify.process_new_events
65
- ```
66
-
67
- ## License
68
-
69
- See [LICENSE](https://github.com/jarmo/eventify/blob/master/LICENSE).
1
+ # Eventify
2
+ [![Gem Version](https://badge.fury.io/rb/eventify.png)](http://badge.fury.io/rb/eventify)
3
+ [![Coverage](https://coveralls.io/repos/jarmo/eventify/badge.png?branch=master)](https://coveralls.io/r/jarmo/eventify)
4
+ [![Code Climate](https://codeclimate.com/github/jarmo/eventify.png)](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).
@@ -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(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")
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/ajaxCaller/method:getConcertsListInfo/id:1089/type:catalog_category/order:date,asc")
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
- list_info = first_page_json["responseData"]["listInfo"]
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("#{URL}/page:#{number}").read)
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["responseData"]["event"]
24
+ entries = json["items"]
25
25
  entries.map do |entry|
26
- link = URI.parse(entry["link"])
27
- link.scheme = "https" unless link.scheme
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
@@ -1,3 +1,3 @@
1
1
  class Eventify
2
- VERSION = "3.0.0"
2
+ VERSION = "4.0.1"
3
3
  end
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, URI.join(Eventify::Provider::ApolloKino::URL, "eng/soon").to_s).to_return(body: File.read(File.expand_path("../../support/apollo_kino.html", __dir__)))
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: "Võimlemisklubi Janika TALVEKONTSERT",
12
- link: "https://www.apollokino.ee/eng/event/4127/title/v%C3%B5imlemisklubi_janika_talvekontsert/",
13
- date: Time.parse("2021-01-31"),
14
- id: "https://www.apollokino.ee/eng/event/4127/title/v%C3%B5imlemisklubi_janika_talvekontsert/"
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: "Jurassic World: Dominion",
18
- link: "https://www.apollokino.ee/eng/event/4064/title/jurassic_world_dominion/",
19
- date: Time.parse("2022-06-10"),
20
- id: "https://www.apollokino.ee/eng/event/4064/title/jurassic_world_dominion/",
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, "#{Eventify::Provider::Piletilevi::URL}/page:1").to_return(body: File.read(File.expand_path("../../support/piletilevi-page1.json", __dir__)))
7
- stub_request(:get, "#{Eventify::Provider::Piletilevi::URL}/page:2").to_return(body: File.read(File.expand_path("../../support/piletilevi-page2.json", __dir__)))
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:"Apsilankyk edukaciniame zoologijos sode ZOOPARK.LT",
13
- link: "https://www.piletilevi.ee/est/piletid/varia/apsilankyk-edukaciniame-zoologijos-sode-zooparklt-53017/",
14
- date: Time.at(1535871600),
15
- id: 53017
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: "Huumoriteater ''ENSV kohvik''",
19
- link: "https://www.kinkekaart.ee/est/piletid/teater/komoodia/huumoriteater-ensv-kohvik-318916/",
20
- date: Time.at(1577898000),
21
- id: 21428
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: "Viiuldaja katusel / J. Steini / J.Bocki / S. Harnicki muusikal",
25
- link: "https://www.piletilevi.ee/est/piletid/muusika/muusikal/viiuldaja-katusel-j-steini-jbocki-s-harnicki-muusikal-40385/",
26
- date: Time.at(1610038800),
27
- id: 40385
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