coffeeoutside 0.1.0 → 0.2.2

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: 0a5744ea07913c3e57048e2e18ac38db972e2f27a58412643ad5c8c21e661092
4
- data.tar.gz: ac683194966a7ad9b8c05ed2580af6c052de9b9a937d970d07f28dc1eb833a95
3
+ metadata.gz: aacb528c83db527b5a8ce464cbf5992ffd5eabb7166d5ba9050d5132ff3b4ddb
4
+ data.tar.gz: 03167aa72764c2df28ec99e1e1feefc16b54e034bd0ca5197aefeac53f129d7b
5
5
  SHA512:
6
- metadata.gz: 20a68ef99969acab09abbeff6b17b869801ea5cb42e98c52376b08d8f994bd2753c545627441a54a8f96e52ec4faa67e52e991e86b73e3700a2bbe3465a2dbed
7
- data.tar.gz: 4a439b69f7698b04d7120446e6f5a364f3ff120df35485f43c48ae88b4bb2332a067d59394939308837b15f2d1556f59fcee4ce218cddaa3ba6f597279b1431a
6
+ metadata.gz: d93a2a356f66be6c72e966b6e3793166f57b825a796863f0f216e86eb941b1be8740a8dcaf77b73d57a53e6bba636ca132254ffe9a77ad4858700d1074c76c29
7
+ data.tar.gz: 7d3a972514ce340b34d50cc1b4149c14ff88f78effa60aea9ac66cdf0d79b2abcc5ff70490521456f6cc2a7b1a108ab59ed54ec4d745a0ecfbb711fd5cb21052
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ config.yaml
6
6
  override.yaml
7
7
  prior_locations.yaml
8
8
  yyc.json
9
+ yyc.rss
data/Gemfile CHANGED
@@ -4,7 +4,12 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- group :development do
7
+ group :serverhack, optional: true do
8
+ # TODO better handling of this
9
+ gem 'http', '= 4.0.0'
10
+ end
11
+
12
+ group :development, optional: true do
8
13
  # TODO: submit Ruby 3.0 fixes upstream
9
14
  gem 'guard'
10
15
  gem 'guard-minitest'
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # CoffeeOutsideBot
2
2
 
3
- The CoffeeOutsideBot is designed to pick a location in the city for the
4
- #yycbike crowd to meet and enjoy some hot coffee (or tea!).
3
+ The CoffeeOutsideBot is designed to pick a location in the city
4
+ for the #yycbike crowd to meet and enjoy some hot coffee (or tea!).
5
5
 
6
6
  ## Installation
7
7
 
8
8
  ```
9
9
  git clone https://github.com/yycbike/coffeeoutsidebot.git
10
- go build
10
+ cd coffeeoutsidebot
11
+ bundle install
12
+ bundle exec bin/coffeeoutsidebot
11
13
  ```
12
14
 
13
15
  ## Twitter integration
@@ -20,11 +22,15 @@ You can get an API key at https://openweathermap.org/price
20
22
  An .ics file is auto generated. The current bot's version can be found at
21
23
  https://coffeeoutside.bike/yyc.ics
22
24
 
25
+ ## RSS integration
26
+ You can add the bot to your favourite RSS reader with
27
+ https://coffeeoutside.bike/yyc.rss
28
+
23
29
  ## Cron job
24
30
  To have the coffeeoutsidebot fire regularly, set up a cron job
25
31
 
26
32
  ```
27
- 0 17 * * 3 pushd /path/to/coffeeoutsidebot && /path/to/coffeeoutsidebot/coffeeoutsidebot
33
+ 0 17 * * 3 pushd /path/to/coffeeoutsidebot && bundle exec ruby bin/coffeeoutsidebot
28
34
  ```
29
35
 
30
36
  ## Contributing
@@ -27,5 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'icalendar', '= 2.7.1'
29
29
  spec.add_dependency 'openweathermap', '= 0.2.3'
30
+ spec.add_dependency 'rss', '= 0.2.7'
30
31
  spec.add_dependency 'twitter', '= 7.0.0'
