lita-destiny 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: 39cd33b667454427dce7205fa629b637d70026fa
4
+ data.tar.gz: 28c0d74636df193b0ede997866ce093a8f9b2b59
5
+ SHA512:
6
+ metadata.gz: 8b90f040b89ce65cdd28dd42a1c172de105fe922c32243fbced9fff18fb313db7bbd80878e47a9774540067bb84912ddcc56c54a529036df2877e4b1a6dace26
7
+ data.tar.gz: edd69da4c9344658c4d31085bbe75282212aa4e7b14ee5e329f6fbfead2489ce978852b8ac52760bf3e0aa812d3dba1330805147ad719b1c078f631c2a7b2cc5
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,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'httparty'
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Pat Irwin "pDaily"
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # lita-destiny
2
+
3
+ [![Build Status](https://travis-ci.org/PDaily/lita-destiny.svg?branch=master)](https://travis-ci.org/PDaily/lita-destiny)
4
+ [![Coverage Status](https://coveralls.io/repos/PDaily/lita-destiny/badge.svg?branch=master)](https://coveralls.io/r/PDaily/lita-destiny?branch=master)
5
+
6
+ Lita handler for interacting with the Destiny API
7
+
8
+ ## Installation
9
+
10
+ Add lita-destiny to your Lita instance's Gemfile:
11
+
12
+ ``` ruby
13
+ gem "lita-destiny"
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ Add the config to your lita config file with your Bungie API key:
19
+ ``` ruby
20
+ config.handlers.destiny.api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ This gem adds several methods for chat routes.
26
+
27
+
28
+ ##### #advisors
29
+ > Returns a hash object containing the days advisor report
30
+ > For brevity, see http://www.bungie.net/Platform/Destiny/Advisors/
31
+
32
+ #### #activity(activity_hash, raw=false)
33
+ > Two options: *raw data* as returned by Bungies server or *parsed data* as manipulated by the method.
34
+ >
35
+ > Defaults to *parsed data*, but can be overridden by passing ```true``` as the second argument.
36
+
37
+ ##### #nightfall(options={})
38
+ > Returns a hash object from #activity
39
+ ```
40
+ { activityName: raw_data['activityName'],
41
+ activityDescription: raw_data['activityDescription'],
42
+ skulls: skulls }
43
+ ```
44
+ ##### #weekly_strike(options={})
45
+ > Returns a hash object
46
+ ```
47
+ { activityName: raw_data['activityName'],
48
+ activityDescription: raw_data['activityDescription'],
49
+ skulls: skulls }
50
+ ```
51
+
52
+ ##### #arena(options={})
53
+ > Not defined yet. No public endpoint.
54
+ > To be complete when there is one.
55
+
56
+ ##### #xur
57
+ > Work in progress, will return items being sold as well as prices and location.
58
+
59
+ ##### #place(place_hash)
60
+ > Returns a hash object
61
+ ```
62
+ { place_name: raw_data['placeName'],
63
+ place_desc: raw_data['placeDescription'] }
64
+ ```
65
+
66
+ ##### #destination(dest_hash)
67
+ > Returns a hash object
68
+ ```
69
+ { dest_name: raw_data['destinationName'],
70
+ dest_desc: raw_data['destinationDescription'] }
71
+
72
+ ```
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,83 @@
1
+ require 'httparty'
2
+
3
+ module DestinyApi
4
+ include HTTParty
5
+ format :json
6
+ base_uri 'www.bungie.net/platform/destiny/'
7
+
8
+
9
+ # Init the Destiny API with Bungie API stored in ENV variable
10
+ # destiny = Destiny.new(api_token)
11
+ def initialize(api_token)
12
+ @headers = { 'X-API-Key' => api_token, 'Content-Type' => 'application/json' }
13
+ end
14
+
15
+ # Pull the days advisor report from http://www.bungie.net/platform/destiny/advisors/
16
+ # destiny.advisors
17
+ def advisors
18
+ raw_data = self.class.get('/advisors', headers: @headers)
19
+ parsed = raw_data.parsed_response['Response']['data']
20
+ end
21
+
22
+ def activity(activity_hash, raw=false)
23
+ raw_data = self.class.get("/manifest/activity/#{activity_hash}").parsed_response['Response']['data']['activity']
24
+ skulls = []
25
+ raw_data['skulls'].each do |skull|
26
+ skulls << skull['displayName']
27
+ end
28
+ unless raw == true
29
+ parsed_data = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
30
+ else
31
+ raw_data
32
+ end
33
+ end
34
+
35
+ # Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
36
+ # Optional boolean argument, defaults to false from activity method to only return basic information for Lita bot.
37
+ #
38
+ # destiny.nightfall
39
+ #
40
+ def nightfall(options={})
41
+ nightfall_activity_hash = self.advisors['nightfallActivityHash']
42
+ activity(nightfall_activity_hash, boolean)
43
+ end
44
+
45
+ # Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
46
+ # Returns an array of three items, only need one for the skulls and location.
47
+ #
48
+ # Optional boolean argument, defaults to false from activity method to return basic information for Lita bot.
49
+ #
50
+ # destiny.weekly_strike(false)
51
+ #
52
+ def weekly_strike(options={})
53
+ heroic_strike_hashes = self.advisors['heroicStrikeHashes']
54
+ activity(heroic_strike_hashes[0], boolean)
55
+ end
56
+
57
+ # Pull the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
58
+ #
59
+ #
60
+ # No known endpoints.
61
+ def arena(options={})
62
+ end
63
+
64
+ # WIP: Pull xur inventory
65
+ # http://www.bungie.net/platform/destiny/advisors/xur/?definitions=true
66
+ def xur
67
+ raw_data = self.class.get('/advisors/xur/?definitions=true').parsed_response['Response']['definitions']
68
+ end
69
+
70
+ # Pull the days bounties
71
+ def bounties
72
+ end
73
+
74
+ def place(place_hash)
75
+ raw data = self.class.get('/manifest/place/#{place_hash}').parsed_response['Response']['data']['place']
76
+ response = { place_name: raw_data['placeName'], place_desc: raw_data['placeDescription'] }
77
+ end
78
+
79
+ def destination(destination_hash)
80
+ raw_data = self.class.get('/manifest/destination/#{destination_hash}').parsed_response['Response']['data']
81
+ response = { dest_name: raw_data['destinationName'], dest_desc: raw_data['destinationDescription'] }
82
+ end
83
+ end
@@ -0,0 +1,24 @@
1
+ module Lita
2
+ module Handlers
3
+ class Destiny < Handler
4
+ include DestinyApi
5
+ config :api_key
6
+
7
+ DESTINY = DestinyApi.new(config.api_key)
8
+
9
+ route(/!+?\b(nightfall)/i, build_activity_message(DESTINY.nightfall), help: { "!nightfall" => "Get this weeks nightfall description and skulls" })
10
+
11
+
12
+
13
+ # activity = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
14
+ def build_activity_message(activity)
15
+ activity = activity
16
+ #response.reply("#{activity["activityName"]}\n #{activityDescription["activityDescription"]}\n #{skulls["skulls"]}")
17
+ response.reply("Hi!")
18
+ end
19
+
20
+ end
21
+
22
+ Lita.register_handler(Destiny)
23
+ end
24
+ end
@@ -0,0 +1,13 @@
1
+ require "lita"
2
+
3
+ Lita.load_locales Dir[File.expand_path(
4
+ File.join("..", "..", "locales", "*.yml"), __FILE__
5
+ )]
6
+
7
+ require "destiny/destiny_api"
8
+ require "lita/handlers/destiny"
9
+
10
+ Lita::Handlers::Destiny.template_root File.expand_path(
11
+ File.join("..", "..", "templates"),
12
+ __FILE__
13
+ )
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-destiny"
3
+ spec.version = "0.1.0"
4
+ spec.authors = ["PDaily"]
5
+ spec.email = ["pat.irwin4@gmail.com"]
6
+ spec.description = "Small lita.io handler for interacting with the Destiny API"
7
+ spec.summary = "Lightweight handler to help consume information related to Destiny the game and relaying it neatly in a chatroom."
8
+ spec.homepage = "http://github.com/pDaily/lita-destiny"
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 "httparty", "~> 0.13", ">= 0.13.5"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "pry-byebug", "~> 3.1", ">= 3.1.0"
22
+ spec.add_development_dependency "rake", "~> 10.4", ">= 10.4.2"
23
+ spec.add_development_dependency "rack-test", "~> 0.6", ">= 0.6.3"
24
+ spec.add_development_dependency "rspec", "~> 3.0", ">= 3.0.0"
25
+ spec.add_development_dependency "simplecov", "~> 0.10", ">= 0.10.0"
26
+ spec.add_development_dependency "coveralls", "~> 0.8", ">= 0.8.1"
27
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ destiny:
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::Destiny, lita_handler: true do
4
+ it { is_expected.to route_command("!nightfall").to(:)}
5
+
6
+
7
+ 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-destiny"
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,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-destiny
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - PDaily
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-27 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: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.13.5
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.13'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.13.5
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: pry-byebug
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.1'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 3.1.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.1'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.1.0
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '10.4'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 10.4.2
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '10.4'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 10.4.2
101
+ - !ruby/object:Gem::Dependency
102
+ name: rack-test
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.6'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.3
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.6'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.6.3
121
+ - !ruby/object:Gem::Dependency
122
+ name: rspec
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '3.0'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 3.0.0
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '3.0'
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 3.0.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: simplecov
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '0.10'
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 0.10.0
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.10'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 0.10.0
161
+ - !ruby/object:Gem::Dependency
162
+ name: coveralls
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.8'
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 0.8.1
171
+ type: :development
172
+ prerelease: false
173
+ version_requirements: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '0.8'
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 0.8.1
181
+ description: Small lita.io handler for interacting with the Destiny API
182
+ email:
183
+ - pat.irwin4@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".travis.yml"
190
+ - Gemfile
191
+ - LICENSE
192
+ - README.md
193
+ - Rakefile
194
+ - lib/destiny/destiny_api.rb
195
+ - lib/lita-destiny.rb
196
+ - lib/lita/handlers/destiny.rb
197
+ - lita-destiny.gemspec
198
+ - locales/en.yml
199
+ - spec/lita/handlers/destiny_spec.rb
200
+ - spec/spec_helper.rb
201
+ - templates/.gitkeep
202
+ homepage: http://github.com/pDaily/lita-destiny
203
+ licenses:
204
+ - MIT
205
+ metadata:
206
+ lita_plugin_type: handler
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubyforge_project:
223
+ rubygems_version: 2.2.2
224
+ signing_key:
225
+ specification_version: 4
226
+ summary: Lightweight handler to help consume information related to Destiny the game
227
+ and relaying it neatly in a chatroom.
228
+ test_files:
229
+ - spec/lita/handlers/destiny_spec.rb
230
+ - spec/spec_helper.rb