lita-tinysong 2.0.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: 15af68942e3463e68ec6fe14c2659253f927fd59
4
+ data.tar.gz: 218bae5d696a1a4f6ee47cdc0c700de78f91d5dc
5
+ SHA512:
6
+ metadata.gz: f80738b39deed26725539dfecd252c01db6ebc74813df33f1ccfa5807087d142b56d2a774848c27821ea16ed4a0e6b08ba323b515c21bcf387ecfcbf1f549d62
7
+ data.tar.gz: 4a07ac3c910f8b1c4aa7e87614185f30dae677a3ac5428763dd3cd1d4a3babcc6377874ac75af479323063f2a8fa6ed7f5ff57835c0ae8105a7fb3c120dc9975
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+
2
+ source 'https://rubygems.org'
3
+
4
+ gemspec
5
+
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lita-tinysong (1.0.0)
5
+ lita (> 4.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.5)
11
+ faraday (0.9.1)
12
+ multipart-post (>= 1.2, < 3)
13
+ http_router (0.11.1)
14
+ rack (>= 1.0.0)
15
+ url_mount (~> 0.2.1)
16
+ i18n (0.7.0)
17
+ ice_nine (0.11.1)
18
+ lita (4.2.0)
19
+ bundler (>= 1.3)
20
+ faraday (>= 0.8.7)
21
+ http_router (>= 0.11.1)
22
+ i18n (>= 0.6.9)
23
+ ice_nine (>= 0.11.0)
24
+ multi_json (>= 1.7.7)
25
+ puma (>= 2.7.1)
26
+ rack (>= 1.5.2)
27
+ rb-readline (>= 0.5.1)
28
+ redis-namespace (>= 1.3.0)
29
+ thor (>= 0.18.1)
30
+ multi_json (1.10.1)
31
+ multipart-post (2.0.0)
32
+ puma (2.11.1)
33
+ rack (>= 1.1, < 2.0)
34
+ rack (1.6.0)
35
+ rake (10.4.2)
36
+ rb-readline (0.5.2)
37
+ redis (3.2.1)
38
+ redis-namespace (1.5.1)
39
+ redis (~> 3.0, >= 3.0.4)
40
+ rspec (3.2.0)
41
+ rspec-core (~> 3.2.0)
42
+ rspec-expectations (~> 3.2.0)
43
+ rspec-mocks (~> 3.2.0)
44
+ rspec-core (3.2.1)
45
+ rspec-support (~> 3.2.0)
46
+ rspec-expectations (3.2.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.2.0)
49
+ rspec-mocks (3.2.1)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.2.0)
52
+ rspec-support (3.2.2)
53
+ thor (0.19.1)
54
+ url_mount (0.2.1)
55
+ rack
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ bundler (~> 1.3)
62
+ lita-tinysong!
63
+ rake
64
+ rspec (~> 3.0)
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # lita-tinysong
2
+
3
+ `lita-tinysong` is a [Lita](https://github.com/jimmycuadra/lita) handler that lets
4
+ Lita respond with [Tinysong](http://tinysong.com) links.
5
+
6
+ ## Installation
7
+ ```ruby
8
+ gem 'lita-tinysong'
9
+ ```
10
+
11
+ ## Configuration
12
+
13
+ You'll need a Tinysong API key: get one [here](http://tinysong.com/api).
14
+
15
+ ```ruby
16
+ Lita.configure do |config|
17
+ ...
18
+ config.handlers.tinysong.api_key = 'your_api_key_goes_here'
19
+ ...
20
+ end
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ `killpack`: `Lita: groove me let the music play`
26
+
27
+ `Lita`: `http://tinysong.com/XtWt`
@@ -0,0 +1,2 @@
1
+ require "lita/handlers/tinysong"
2
+
@@ -0,0 +1,31 @@
1
+ require 'lita'
2
+ module Lita
3
+ module Handlers
4
+ class Tinysong < Handler
5
+
6
+ config :api_key
7
+
8
+ route(/(groove)( me)? (.*)/i, :groove, command: true, help: { "groove (me) SONG" => "Returns a Tinysong url for SONG" })
9
+
10
+ def groove(response)
11
+ unless Lita.config.handlers.tinysong.api_key
12
+ response.reply "Tinysong API key required"
13
+ return
14
+ end
15
+
16
+ query = response.matches[0][2]
17
+ result = http.get("http://tinysong.com/a/#{query.gsub(/\s+/, "+")}", format: 'json', key: Lita.config.handlers.tinysong.api_key).body
18
+
19
+ if result == "[]"
20
+ response.reply "I couldn't find any results for '#{query}'!"
21
+ else
22
+ response.reply result.gsub(/"/, '').gsub(/\\/, '')
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ Lita.register_handler(Tinysong)
29
+ end
30
+ end
31
+
@@ -0,0 +1,23 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "lita-tinysong"
4
+ spec.version = "2.0.0"
5
+ spec.authors = ["Jordan Killpack"]
6
+ spec.email = ["jordan.killpack@gatech.edu"]
7
+ spec.description = "Tinysong Lita handler"
8
+ spec.summary = "Tinysong Lita handler"
9
+ spec.homepage = "https://github.com/killpack/lita-tinysong"
10
+ spec.license = "MIT"
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.0"
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rspec", "~> 3.0"
22
+ end
23
+
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::Tinysong, lita_handler: true do
4
+ it { is_expected.to route_command("groove me the final countdown").to :groove }
5
+ it { is_expected.to route_command("groove last night a dj saved my life").to :groove }
6
+
7
+ describe "#groove" do
8
+ context "when no API key is set" do
9
+ it "complains loudly" do
10
+ send_command("groove me whatever you feel like, buddy")
11
+ expect(replies.last).to include("Tinysong API key required")
12
+ end
13
+ end
14
+
15
+ context "when an API key is set" do
16
+ before do
17
+ Lita.config.handlers.tinysong.api_key = 'a_fake_api_key'
18
+ end
19
+ context "when a song is found" do
20
+ let(:body) { "http:\/\/tinysong.com\/gHQJ" }
21
+ before do
22
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(double("Faraday::Response", status: 200, body: body))
23
+ end
24
+ it "replies with a link to the song" do
25
+ send_command("groove gut feeling")
26
+ expect(replies.last).to include("http://tinysong.com/gHQJ")
27
+ end
28
+ end
29
+
30
+ context "when no song is found" do
31
+ let(:body) { "[]" }
32
+ before do
33
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(double("Faraday::Response", status: 200, body: body))
34
+ end
35
+ it "is apologetic" do
36
+ send_command("groove me dog police where are you coming from")
37
+ expect(replies.last).to include("I couldn't find any results for 'dog police where are you coming from'!")
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ require 'lita-tinysong'
2
+ require 'lita/rspec'
3
+ Lita.version_3_compatibility_mode = false
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-tinysong
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Killpack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-26 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.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'
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'
69
+ description: Tinysong Lita handler
70
+ email:
71
+ - jordan.killpack@gatech.edu
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - README.md
80
+ - lib/lita-tinysong.rb
81
+ - lib/lita/handlers/tinysong.rb
82
+ - lita-tinysong.gemspec
83
+ - spec/lita/handlers/tinysong_spec.rb
84
+ - spec/spec_helper.rb
85
+ homepage: https://github.com/killpack/lita-tinysong
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Tinysong Lita handler
109
+ test_files:
110
+ - spec/lita/handlers/tinysong_spec.rb
111
+ - spec/spec_helper.rb
112
+ has_rdoc: