lita-genius 0.1.0

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: 6e4287bd490f22350cca01a84526eda67d49c265
4
+ data.tar.gz: 12cfa053e00d5a9a4f94e6cac3b3f0866657db8c
5
+ SHA512:
6
+ metadata.gz: 07c355e1f2cb041663cfa40b939bc3b2ac78eb5023a5136e029c0b99a72316c0845f68b57f2f62667a97d029eb7afd72abf89a98fd1119d06adbafd7df457e0d
7
+ data.tar.gz: e936bad19448e38967a71b357700820c410a0e8151cc51cdebeeed427112131eed49c09734a4643541ad69b2150e003b83b1d164cb6b7560ce3d815372341fec
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
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
+ *.swp
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) 2015 Tristan Chong
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,28 @@
1
+ # lita-genius
2
+
3
+ **lita-genius** is a handler for [Lita](https://github.com/jimmycuadra/lita) that returns requested songs from Genius (formerly known as Rap Genius).
4
+
5
+ ## Installation
6
+
7
+ Add lita-genius to your Lita instance's Gemfile:
8
+
9
+ ``` ruby
10
+ gem "lita-genius"
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Using the `genius` command will return the top Genius result for your query. Song titles and lyrics are both valid types of search strings.
16
+ ```
17
+ <me> lita: genius weeknd montreal
18
+ <lita> A sample from “Laisse Tomber Les Filles” originally performed by France Gall.
19
+ <lita> The Weeknd - Montreal | http://genius.com/songs/61962
20
+
21
+ <me> lita: genius runnin through the 6 with my woes
22
+ <lita> Drake first used this moniker in “Jodeci Freestyle” — a single released in the lead-up to his album Nothing Was The Same. On the album, the phrase is also referenced in “From Time”, during a monologue by Baka. Over time Drake has made the line a recurring theme in songs such as “0 to 100”. “Know yourself”/know thyself is also an aphorism that has been attributed to a number of ancient Greek sages, including Socrates, Heraclitus and Pythagoras. Care first about the greatest perfection of the soul. — Socrates
23
+ <lita> Drake - Know Yourself | http://genius.com/songs/703654
24
+ ```
25
+
26
+ ## License
27
+
28
+ [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,26 @@
1
+ require "rapgenius"
2
+
3
+ module Lita
4
+ module Handlers
5
+ class Genius < Handler
6
+
7
+ route(/^genius\s+(.+)/i, :search, command:true,
8
+ help: {t("help.search_key") => t("help.search_value")})
9
+
10
+ def search(response)
11
+ query = response.matches.first.first
12
+ songs = RapGenius.search(query)
13
+ if !songs.empty?
14
+ song = songs.first
15
+ response.reply song.description.gsub(/\n+/, " ")
16
+ response.reply "#{song.artist.name} - #{song.title} | http://genius.com/songs/#{song.id}"
17
+ else
18
+ response.reply "No songs found for '#{query}'"
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ Lita.register_handler(Genius)
25
+ end
26
+ end
@@ -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/genius"
8
+
9
+ Lita::Handlers::Genius.template_root File.expand_path(
10
+ File.join("..", "..", "templates"),
11
+ __FILE__
12
+ )
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-genius"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["Tristan Chong"]
5
+ spec.email = ["ong@tristaneuan.ch"]
6
+ spec.description = "A Lita handler that returns requested songs from (Rap) Genius."
7
+ spec.summary = "A Lita handler that returns requested songs from (Rap) Genius."
8
+ spec.homepage = "https://github.com/tristaneuan/lita-genius"
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.3"
18
+ spec.add_runtime_dependency "rapgenius", ">= 1.0.5"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "pry-byebug"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rack-test"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
25
+ spec.add_development_dependency "simplecov"
26
+ spec.add_development_dependency "coveralls"
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,7 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ genius:
5
+ help:
6
+ search_key: "genius SONG|LYRICS"
7
+ search_value: "Retrieve a matching song from (Rap) Genius."
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Genius, lita_handler: true do
4
+
5
+ it { is_expected.to route_command("genius weeknd montreal").to(:search) }
6
+
7
+ describe "#search" do
8
+
9
+ it "returns the top result for a search query" do
10
+ send_command "genius runnin through the 6 with my woes"
11
+ expect(replies.count).to eq 2
12
+ expect(replies.first).to match(/aphorism/)
13
+ expect(replies.last).to match(/^Drake - Know Yourself \| http:\/\/genius\.com\/songs\/703654/)
14
+ expect(replies.first).not_to include("\n")
15
+ end
16
+
17
+ it "returns an appropriate message when there are no search results" do
18
+ send_command "genius aklsjklawjekj"
19
+ expect(replies.count).to eq 1
20
+ expect(replies.first).to match(/^No songs found for 'aklsjklawjekj'$/)
21
+ end
22
+
23
+ end
24
+
25
+ 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-genius"
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
File without changes
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-genius
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tristan Chong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-06 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.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rapgenius
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.5
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: pry-byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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: rack-test
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
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coveralls
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: A Lita handler that returns requested songs from (Rap) Genius.
140
+ email:
141
+ - ong@tristaneuan.ch
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".coveralls.yml"
147
+ - ".gitignore"
148
+ - ".travis.yml"
149
+ - Gemfile
150
+ - LICENSE
151
+ - README.md
152
+ - Rakefile
153
+ - lib/lita-genius.rb
154
+ - lib/lita/handlers/genius.rb
155
+ - lita-genius.gemspec
156
+ - locales/en.yml
157
+ - spec/lita/handlers/genius_spec.rb
158
+ - spec/spec_helper.rb
159
+ - templates/.gitkeep
160
+ homepage: https://github.com/tristaneuan/lita-genius
161
+ licenses:
162
+ - MIT
163
+ metadata:
164
+ lita_plugin_type: handler
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.2.2
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: A Lita handler that returns requested songs from (Rap) Genius.
185
+ test_files:
186
+ - spec/lita/handlers/genius_spec.rb
187
+ - spec/spec_helper.rb