dev_training_bot 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fa922d8863cd6e534ac098716185914c5d8b4b65f4764682c6d5a3b7336a867f
4
+ data.tar.gz: 62d07ba4cdaf73a1b21d90da2a6832980db56b3e30d68b7811ca9de2eec446e2
5
+ SHA512:
6
+ metadata.gz: ba61b77e9bee4442b6a4c993f96a3d3eb4c171b738cdc07cc0534f3bd4c3e1525755a727a6d3669105dbeee8ccfba1bb9bae90cd3312bb8cbcce3ed10220786d
7
+ data.tar.gz: 14bd3d7fb14671e16a181aba6edccd5fe3d7922ce05ec0ee7399385f30bb0547ae9fd851ea499dd58150a819aa27c67cf40175e60788d42a764924d4deb22aff
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .env
12
+ .rspec_status
13
+ client_secrets.json
14
+ token.yaml
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in dev_training_bot.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,174 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dev_training_bot (1.0.0)
5
+ chronic (~> 0.10)
6
+ google-api-client (~> 0.23)
7
+ launchy (~> 2.4)
8
+ slack-ruby-client (~> 0.11)
9
+ thor (~> 0.20)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activesupport (5.2.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
19
+ addressable (2.5.2)
20
+ public_suffix (>= 2.0.2, < 4.0)
21
+ awesome_print (1.8.0)
22
+ byebug (10.0.2)
23
+ chronic (0.10.2)
24
+ coderay (1.1.2)
25
+ concurrent-ruby (1.0.5)
26
+ crack (0.4.3)
27
+ safe_yaml (~> 1.0.0)
28
+ declarative (0.0.10)
29
+ declarative-option (0.1.0)
30
+ diff-lcs (1.3)
31
+ dotenv (2.5.0)
32
+ factory_bot (4.10.0)
33
+ activesupport (>= 3.0.0)
34
+ faraday (0.15.2)
35
+ multipart-post (>= 1.2, < 3)
36
+ faraday_middleware (0.12.2)
37
+ faraday (>= 0.7.4, < 1.0)
38
+ ffi (1.9.25)
39
+ formatador (0.2.5)
40
+ gli (2.17.1)
41
+ google-api-client (0.23.0)
42
+ addressable (~> 2.5, >= 2.5.1)
43
+ googleauth (>= 0.5, < 0.7.0)
44
+ httpclient (>= 2.8.1, < 3.0)
45
+ mime-types (~> 3.0)
46
+ representable (~> 3.0)
47
+ retriable (>= 2.0, < 4.0)
48
+ googleauth (0.6.2)
49
+ faraday (~> 0.12)
50
+ jwt (>= 1.4, < 3.0)
51
+ logging (~> 2.0)
52
+ memoist (~> 0.12)
53
+ multi_json (~> 1.11)
54
+ os (~> 0.9)
55
+ signet (~> 0.7)
56
+ guard (2.14.2)
57
+ formatador (>= 0.2.4)
58
+ listen (>= 2.7, < 4.0)
59
+ lumberjack (>= 1.0.12, < 2.0)
60
+ nenv (~> 0.1)
61
+ notiffany (~> 0.0)
62
+ pry (>= 0.9.12)
63
+ shellany (~> 0.0)
64
+ thor (>= 0.18.1)
65
+ guard-compat (1.2.1)
66
+ guard-rspec (4.7.3)
67
+ guard (~> 2.1)
68
+ guard-compat (~> 1.1)
69
+ rspec (>= 2.99.0, < 4.0)
70
+ hashdiff (0.3.7)
71
+ hashie (3.5.7)
72
+ httpclient (2.8.3)
73
+ i18n (1.0.1)
74
+ concurrent-ruby (~> 1.0)
75
+ jwt (2.1.0)
76
+ launchy (2.4.3)
77
+ addressable (~> 2.3)
78
+ listen (3.1.5)
79
+ rb-fsevent (~> 0.9, >= 0.9.4)
80
+ rb-inotify (~> 0.9, >= 0.9.7)
81
+ ruby_dep (~> 1.2)
82
+ little-plugger (1.1.4)
83
+ logging (2.2.2)
84
+ little-plugger (~> 1.1)
85
+ multi_json (~> 1.10)
86
+ lumberjack (1.0.13)
87
+ memoist (0.16.0)
88
+ method_source (0.9.0)
89
+ mime-types (3.1)
90
+ mime-types-data (~> 3.2015)
91
+ mime-types-data (3.2016.0521)
92
+ minitest (5.11.3)
93
+ multi_json (1.13.1)
94
+ multipart-post (2.0.0)
95
+ nenv (0.3.0)
96
+ notiffany (0.1.1)
97
+ nenv (~> 0.1)
98
+ shellany (~> 0.0)
99
+ os (0.9.6)
100
+ pry (0.11.3)
101
+ coderay (~> 1.1.0)
102
+ method_source (~> 0.9.0)
103
+ pry-byebug (3.6.0)
104
+ byebug (~> 10.0)
105
+ pry (~> 0.10)
106
+ public_suffix (3.0.2)
107
+ rake (10.5.0)
108
+ rb-fsevent (0.10.3)
109
+ rb-inotify (0.9.10)
110
+ ffi (>= 0.5.0, < 2)
111
+ representable (3.0.4)
112
+ declarative (< 0.1.0)
113
+ declarative-option (< 0.2.0)
114
+ uber (< 0.2.0)
115
+ retriable (3.1.2)
116
+ rspec (3.7.0)
117
+ rspec-core (~> 3.7.0)
118
+ rspec-expectations (~> 3.7.0)
119
+ rspec-mocks (~> 3.7.0)
120
+ rspec-core (3.7.1)
121
+ rspec-support (~> 3.7.0)
122
+ rspec-expectations (3.7.0)
123
+ diff-lcs (>= 1.2.0, < 2.0)
124
+ rspec-support (~> 3.7.0)
125
+ rspec-mocks (3.7.0)
126
+ diff-lcs (>= 1.2.0, < 2.0)
127
+ rspec-support (~> 3.7.0)
128
+ rspec-support (3.7.1)
129
+ ruby_dep (1.5.0)
130
+ safe_yaml (1.0.4)
131
+ shellany (0.0.1)
132
+ signet (0.8.1)
133
+ addressable (~> 2.3)
134
+ faraday (~> 0.9)
135
+ jwt (>= 1.5, < 3.0)
136
+ multi_json (~> 1.10)
137
+ slack-ruby-client (0.11.1)
138
+ activesupport
139
+ faraday (>= 0.9)
140
+ faraday_middleware
141
+ gli
142
+ hashie
143
+ websocket-driver
144
+ thor (0.20.0)
145
+ thread_safe (0.3.6)
146
+ tzinfo (1.2.5)
147
+ thread_safe (~> 0.1)
148
+ uber (0.1.0)
149
+ webmock (3.4.2)
150
+ addressable (>= 2.3.6)
151
+ crack (>= 0.3.2)
152
+ hashdiff
153
+ websocket-driver (0.7.0)
154
+ websocket-extensions (>= 0.1.0)
155
+ websocket-extensions (0.1.3)
156
+
157
+ PLATFORMS
158
+ ruby
159
+
160
+ DEPENDENCIES
161
+ awesome_print (~> 1.8)
162
+ bundler (~> 1.16)
163
+ dev_training_bot!
164
+ dotenv (~> 2.5)
165
+ factory_bot (~> 4.10)
166
+ guard-rspec (~> 4.7)
167
+ pry (~> 0.11)
168
+ pry-byebug (~> 3.6)
169
+ rake (~> 10.0)
170
+ rspec (~> 3.0)
171
+ webmock (~> 3.4)
172
+
173
+ BUNDLED WITH
174
+ 1.16.2
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { 'spec' }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 David Marchante
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # DevTrainingBot
2
+
3
+ List, publish or export the Dev Training topics (made for RubiconMD).
4
+
5
+ ## Installation
6
+
7
+ Install the gem:
8
+
9
+ $ gem install dev_training_bot
10
+
11
+ Turn on the [Drive API](https://developers.google.com/drive/api/v3/quickstart/ruby#prerequisites) and download your `client_secrets.json` file.
12
+
13
+ Generate a [token](https://api.slack.com/custom-integrations/legacy-tokens) for your Slack user.
14
+ **NOTE:** bots can't execute slash commands like `/poll`
15
+
16
+ Configure the following environment variables:
17
+ ```sh
18
+ CLIENT_SECRETS_PATH="$HOME/.client_secrets.json"
19
+ FILE_ID=<Google Docs file id>
20
+ SLACK_API_TOKEN=<your slack user token>
21
+ SLACK_CHANNEL="#your_channel"
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```
27
+ $ training
28
+
29
+ Commands:
30
+ training help [COMMAND] # Describe available commands or one specific command
31
+ training list # Show the list of available topics
32
+ training open # Open Dev Training document in your browser
33
+ training publish # Send a poll to the configured channel
34
+ training save <file> # Save Dev Training document to disk
35
+ ```
36
+
37
+ **NOTE:** The command `save` accepts an optional `--format` parameter (see `training help save`)
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/iovis9/dev_training_bot.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'dev_training_bot'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'pry'
10
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'dev_training_bot/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'dev_training_bot'
7
+ spec.version = DevTrainingBot::VERSION
8
+ spec.authors = ['David Marchante']
9
+ spec.email = ['david.marchante@rubiconmd.com']
10
+
11
+ spec.summary = 'Create a poll in Slack with the proposed topics'
12
+ spec.homepage = 'https://github.com/iovis9/dev_training_bot'
13
+ spec.license = 'MIT'
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
18
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_runtime_dependency 'chronic', '~> 0.10'
25
+ spec.add_runtime_dependency 'google-api-client', '~> 0.23'
26
+ spec.add_runtime_dependency 'launchy', '~> 2.4'
27
+ spec.add_runtime_dependency 'slack-ruby-client', '~> 0.11'
28
+ spec.add_runtime_dependency 'thor', '~> 0.20'
29
+
30
+ spec.add_development_dependency 'awesome_print', '~> 1.8'
31
+ spec.add_development_dependency 'bundler', '~> 1.16'
32
+ spec.add_development_dependency 'dotenv', '~> 2.5'
33
+ spec.add_development_dependency 'factory_bot', '~> 4.10'
34
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
35
+ spec.add_development_dependency 'pry', '~> 0.11'
36
+ spec.add_development_dependency 'pry-byebug', '~> 3.6'
37
+ spec.add_development_dependency 'rake', '~> 10.0'
38
+ spec.add_development_dependency 'rspec', '~> 3.0'
39
+ spec.add_development_dependency 'webmock', '~> 3.4'
40
+ end
data/exe/training ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'dev_training_bot'
4
+
5
+ DevTrainingBot::Cli.start
@@ -0,0 +1,57 @@
1
+ require 'launchy'
2
+ require 'thor'
3
+
4
+ module DevTrainingBot
5
+ class Cli < Thor
6
+ def self.exit_on_failure?
7
+ true
8
+ end
9
+
10
+ desc 'open', 'Open Dev Training document in your browser'
11
+ def open
12
+ Launchy.open GoogleDriveService::DOC_URL
13
+ end
14
+
15
+ desc 'save <file>', 'Save Dev Training document to disk'
16
+ method_option :format,
17
+ aliases: '-f',
18
+ desc: 'Specify the format of the document',
19
+ default: 'text',
20
+ enum: GoogleDriveService.formats
21
+ def save(file)
22
+ mime = GoogleDriveService.mime(options[:format])
23
+ drive_service.export_file(ENV['FILE_ID'], mime, download_dest: file)
24
+ say 'Successfully saved the document!', :green
25
+ end
26
+
27
+ desc 'publish', "Send a poll to the #{ENV['SLACK_CHANNEL']} channel"
28
+ def publish
29
+ slack_service.create_poll(topic_service.to_poll)
30
+ slack_service.link_doc
31
+ say 'Successfully published the poll!', :green
32
+ end
33
+
34
+ desc 'list', 'Show the list of available topics'
35
+ def list
36
+ topics_table = topic_service.topics.map do |topic|
37
+ ['', set_color(topic.author, :blue), topic.title]
38
+ end
39
+
40
+ print_table topics_table
41
+ end
42
+
43
+ private
44
+
45
+ def drive_service
46
+ @drive_service ||= GoogleDriveService.new
47
+ end
48
+
49
+ def topic_service
50
+ @topic_service ||= TopicService.new(drive_service)
51
+ end
52
+
53
+ def slack_service
54
+ @slack_service ||= SlackService.new
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,24 @@
1
+ module DevTrainingBot
2
+ class Topic
3
+ REGEX = /(?<author>.*?(?=:))?:?\s*(?<title>.+)/
4
+
5
+ attr_accessor :title, :author
6
+
7
+ def self.parse(topic)
8
+ topic.match(REGEX) { |matches| new(matches[:title], matches[:author]) }
9
+ end
10
+
11
+ def initialize(title, author = 'Unknown')
12
+ @title = title
13
+ @author = author || 'Unknown'
14
+ end
15
+
16
+ def to_s
17
+ "#{author}: #{title}"
18
+ end
19
+
20
+ def ==(other)
21
+ author == other.author && title == other.title
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,73 @@
1
+ require 'google/apis/drive_v3'
2
+ require 'googleauth/stores/file_token_store'
3
+
4
+ module DevTrainingBot
5
+ class GoogleDriveService
6
+ OOB_URI = 'urn:ietf:wg:oauth:2.0:oob'.freeze
7
+ APPLICATION_NAME = 'Dev Training Bot'.freeze
8
+ CLIENT_SECRETS_PATH = ENV['CLIENT_SECRETS_PATH'].freeze
9
+ CREDENTIALS_PATH = 'token.yaml'.freeze
10
+ SCOPE = Google::Apis::DriveV3::AUTH_DRIVE_READONLY
11
+ DOC_URL = "https://docs.google.com/document/d/#{ENV['FILE_ID']}".freeze
12
+ FORMATS = {
13
+ 'html' => 'text/html',
14
+ 'zip' => 'application/zip',
15
+ 'text' => 'text/plain',
16
+ 'rtf' => 'application/rtf',
17
+ 'open_office' => 'application/vnd.oasis.opendocument.text',
18
+ 'pdf' => 'application/pdf',
19
+ 'word' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
20
+ 'epub' => 'application/epub+zip'
21
+ }
22
+
23
+ extend Forwardable
24
+
25
+ def_delegators :@service, :export_file
26
+
27
+ attr_reader :service
28
+
29
+ def self.formats
30
+ FORMATS.keys
31
+ end
32
+
33
+ def self.mime(format)
34
+ FORMATS[format]
35
+ end
36
+
37
+ def initialize
38
+ @service = Google::Apis::DriveV3::DriveService.new
39
+ @service.client_options.application_name = APPLICATION_NAME
40
+ @service.authorization = authorize
41
+ end
42
+
43
+ private
44
+
45
+ ##
46
+ # Ensure valid credentials, either by restoring from the saved credentials
47
+ # files or intitiating an OAuth2 authorization. If authorization is required,
48
+ # the user's default browser will be launched to approve the request.
49
+ #
50
+ # @return [Google::Auth::UserRefreshCredentials] OAuth2 credentials
51
+ def authorize
52
+ client_id = Google::Auth::ClientId.from_file(CLIENT_SECRETS_PATH)
53
+ token_store = Google::Auth::Stores::FileTokenStore.new(file: CREDENTIALS_PATH)
54
+ authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)
55
+ user_id = 'default'
56
+ credentials = authorizer.get_credentials(user_id)
57
+
58
+ if credentials.nil?
59
+ url = authorizer.get_authorization_url(base_url: OOB_URI)
60
+
61
+ puts 'Open the following URL in the browser and enter the ' \
62
+ "resulting code after authorization:\n" + url
63
+ code = gets
64
+
65
+ credentials = authorizer.get_and_store_credentials_from_code(
66
+ user_id: user_id, code: code, base_url: OOB_URI
67
+ )
68
+ end
69
+
70
+ credentials
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,38 @@
1
+ require 'chronic'
2
+ require 'slack-ruby-client'
3
+
4
+ Slack.configure do |config|
5
+ config.token = ENV['SLACK_API_TOKEN']
6
+ raise 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
7
+ end
8
+
9
+ module DevTrainingBot
10
+ class SlackService
11
+ def initialize
12
+ @client = Slack::Web::Client.new
13
+ @client.auth_test
14
+ end
15
+
16
+ def create_poll(topics)
17
+ return no_topics_available if topics.empty?
18
+
19
+ next_friday = Chronic.parse('next friday').to_date
20
+
21
+ @client.chat_command channel: ENV['SLACK_CHANNEL'],
22
+ command: '/poll',
23
+ text: "\"@here Vote for the next dev learning! [#{next_friday}]\" #{topics}"
24
+ end
25
+
26
+ def no_topics_available
27
+ @client.chat_postMessage channel: ENV['SLACK_CHANNEL'],
28
+ text: '<!here> Please propose your topics for the next Dev Learning!',
29
+ as_user: true
30
+ end
31
+
32
+ def link_doc
33
+ @client.chat_postMessage channel: ENV['SLACK_CHANNEL'],
34
+ text: GoogleDriveService::DOC_URL,
35
+ as_user: true
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,49 @@
1
+ module DevTrainingBot
2
+ class TopicService
3
+ OPEN_TOPICS_REGEX = /Open Topics\s+(\*.*\r\n)+/
4
+ TOPIC_ITEM_REGEX = /(?<=\* ).*(?=\r)/
5
+
6
+ def initialize(drive_service)
7
+ @drive_service = drive_service
8
+ end
9
+
10
+ def to_poll
11
+ return '' if empty?
12
+ "\"#{topics.join('" "')}\""
13
+ end
14
+
15
+ def content
16
+ @content ||= @drive_service.export_file(ENV['FILE_ID'], 'text/plain', download_dest: StringIO.new)
17
+ end
18
+
19
+ ##
20
+ # Returns a list of topics from a string in the following format:
21
+ #
22
+ # Open Topics
23
+ # * David: Browser rendering optimization: how to get silky smooth animations
24
+ # * David: The JS Event Loop: what nightmares are made of
25
+ # * David: RxJS: Observing the death of Promises
26
+ # * David: Intro to vim
27
+ # * Mo: Ansible
28
+ # * Julio: CSI:RMD Reading error reports like a $BOSS
29
+ # * Anthony: SAML
30
+ # * Jimmi: Gang of Four Design Patterns in Ruby (possibly in different parts)
31
+ #
32
+ # @return [string]
33
+ def topics
34
+ @topics ||= import.map { |topic| Topic.parse(topic) }
35
+ end
36
+
37
+ def empty?
38
+ topics.empty?
39
+ end
40
+
41
+ private
42
+
43
+ def import
44
+ list = content.string[OPEN_TOPICS_REGEX].scan(TOPIC_ITEM_REGEX)
45
+ return [] if list.all?(&:empty?)
46
+ list.sort
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module DevTrainingBot
2
+ VERSION = '1.0.0'.freeze
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'dotenv/load'
2
+
3
+ require 'dev_training_bot/models/topic'
4
+
5
+ require 'dev_training_bot/services/google_drive_service'
6
+ require 'dev_training_bot/services/slack_service'
7
+ require 'dev_training_bot/services/topic_service'
8
+
9
+ require 'dev_training_bot/cli'
10
+ require 'dev_training_bot/version'
11
+
12
+ module DevTrainingBot
13
+ end
metadata ADDED
@@ -0,0 +1,275 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dev_training_bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - David Marchante
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chronic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: google-api-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.23'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.23'
41
+ - !ruby/object:Gem::Dependency
42
+ name: launchy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: slack-ruby-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.11'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.11'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.20'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.20'
83
+ - !ruby/object:Gem::Dependency
84
+ name: awesome_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.16'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.16'
111
+ - !ruby/object:Gem::Dependency
112
+ name: dotenv
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: factory_bot
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '4.10'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '4.10'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.7'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.7'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.11'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.11'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-byebug
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.6'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.6'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '10.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '10.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: rspec
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '3.0'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '3.0'
209
+ - !ruby/object:Gem::Dependency
210
+ name: webmock
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '3.4'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '3.4'
223
+ description:
224
+ email:
225
+ - david.marchante@rubiconmd.com
226
+ executables:
227
+ - training
228
+ extensions: []
229
+ extra_rdoc_files: []
230
+ files:
231
+ - ".gitignore"
232
+ - ".rspec"
233
+ - ".travis.yml"
234
+ - Gemfile
235
+ - Gemfile.lock
236
+ - Guardfile
237
+ - LICENSE.txt
238
+ - README.md
239
+ - Rakefile
240
+ - bin/console
241
+ - bin/setup
242
+ - dev_training_bot.gemspec
243
+ - exe/training
244
+ - lib/dev_training_bot.rb
245
+ - lib/dev_training_bot/cli.rb
246
+ - lib/dev_training_bot/models/topic.rb
247
+ - lib/dev_training_bot/services/google_drive_service.rb
248
+ - lib/dev_training_bot/services/slack_service.rb
249
+ - lib/dev_training_bot/services/topic_service.rb
250
+ - lib/dev_training_bot/version.rb
251
+ homepage: https://github.com/iovis9/dev_training_bot
252
+ licenses:
253
+ - MIT
254
+ metadata: {}
255
+ post_install_message:
256
+ rdoc_options: []
257
+ require_paths:
258
+ - lib
259
+ required_ruby_version: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ">="
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
265
+ requirements:
266
+ - - ">="
267
+ - !ruby/object:Gem::Version
268
+ version: '0'
269
+ requirements: []
270
+ rubyforge_project:
271
+ rubygems_version: 2.7.6
272
+ signing_key:
273
+ specification_version: 4
274
+ summary: Create a poll in Slack with the proposed topics
275
+ test_files: []