31
32
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'dispatcher'
4
+ require 'rss'
5
+
6
+ module CoffeeOutside
7
+ class RssDispatcher < DispatcherBase
8
+ def generate_description
9
+ items = []
10
+ items.append(["Address: #{@location.address}"]) if @location.address
11
+ items.append(@forecast)
12
+ items.join("\n")
13
+ end
14
+
15
+ def generate_rss_string
16
+ RSS::Maker.make('2.0') do |maker|
17
+ maker.channel.language = 'en'
18
+ maker.channel.author = 'CoffeeOutsideBot'
19
+ maker.channel.updated = Time.now.to_s
20
+ maker.channel.about = 'https://coffeeoutside.bike/yyc.rss'
21
+ maker.channel.link = 'https://coffeeoutside.bike/yyc.rss'
22
+ maker.channel.description = 'CoffeeOutside is a weekly meetup where Calgarians bike/walk/run/rollerblade to a location, drink coffee/tea/some hot or cold beverage, and shoot the breeze'
23
+ maker.channel.title = 'CoffeeOutside'
24
+
25
+ maker.items.new_item do |item|
26
+ item.link = @location.url if @location.url
27
+ item.title = "Location for #{@start_time.strftime('%Y-%m-%d')}: #{@location.name}"
28
+ item.description = generate_description
29
+ item.updated = Time.now.to_s
30
+ end
31
+ end
32
+ end
33
+
34
+ def notify_production
35
+ i = File.open('yyc.rss', 'w')
36
+ i.write(generate_rss_string)
37
+ end
38
+
39
+ def notify_debug
40
+ puts generate_rss_string
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'dispatcher'
4
+
5
+ module CoffeeOutside
6
+ class StdoutDispatcher < DispatcherBase
7
+ def notify_production
8
+ # Since the bot is cron-based, don't write anything to stdout unless
9
+ # there's a problem
10
+ # puts "Chosen location is #{@location.name}"
11
+ end
12
+
13
+ def notify_debug
14
+ puts "Chosen location is #{@location.name}"
15
+ end
16
+ end
17
+ end
@@ -17,7 +17,7 @@ module CoffeeOutside
17
17
 
18
18
  # Send location tweet
19
19
  t = client.update location_tweet_msg
20
- puts t
20
+ # puts t
21
21
 
22
22
  # Send followup tweets
23
23
  # client.update('test', { in_reply_to_status_id: t.id }) if t.id
@@ -127,7 +127,11 @@ module CoffeeOutside
127
127
  class PriorLocationsFile
128
128
  def initialize(filename = './prior_locations.yaml')
129
129
  @filename = filename
130
- @locations = YAML.load_file(filename) || []
130
+ @locations = if File.exist? filename
131
+ YAML.load_file(filename) || []
132
+ else
133
+ []
134
+ end
131
135
  end
132
136
 
133
137
  def previous_locations(n = 5)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CoffeeOutside
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.2'
5
5
  end
data/lib/coffeeoutside.rb CHANGED
@@ -7,9 +7,9 @@ require_relative 'coffeeoutside/locations'
7
7
  require_relative 'coffeeoutside/weather'
8
8
 
9
9
  # Dispatchers
10
- require_relative 'coffeeoutside/dispatchers/json'
11
- require_relative 'coffeeoutside/dispatchers/ical'
12
- require_relative 'coffeeoutside/dispatchers/twitter'
10
+ %w[stdout json ical rss twitter].each do |d|
11
+ require_relative "coffeeoutside/dispatchers/#{d}"
12
+ end
13
13
 
14
14
  module CoffeeOutside
15
15
  class Error < StandardError; end
@@ -51,7 +51,6 @@ module CoffeeOutside
51
51
  def main
52
52
  config = Config.new
53
53
  if config.production?
54
- puts config.openweathermap
55
54
  owm = OWM.new config.openweathermap
56
55
  forecast = owm.get_forecast
57
56
  else
@@ -60,7 +59,6 @@ module CoffeeOutside
60
59
 
61
60
  destructive = config.production?
62
61
  location = LocationChooser.new(destructive, forecast).location
63
- puts "Chosen location is #{location}"
64
62
 
65
63
  dispatch = {
66
64
  start_time: get_start_time,
@@ -69,7 +67,9 @@ module CoffeeOutside
69
67
  location: location,
70
68
  production: config.production?
71
69
  }
70
+ StdoutDispatcher.new(dispatch).notify
72
71
  JsonDispatcher.new(dispatch).notify
72
+ RssDispatcher.new(dispatch).notify
73
73
  IcalDispatcher.new(dispatch).notify
74
74
  TwitterDispatcher.new(dispatch.merge(config.dispatchers['twitter'])).notify
75
75
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coffeeoutside
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Crosby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: icalendar
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.2.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rss
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.7
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: twitter
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -75,6 +89,8 @@ files:
75
89
  - lib/coffeeoutside/dispatchers/dispatcher.rb
76
90
  - lib/coffeeoutside/dispatchers/ical.rb
77
91
  - lib/coffeeoutside/dispatchers/json.rb
92
+ - lib/coffeeoutside/dispatchers/rss.rb
93
+ - lib/coffeeoutside/dispatchers/stdout.rb
78
94
  - lib/coffeeoutside/dispatchers/twitter.rb
79
95
  - lib/coffeeoutside/locations.rb
80
96
  - lib/coffeeoutside/version.rb