lita-onewheel-beer-wework 0.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
+ SHA1:
3
+ metadata.gz: b7458525108d874df189dfda5852e74d383cb540
4
+ data.tar.gz: af8c0349ea10191090d6c7905f42ab4ac123b765
5
+ SHA512:
6
+ metadata.gz: 2ae42ef32ed6a725bad8fd2d80b277c32718ba6e3c9445c560a32b293a9734b81271ee0fe52631aa72ab2b400a58d4f7cb83ec70759deab57fcc408291614d27
7
+ data.tar.gz: fa52024e24bd1b5bfd38187d21ae155ad1920676dbe43c7c1193eb951b10ad2d1f48c8c55a9f1bab68047f1b62354ef7074240bc4eec05f47c3a247c23e47132
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.5
4
+ - 2.3.1
5
+ script: bundle exec rake
6
+ before_install:
7
+ - gem update --system
8
+ services:
9
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # lita-onewheel-beer-wework
2
+
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-wework.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-beer-wework)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-beer-wework/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-beer-wework)
5
+
6
+ This plugin was designed to store WeWork's beer as sort of a shared beer locator for WeWork.
7
+
8
+ Thus, the plugin was born. It'll store, quite literally, anything you like.
9
+
10
+ ## Installation
11
+
12
+ Add lita-onewheel-beer-wework to your Lita instance's Gemfile:
13
+
14
+ ``` ruby
15
+ gem 'lita-onewheel-beer-wework'
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ Just needs redis which you have because you're already running Lita.
21
+
22
+ ## Usage
23
+ Command | Description
24
+ ------------------------- | -------------
25
+ `!wework floor beer` | Stores https://value under the key key. Note, web links are not enforced. You can store emoji if you like.
26
+ `!wework floor` | Display beer from a given floor.
27
+ `!wework` | list all beers.
28
+
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
@@ -0,0 +1,12 @@
1
+ require 'lita'
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join('..', '..', 'locales', '*.yml'), __FILE__
5
+ )]
6
+
7
+ require 'lita/handlers/onewheel_beer_wework'
8
+
9
+ Lita::Handlers::OnewheelBeerWework.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'),
11
+ __FILE__
12
+ )
@@ -0,0 +1,66 @@
1
+ module Lita
2
+ module Handlers
3
+ class OnewheelBeerWework < Handler
4
+ REDIS_KEY = 'onewheel-doc'
5
+
6
+ route /^wework\s+([\w\/+_-]+)\s+(.*)$/i,
7
+ :command_add_key,
8
+ command: true,
9
+ help: {'!wework 2fS Beer' => 'Add a beer to 2fS'}
10
+ route /^wework$/i,
11
+ :command_list_keys,
12
+ command: true,
13
+ help: {'!wework ' => 'list all beers'}
14
+ route /^wework\s+(\w+)$/i,
15
+ :command_fetch_key,
16
+ command: true,
17
+ help: {'!wework 2fS ' => 'fetch the beer for 2fS'}
18
+
19
+ def command_add_key(response)
20
+ key = response.matches[0][0].downcase
21
+ unless %w(1fs 1fn 2fs 2fn 3fn).include? key
22
+ Lita.logger.info "#{key} was not found in the floors array."
23
+ return
24
+ end
25
+ key = key[0..1] + key[-1].upcase
26
+ value = response.matches[0][1]
27
+ redis.hset(REDIS_KEY, key, value)
28
+ response.reply "Logged #{value} at #{key}!"
29
+ end
30
+
31
+ def command_fetch_key(response)
32
+ key = response.matches[0][0]
33
+
34
+ reply = get_values_that_start_with_key(key)
35
+ response.reply reply
36
+ end
37
+
38
+ def command_list_keys(response)
39
+ replies = []
40
+
41
+ all = redis.hgetall(REDIS_KEY)
42
+ all.each do |key, val|
43
+ replies.push format_key_val_response(key, val)
44
+ end
45
+ response.reply replies.join ", "
46
+ end
47
+
48
+ def get_values_that_start_with_key(key)
49
+ values = []
50
+ all = redis.hgetall(REDIS_KEY)
51
+ all.each do |all_key, all_val|
52
+ if all_key =~ /^#{key}/i
53
+ values.push format_key_val_response(all_key, all_val)
54
+ end
55
+ end
56
+ reply = values.join ", "
57
+ end
58
+
59
+ def format_key_val_response(all_key, all_val)
60
+ "#{all_key}: #{all_val}"
61
+ end
62
+ end
63
+
64
+ Lita.register_handler(OnewheelBeerWework)
65
+ end
66
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-onewheel-beer-wework'
3
+ spec.version = '0.0.0'
4
+ spec.authors = ['Andrew Kreps']
5
+ spec.email = ['andrew.kreps@gmail.com']
6
+ spec.description = 'Basic key/value store for wework beers.'
7
+ spec.summary = 'Will do it\'s best to store urls under the key specified.'
8
+ spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-beer-wework'
9
+ spec.license = 'MIT'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($/)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'lita', '~> 4'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
21
+ spec.add_development_dependency 'rake', '~> 10.4'
22
+ spec.add_development_dependency 'rack-test', '~> 0.6'
23
+ spec.add_development_dependency 'rspec', '~> 3.0'
24
+
25
+ spec.add_development_dependency 'simplecov', '~> 0.10'
26
+ spec.add_development_dependency 'coveralls', '~> 0.8'
27
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::OnewheelBeerWework, lita_handler: true do
4
+ it { is_expected.to route_command('wework') }
5
+ it { is_expected.to route_command('wework 2fS Breakfast Stout') }
6
+
7
+ it 'sets a beer' do
8
+ send_command 'wework 2fs Breakfast Stout'
9
+ expect(replies.last).to eq('Logged Breakfast Stout at 2fS!')
10
+ end
11
+
12
+ it 'gets a beer' do
13
+ send_command 'wework 2fs Breakfast Stout'
14
+ send_command 'wework 2fs'
15
+ expect(replies.last).to eq('2fS: Breakfast Stout')
16
+ end
17
+
18
+ it 'lists documents' do
19
+ send_command 'wework 2fs one'
20
+ send_command 'wework 2fN two'
21
+ send_command 'wework'
22
+ expect(replies.last).to eq("2fS: one, 2fN: two")
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-onewheel-beer-wework'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
13
+ # was generated with Lita 4, the compatibility mode should be left disabled.
14
+ Lita.version_3_compatibility_mode = false
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-onewheel-beer-wework
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kreps
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ description: Basic key/value store for wework beers.
112
+ email:
113
+ - andrew.kreps@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/lita-onewheel-beer-wework.rb
124
+ - lib/lita/handlers/onewheel_beer_wework.rb
125
+ - lita-onewheel-beer-wework.gemspec
126
+ - spec/lita/handlers/onewheel_beer_wework_spec.rb
127
+ - spec/spec_helper.rb
128
+ homepage: https://github.com/onewheelskyward/lita-onewheel-beer-wework
129
+ licenses:
130
+ - MIT
131
+ metadata:
132
+ lita_plugin_type: handler
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.5.1
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Will do it's best to store urls under the key specified.
153
+ test_files:
154
+ - spec/lita/handlers/onewheel_beer_wework_spec.rb
155
+ - spec/spec_helper.rb