lita-onewheel-rolz 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: c1d04dea819bad98a3910d00600832fd8a875ffa
4
+ data.tar.gz: da8d4af3ef5efc95cce0aee2ad6f52172a90da5d
5
+ SHA512:
6
+ metadata.gz: 2e8b4f80c6deea5d2b6423b60f1734c70d0ed1952ea07d542dad70dcb3ddf826f35ad96610ce7dd4eb148e1c27f5e2f78ad06f32977b7af69a3ac5502a946ed5
7
+ data.tar.gz: c478b1256ec2b5a35903197481bd5f8e05364de5bf797e94b55dbadf1576ed30f0653ff9675157e7b87b46d1ec9e47163a71d73229312d3cc9fe8fc0d24aa878
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ lita_config.rb
19
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.4
4
+ - 2.3.0
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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Andrew Kreps
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # lita-onewheel-rolz
2
+
3
+ [![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-rolz.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-rolz)
4
+ [![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-rolz/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-rolz)
5
+
6
+ Display a dice roll.
7
+
8
+ ## Installation
9
+
10
+ Add lita-onewheel-rolz to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem 'lita-onewheel-rolz'
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ !roll d20
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,3 @@
1
+ require 'lita'
2
+
3
+ require 'lita/handlers/onewheel_rolz'
@@ -0,0 +1,49 @@
1
+ require 'rest-client'
2
+
3
+ module Lita
4
+ module Handlers
5
+ class OnewheelRolz < Handler
6
+ route /roll (.*)$/i, :roll, command: true
7
+ route /roll$/i, :roll_default, command: true
8
+
9
+ def roll_default(response)
10
+ response.reply make_roll('d20')
11
+ end
12
+
13
+ def roll(response)
14
+ response.reply make_roll(response.matches[0][0])
15
+ end
16
+
17
+ def make_roll(dice)
18
+ Lita.logger.debug "lita-onewheel-rolz: rolling #{dice}"
19
+ result = 'wat'
20
+ input = ''
21
+
22
+ roll_data = RestClient.get "https://rolz.org/api/?#{dice}"
23
+
24
+ roll_data.split(/\n/).each do |line|
25
+ if line.match /result/
26
+ result = line[/(\d+)$/]
27
+ end
28
+ if line.match /input/
29
+ input = line[/(\w+)$/]
30
+ end
31
+ end
32
+
33
+ say = "You rolled a #{result}!"
34
+ if input.match(/d20/i) and result == 1.to_s
35
+ say += ' And you dropped your keyboard.'
36
+ end
37
+
38
+ if input.match(/d20/i) and result == 20.to_s
39
+ say += ' Critical hit!'
40
+ end
41
+
42
+ say
43
+ end
44
+
45
+
46
+ Lita.register_handler(self)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-onewheel-rolz'
3
+ spec.version = '0.0.0'
4
+ spec.authors = ['Andrew Kreps']
5
+ spec.email = ['andrew.kreps@gmail.com']
6
+ spec.description = %q{Lita interface to https://rolz.org}
7
+ spec.summary = %q{See above.}
8
+ spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-rolz'
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.7'
18
+ spec.add_runtime_dependency 'rest-client', '~> 1.8'
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.3'
21
+ # spec.add_development_dependency 'pry-byebug', '~> 3.1'
22
+ spec.add_development_dependency 'rake', '~> 10.4'
23
+ spec.add_development_dependency 'rack-test', '~> 0.6'
24
+ spec.add_development_dependency 'rspec', '~> 3.0'
25
+ spec.add_development_dependency 'simplecov', '~> 0.10'
26
+ spec.add_development_dependency 'coveralls', '~> 0.8'
27
+ end
@@ -0,0 +1,6 @@
1
+ input=6d6
2
+ result=20
3
+ details= (4 +5 +1 +3 +1 +6)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">6</span><span class="dc_dice_d">D6</span>
6
+ timestamp=1464906983
@@ -0,0 +1,6 @@
1
+ input=d20
2
+ result=6
3
+ details= (6)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">1</span><span class="dc_dice_d">D20</span>
6
+ timestamp=1464907412
@@ -0,0 +1,6 @@
1
+ input=d20
2
+ result=1
3
+ details= (1)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">1</span><span class="dc_dice_d">D20</span>
6
+ timestamp=1464907412
@@ -0,0 +1,6 @@
1
+ input=d20
2
+ result=17
3
+ details= (17)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">1</span><span class="dc_dice_d">D20</span>
6
+ timestamp=1464907412
@@ -0,0 +1,6 @@
1
+ input=d20
2
+ result=20
3
+ details= (20)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">1</span><span class="dc_dice_d">D20</span>
6
+ timestamp=1464907412
@@ -0,0 +1,6 @@
1
+ input=d6
2
+ result=1
3
+ details= (1)
4
+ code=
5
+ illustration=<span style="color: gray;"></span> <span class="dc_dice_a">6</span><span class="dc_dice_d">D6</span>
6
+ timestamp=1464906983
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ def mock_fixture(fixture)
4
+ mock = File.open("spec/fixtures/#{fixture}.wat").read
5
+ allow(RestClient).to receive(:get) { mock }
6
+ end
7
+
8
+ describe Lita::Handlers::OnewheelRolz, lita_handler: true do
9
+ it { is_expected.to route_command('roll') }
10
+ it { is_expected.to route_command('roll d20') }
11
+ it { is_expected.to route_command('roll 6d20') }
12
+
13
+ it 'gets a d20 roll' do
14
+ mock_fixture('d20')
15
+ send_command ('roll d20')
16
+ expect(replies.last).to eq('You rolled a 6!')
17
+ end
18
+
19
+ it 'gets a d20 roll of 1' do
20
+ mock_fixture('d20_1')
21
+ send_command ('roll d20')
22
+ expect(replies.last).to eq('You rolled a 1! And you dropped your keyboard.')
23
+ end
24
+
25
+ it 'gets a 6d6 roll' do
26
+ mock_fixture('6d6')
27
+ send_command ('roll 6d6')
28
+ expect(replies.last).to eq('You rolled a 20!')
29
+ end
30
+
31
+ it 'gets a 6d6 roll of 1' do
32
+ mock_fixture('d6_1')
33
+ send_command ('roll d6')
34
+ expect(replies.last).to eq('You rolled a 1!')
35
+ end
36
+
37
+ it 'rolls default' do
38
+ mock_fixture('d20_17')
39
+ send_command ('roll')
40
+ expect(replies.last).to eq('You rolled a 17!')
41
+ end
42
+
43
+ it 'rolls a 20!' do
44
+ mock_fixture('d20_20')
45
+ send_command ('roll d20')
46
+ expect(replies.last).to eq('You rolled a 20! Critical hit!')
47
+ end
48
+ end
@@ -0,0 +1,14 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatters = [
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-onewheel-rolz'
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,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-onewheel-rolz
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-02 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.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.8'
125
+ description: Lita interface to https://rolz.org
126
+ email:
127
+ - andrew.kreps@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
134
+ - Gemfile
135
+ - LICENSE
136
+ - README.md
137
+ - Rakefile
138
+ - lib/lita-onewheel-rolz.rb
139
+ - lib/lita/handlers/onewheel_rolz.rb
140
+ - lita-onewheel-rolz.gemspec
141
+ - spec/fixtures/6d6.wat
142
+ - spec/fixtures/d20.wat
143
+ - spec/fixtures/d20_1.wat
144
+ - spec/fixtures/d20_17.wat
145
+ - spec/fixtures/d20_20.wat
146
+ - spec/fixtures/d6_1.wat
147
+ - spec/lita/handlers/onewheel_rolz_spec.rb
148
+ - spec/spec_helper.rb
149
+ homepage: https://github.com/onewheelskyward/lita-onewheel-rolz
150
+ licenses:
151
+ - MIT
152
+ metadata:
153
+ lita_plugin_type: handler
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.5.1
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: See above.
174
+ test_files:
175
+ - spec/fixtures/6d6.wat
176
+ - spec/fixtures/d20.wat
177
+ - spec/fixtures/d20_1.wat
178
+ - spec/fixtures/d20_17.wat
179
+ - spec/fixtures/d20_20.wat
180
+ - spec/fixtures/d6_1.wat
181
+ - spec/lita/handlers/onewheel_rolz_spec.rb
182
+ - spec/spec_helper.rb