lita-quote 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 275240b0c3f33d865924686a35657049c22ac42d
4
+ data.tar.gz: 4c71d91b20b7570ff29ad7c914ac42b3c7146a65
5
+ SHA512:
6
+ metadata.gz: 6dbcc2eb8c1b225eee982b29a87d2ded28bd3702f536ed0bcc8b871575304356c7aaf109d031de908b1a0b89b4f11ec20d8c567d6b74fd7ea02729238c10199c
7
+ data.tar.gz: 107df58d184ff015b507ca9fd87269e819e169f7d5adbd0d573b671b43fcffe54d4552269769bc3b07d2da871d01162fb0ce7eaf22215ccd5f8b089c39fcbb68
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Jonathan Amiez
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # lita-quote
2
+
3
+ TODO: Add a description of the plugin.
4
+
5
+ ## Installation
6
+
7
+ Add lita-quote to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-quote"
11
+ ```
12
+
13
+ ## Configuration
14
+
15
+ TODO: Describe any configuration attributes the plugin exposes.
16
+
17
+ ## Usage
18
+
19
+ TODO: Describe the plugin's features and how to use them.
20
+
21
+ ## License
22
+
23
+ [MIT](http://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
@@ -0,0 +1,53 @@
1
+ module Lita
2
+ module Handlers
3
+ class Quote < Handler
4
+
5
+ def self.default_config(config)
6
+ config.date_format = nil
7
+ end
8
+
9
+ route /^qadd\s+(.*)$/, :add_quote, command: true,
10
+ help: { "qadd <text>" => "Store quote following the command" }
11
+
12
+ route /^qget(\s*(\d+))?$/, :get_quote, command: true,
13
+ help: { "qget [id]" => "Retrieve a quote by #id or randomly" }
14
+
15
+ route /^qdel\s+(\d+)$/, :del_quote, command: true, restrict_to: ["admins"],
16
+ help: { "qdel <id>" => "Delete quote with given #id (admins only)" }
17
+
18
+ def add_quote(response)
19
+ quote_id = redis.incr("last_id")
20
+ message = "##{quote_id}: #{response.matches.flatten.first}"
21
+ message += " #{Time.now.strftime(Lita.config.handlers.quote.date_format)}" if Lita.config.handlers.quote.date_format
22
+ redis.hset("list", quote_id, message)
23
+ response.reply("added quote ##{quote_id}")
24
+ end
25
+
26
+ def get_quote(response)
27
+ if quote_id = response.matches.flatten.last
28
+ quote = redis.hget("list", quote_id.to_i)
29
+ else
30
+ quotes = redis.hvals("list")
31
+ quote = quotes[rand(quotes.length)]
32
+ end
33
+
34
+ if quote
35
+ response.reply(quote)
36
+ else
37
+ response.reply("No quote found")
38
+ end
39
+ end
40
+
41
+ def del_quote(response)
42
+ quote_id = response.matches.flatten.last.to_i
43
+ if redis.hdel("list", quote_id) == 1
44
+ response.reply("Deleted quote ##{quote_id}")
45
+ else
46
+ response.reply("Quote ##{quote_id} does not exist")
47
+ end
48
+ end
49
+ end
50
+
51
+ Lita.register_handler(Quote)
52
+ end
53
+ end
data/lib/lita-quote.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "lita"
2
+ require "lita/handlers/quote"
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-quote"
3
+ spec.version = "0.0.1"
4
+ spec.authors = ["Jonathan Amiez"]
5
+ spec.email = ["jonathan.amiez@gmail.com"]
6
+ spec.description = "Quote handler for Lita"
7
+ spec.summary = "Store quotes added by users and display them back"
8
+ spec.homepage = "https://github.com/josqu4red/lita-quote"
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", ">= 3.0"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
22
+ spec.add_development_dependency "simplecov"
23
+ spec.add_development_dependency "coveralls"
24
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Quote, lita_handler: true do
4
+
5
+ before do
6
+ Lita.configure do |config|
7
+ config.handlers.quote.date_format = "%Y%m%d-%H%M"
8
+ end
9
+ end
10
+
11
+ it { routes_command("qadd dat funny guy").to(:add_quote) }
12
+ it { doesnt_route("qadd").to(:add_quote) }
13
+ it { doesnt_route("yo qadd dat funny guy").to(:add_quote) }
14
+
15
+ it { routes_command("qget").to(:get_quote) }
16
+ it { routes_command("qget 22").to(:get_quote) }
17
+ it { doesnt_route("yo qget").to(:get_quote) }
18
+ it { doesnt_route("qget dat").to(:get_quote) }
19
+
20
+ it { routes_command("qdel 22").to(:del_quote) }
21
+ it { doesnt_route("qdel").to(:del_quote) }
22
+ it { doesnt_route("yo qdel dat").to(:del_quote) }
23
+
24
+ describe "#add_quote" do
25
+ end
26
+
27
+ describe "#get_quote" do
28
+ end
29
+
30
+ describe "#del_quote" do
31
+ end
32
+ end
@@ -0,0 +1,10 @@
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-quote"
10
+ require "lita/rspec"
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-quote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Amiez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-20 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: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0.beta2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0.beta2
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Quote handler for Lita
98
+ email:
99
+ - jonathan.amiez@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - lib/lita-quote.rb
111
+ - lib/lita/handlers/quote.rb
112
+ - lita-quote.gemspec
113
+ - spec/lita/handlers/quote_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/josqu4red/lita-quote
116
+ licenses:
117
+ - MIT
118
+ metadata:
119
+ lita_plugin_type: handler
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.2.0
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Store quotes added by users and display them back
140
+ test_files:
141
+ - spec/lita/handlers/quote_spec.rb
142
+ - spec/spec_helper.rb