destiny_rb 0.1.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: 33b674773d7c75eec6ace73041554d225b7c7492
4
+ data.tar.gz: ce89d49e9c8dd492fea6d36b34fb453062e6d778
5
+ SHA512:
6
+ metadata.gz: 9af5f5aaa57188d2a7d6a384772edf933723f2ce937c49a372aaa3a142f5903f61cf99b628721a7aab7296c9bc7e7700d33b03a625f09c281190e3efe305f6f5
7
+ data.tar.gz: ce9cc451ac68e6e2b133e2eeca67b55c124b284145c817ff8ae09f61215cc98a145ecbd9c368bd00e6a163999b47fab131831ddd536b5209f73ad431eb2e9901
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.6
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in destiny_rb.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 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,41 @@
1
+ # DestinyRb
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/destiny_rb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'destiny_rb'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install destiny_rb
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/destiny_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "destiny_rb"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'destiny_rb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "destiny_rb"
8
+ spec.version = Destiny::VERSION
9
+ spec.authors = ["pDaily"]
10
+ spec.email = ["pat@pdaily.me"]
11
+
12
+ spec.summary = %q{Basic Ruby implementation of Bungies Destiny API}
13
+ spec.description = %q{Bungies Destiny API in an easily consumable ruby gem!}
14
+ spec.homepage = "https://github.com/PDaily/destiny-rb"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_runtime_dependency "httparty", "~> 0.13", ">= 0.13.5"
31
+ spec.add_runtime_dependency "rake", "~> 10.4", ">= 10.4.2"
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ spec.add_development_dependency "pry-byebug", "~> 3.1", ">= 3.1.0"
35
+ spec.add_development_dependency "rack-test", "~> 0.6", ">= 0.6.3"
36
+ spec.add_development_dependency "rspec", "~> 3.0", ">= 3.0.0"
37
+ spec.add_development_dependency "simplecov", "~> 0.10", ">= 0.10.0"
38
+ spec.add_development_dependency "coveralls", "~> 0.8", ">= 0.8.1"
39
+ spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4", ">= 0.4.7"
40
+ end
@@ -0,0 +1,96 @@
1
+ module Destiny
2
+ module Advisors
3
+
4
+ # GET the days advisor report from http://www.bungie.net/platform/destiny/advisors/
5
+ #
6
+ # Usage:
7
+ # Destiny::Advisors.report
8
+ #
9
+ # Returns:
10
+ # A JSON object containing activity hashes, end times, and special events.
11
+ #
12
+ def daily_report
13
+ raw_data = self.class.get('/Advisors', headers: @headers)
14
+ parsed = raw_data.parsed_response['Response']['data']
15
+ end
16
+
17
+ # GET the activity information from http://www.bungie.net/platform/destiny/manifest/activity/{activity_hash}/
18
+ #
19
+ # Raw argument will return an unmodified respons from Bungie.
20
+ #
21
+ # Usage:
22
+ # destiny.activity('3508129769', false)
23
+ #
24
+ # Arguments:
25
+ # activity_hash: (String)
26
+ # raw: (Boolean)
27
+ #
28
+ # Returns:
29
+ # A JSON object containing activity information based on the activity hash supplied with:
30
+ # activityName: (String)
31
+ # activityDescription: (String)
32
+ # skulls: (Array)(Strings)
33
+ #
34
+ # If raw = true, returns whole response back from bungie.
35
+ #
36
+ def activity_search(activity_hash, raw=false)
37
+ raw_data = self.class.get("/Manifest/Activity/#{activity_hash}").parsed_response['Response']['data']['activity']
38
+ skulls = []
39
+ raw_data['skulls'].each do |skull|
40
+ skulls << skull['displayName']
41
+ end
42
+ if raw
43
+ raw_data
44
+ else
45
+ parsed_data = { activityName: raw_data['activityName'], activityDescription: raw_data['activityDescription'], skulls: skulls }
46
+ end
47
+ end
48
+
49
+ # GET the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
50
+ #
51
+ # Optional boolean argument.
52
+ #
53
+ # Usage:
54
+ # destiny.nightfall(true)
55
+ #
56
+ # Arguments:
57
+ # raw: (boolean)
58
+ #
59
+ def nightfall(raw=false)
60
+ nightfall_activity_hash = self.daily_report['nightfallActivityHash']
61
+ activity_search(nightfall_activity_hash)
62
+ end
63
+
64
+ # GET the weekly strike info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
65
+ # Returns an array of three items, only need one for the skulls and location.
66
+ #
67
+ # Optional boolean argument, defaults to false from activity method to return basic information for Lita bot.
68
+ #
69
+ # Usage:
70
+ # destiny.weekly_strike(false)
71
+ #
72
+ # Arguments:
73
+ # raw: (boolean)
74
+ #
75
+ def weekly_strike(raw=false)
76
+ heroic_strike_hashes = self.daily_report['heroicStrikeHashes']
77
+ activity_search(heroic_strike_hashes[0], raw)
78
+ end
79
+
80
+ # GET the weekly nightfall info from http://www.bungie.net/platform/destiny/manifest/activity/#{activity_hash}
81
+ #
82
+ # No known endpoints.
83
+ def arena(raw=false, level=32)
84
+ arenas = self.daily_report['arena']
85
+ case level
86
+ when 32
87
+ arenas[0]
88
+ when 34
89
+ arenas[1]
90
+ when 35
91
+ arenas[2]
92
+ end
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'advisors'
2
+ require_relative 'vendors'
3
+ require_relative 'manifest'
4
+ require_relative 'manifest_definitions'
5
+ require_relative 'item_explorer'
6
+ # Destiny-rb module wrapper
7
+ module Destiny
8
+ # Base API Class
9
+ #
10
+ # Usage:
11
+ # destiny = DestinyAPI::Base.new(api_token)
12
+ class Client
13
+ # Include HTTParty Module
14
+ include HTTParty
15
+ # Format HTTP response automatically to JSON
16
+ format :json
17
+ # Set the base URI
18
+ base_uri 'www.bungie.net/Platform/Destiny/'
19
+
20
+ include Advisors
21
+ include Vendors
22
+ include Manifest
23
+ include ManifestDefinitions
24
+ include ItemExplorer
25
+
26
+ # Init the Destiny API with Bungie API stored in ENV variable
27
+ #
28
+ # Usage:
29
+ # destiny = Destiny::Client.new('6971067dec36c6597cd57789a62f48f0')
30
+ #
31
+ # Arguments:
32
+ # api_token: (String)
33
+ #
34
+ # Returns:
35
+ # Destiny client object
36
+ #
37
+ def initialize(api_token)
38
+ @headers = { 'X-API-Key' => api_token, 'Content-Type' => 'application/json' }
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,191 @@
1
+ module Destiny
2
+ module ItemExplorer
3
+
4
+ # Item Explorer Item-Type definitions
5
+ #
6
+ # Usage:
7
+ # client.types(:armor)
8
+ # client.enemy_race(2)
9
+ #
10
+ # Arguments:
11
+ # type: (String/Symbol)
12
+ #
13
+ # Returns:
14
+ # Either the numeric representation of a item type or a symbol of said item type.
15
+ def types(type)
16
+ types = {
17
+ none: 0,
18
+ currency: 1,
19
+ armor: 2,
20
+ weapon: 3,
21
+ bounty: 4,
22
+ completed_bounty: 5,
23
+ bounty_reward: 6,
24
+ message: 7,
25
+ engram: 8,
26
+ consumable: 9,
27
+ exchange_material: 10,
28
+ mission_reward: 11,
29
+ quest_step: 12,
30
+ quest_step_complete: 13
31
+ }
32
+ if type.is_a? Numeric
33
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
34
+ else type.is_a? Symbol
35
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
36
+ end
37
+ end
38
+
39
+
40
+ # Item Explorer Sub-Type definitions
41
+ #
42
+ # Usage:
43
+ # client.sub_type(:sidearm)
44
+ # client.sub_type(17)
45
+ #
46
+ # Arguments:
47
+ # type: (String/Symbol)
48
+ #
49
+ # Returns:
50
+ # Either the numeric representation of a item sub-type or a symbol of said sub-type.
51
+ def sub_type(type)
52
+ types = {
53
+ none: 0,
54
+ crucible: 1,
55
+ vanguard: 2,
56
+ iron_banner: 3,
57
+ queen: 4,
58
+ exotic: 5,
59
+ auto_rifle: 6,
60
+ shotgun: 7,
61
+ machinegun: 8,
62
+ hand_cannon: 9,
63
+ rocket_launcher: 10,
64
+ fusion_rifle: 11,
65
+ sniper_rifle:12,
66
+ pulse_rifle: 13,
67
+ scout_rifle: 14,
68
+ camera: 15,
69
+ crm: 16,
70
+ sidearm: 17
71
+ }
72
+ if type.is_a? Numeric
73
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
74
+ else type.is_a? Symbol
75
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
76
+ end
77
+ end
78
+
79
+ # Item Explorer Ordering definitions
80
+ #
81
+ # Usage:
82
+ # client.order(:rarity)
83
+ # client.enemy_race(3)
84
+ #
85
+ # Arguments:
86
+ # type: (String/Symbol)
87
+ #
88
+ # Returns:
89
+ # Either the numeric representation of a item ordering or a symbol of said ordering.
90
+ def order(type)
91
+ types = {
92
+ none: 0,
93
+ name: 1,
94
+ item_type: 2,
95
+ rarity: 3,
96
+ item_type_name: 4,
97
+ item_stat_hash: 5,
98
+ minimum_required_level: 6,
99
+ maximum_required_level: 7
100
+ }
101
+ if type.is_a? Numeric
102
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
103
+ else type.is_a? Symbol
104
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
105
+ end
106
+ end
107
+
108
+ # Item Explorer Rarity definitions
109
+ #
110
+ # Usage:
111
+ # client.enemy_race(:vex)
112
+ # client.enemy_race(711470098)
113
+ #
114
+ # Arguments:
115
+ # type: (String/Symbol)
116
+ #
117
+ # Returns:
118
+ # Either the numeric representation of a enemy race or a symbol of said race.
119
+ def rarity(type)
120
+ types = {
121
+ none: 0,
122
+ currency: 1,
123
+ basic: 2,
124
+ common: 3,
125
+ rare: 4,
126
+ superior: 5,
127
+ exotic: 6
128
+ }
129
+ if type.is_a? Numeric
130
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
131
+ else type.is_a? Symbol
132
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
133
+ end
134
+ end
135
+
136
+ # Explorer Bucket definitions
137
+ #
138
+ # Usage:
139
+ # client.buckets(:artifact)
140
+ # client.buckets(1)
141
+ #
142
+ # Arguments:
143
+ # type: (String/Symbol)
144
+ #
145
+ # Returns:
146
+ # Either the numeric representation of a explorer bucket or a symbol of said bucket.
147
+ def buckets(type)
148
+ types = {
149
+ none: 0,
150
+ artifact: 1,
151
+ materials: 2,
152
+ consumables: 4,
153
+ mission: 8,
154
+ bounties: 16,
155
+ build: 32,
156
+ primary_weapon: 64,
157
+ special_weapon: 128,
158
+ heavy_weapon: 256,
159
+ head: 512,
160
+ arms: 1024,
161
+ chest: 2048,
162
+ legs: 4096,
163
+ class_items: 8192,
164
+ ghost: 16384,
165
+ vehicle: 32768,
166
+ ship: 65536,
167
+ shader: 131072,
168
+ emblem: 262144
169
+ }
170
+ if type.is_a? Numeric
171
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
172
+ else type.is_a? Symbol
173
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
174
+ end
175
+ end
176
+
177
+ def get_exlorer_items(options={})
178
+ definitions = options[:definitions] || false
179
+ character_class = character_class(options[:character_class] || 'unknown')
180
+ types = types(options[:types] || 'none')
181
+ sub_type = sub_type(options[:sub_type] || 'none')
182
+ order = order(options[:order] || 'none')
183
+ rarity = rarity(options[:rarity] || 'none')
184
+ buckets = buckets(options[:buckets] || 'none')
185
+ page = options[:page] || 0
186
+ count = options[:count] || 250
187
+ self.class.get("/Explorer/Items/?definitions=#{definitions}&count=#{count}&characterClass=#{character_class}&types=#{types}&subtype=#{sub_type}&order=#{order}&rarity=#{rarity}&buckets=#{buckets}&page=#{page}")
188
+ end
189
+
190
+ end
191
+ end
@@ -0,0 +1,31 @@
1
+ module Destiny
2
+ module Manifest
3
+
4
+ # GET information about a place, specifically a planet.
5
+ #
6
+ # Usage:
7
+ # destiny.place('3747705955')
8
+ #
9
+ # Arguments:
10
+ # place_hash: (String)
11
+ #
12
+ def place(place_hash)
13
+ raw data = self.class.get('/Manifest/Place/#{place_hash}').parsed_response['Response']['data']['place']
14
+ response = { place_name: raw_data['placeName'], place_desc: raw_data['placeDescription'] }
15
+ end
16
+
17
+ # GET information about a destination, specifically a location on a planet.
18
+ #
19
+ # Usage:
20
+ # destiny.destination('518553403')
21
+ #
22
+ # Arguments:
23
+ # destination_hash: (String)
24
+ #
25
+ def destination(destination_hash)
26
+ raw_data = self.class.get('/Manifest/Destination/#{destination_hash}').parsed_response['Response']['data']
27
+ response = { dest_name: raw_data['destinationName'], dest_desc: raw_data['destinationDescription'] }
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,97 @@
1
+ module Destiny
2
+ # Destiny Manifest definitions
3
+ # Pulled from sqlite file in the EN manifest
4
+ # http://www.bungie.net/Platform/Destiny/Manifest/
5
+ module ManifestDefinitions
6
+
7
+ # Character Class definitions
8
+ #
9
+ # Usage:
10
+ # client.character_class(:titan)
11
+ # client.character_class(0)
12
+ #
13
+ # Arguments:
14
+ # type: (String/Symbol)
15
+ #
16
+ # Returns:
17
+ # Either the numeric representation of a character class or a symbol of said class.
18
+ #
19
+ def character_class(type)
20
+ types = {
21
+ titan: 0,
22
+ hunter: 1,
23
+ warlock: 2,
24
+ unknown: 3
25
+ }
26
+ if type.is_a? Numeric
27
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
28
+ else type.is_a? Symbol
29
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
30
+ end
31
+ end
32
+
33
+ # Enemy Race definitions
34
+ #
35
+ # Usage:
36
+ # client.enemy_race(:vex)
37
+ # client.enemy_race(711470098)
38
+ #
39
+ # Arguments:
40
+ # type: (String/Symbol)
41
+ #
42
+ # Returns:
43
+ # Either the numeric representation of a enemy race or a symbol of said race.
44
+ def enemy_race(type)
45
+ types = {
46
+ none: 0, # Not a real Bungie value
47
+ fallen: 1636291695,
48
+ vex: 711470098,
49
+ cabal: 546070638,
50
+ hive: 3265589059
51
+ }
52
+ if type.is_a? Numeric
53
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
54
+ else type.is_a? Symbol
55
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
56
+ end
57
+ end
58
+
59
+ # Skull (modifier) definitions
60
+ #
61
+ # Usage:
62
+ # client.skulls(:juggler)
63
+ # client.skulls(13)
64
+ #
65
+ # Arguments:
66
+ # type: (String/Symbol)
67
+ #
68
+ # Returns:
69
+ # Either the numeric representation of a skull or a symbol of said skull.
70
+ def skulls(type)
71
+ types = {
72
+ none: 0, # Not a real Bungie value
73
+ trickle: 1,
74
+ grounded: 2,
75
+ exposure: 3,
76
+ airborne: 4,
77
+ small_arms: 5,
78
+ brawler: 6,
79
+ catapult: 7,
80
+ specialist: 8,
81
+ arc_burn: 9,
82
+ solar_burn: 10,
83
+ void_burn: 11,
84
+ angry: 12,
85
+ juggler: 13,
86
+ lightswitch: 19,
87
+ melee_damage_boost: 20
88
+ }
89
+ if type.is_a? Numeric
90
+ requested_type = types.key(type) || :none# Fetch type from hash, if type doesn't match return 'none'
91
+ else type.is_a? Symbol
92
+ requested_type = types.fetch(type, 0) # Fetch type from hash, if type doesn't match return 0 for 'none'
93
+ end
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,30 @@
1
+ module Destiny
2
+ module Vendors
3
+
4
+ # WIP: Pull xur inventory
5
+ # http://www.bungie.net/platform/destiny/advisors/xur/
6
+ def xur(raw=false)
7
+ raw_data = self.class.get('/Advisors/Xur/').parsed_response['Response']
8
+
9
+ if raw
10
+ raw_data
11
+ elsif raw_data.empty?
12
+ return { status: "Xur is not in the game world." }
13
+ else
14
+ vendor_hash = raw_data['data']['vendorHash']
15
+ sale_items = {}
16
+ # Hacky? Probs.
17
+ raw_data['data']['saleItemCategories'].each do |category|
18
+ items = { category['categoryTitle'] => category['saleItems'].map!{|item| {:item_hash => item['item']['itemHash'], :item_cost => item['costs'][0]['value'], :item_cost_hash => item['costs'][0]['itemHash']} } }
19
+ sale_items.merge!(items)
20
+ end
21
+ sale_items
22
+ end
23
+ end
24
+
25
+ def vendor(vendor_hash)
26
+ raw_data = self.class.get("/Manifest/Vendor/#{vendor_hash}").parsed_response['Response']['data']['vendor']['summary']
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Destiny
2
+ VERSION = "0.1.0"
3
+ end
data/lib/destiny_rb.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'httparty'
2
+ require 'destiny_rb/version'
3
+ require 'destiny_rb/client'
4
+ require 'destiny_rb/advisors'
5
+ require 'destiny_rb/vendors'
6
+ require 'destiny_rb/manifest'
7
+ require 'destiny_rb/manifest_definitions'
8
+ require 'destiny_rb/item_explorer'
9
+
10
+ module Destiny
11
+ def self.new(options={})
12
+ Destiny::Client.new(options)
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,238 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: destiny_rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - pDaily
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.13.5
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.13'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.5
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '10.4'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 10.4.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '10.4'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 10.4.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.10'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.10'
67
+ - !ruby/object:Gem::Dependency
68
+ name: pry-byebug
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.1'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.1.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.1'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.1.0
87
+ - !ruby/object:Gem::Dependency
88
+ name: rack-test
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: '0.6'
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.3
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.6'
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 0.6.3
107
+ - !ruby/object:Gem::Dependency
108
+ name: rspec
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '3.0'
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 3.0.0
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.0'
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: 3.0.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: simplecov
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - "~>"
132
+ - !ruby/object:Gem::Version
133
+ version: '0.10'
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: 0.10.0
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - "~>"
142
+ - !ruby/object:Gem::Version
143
+ version: '0.10'
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 0.10.0
147
+ - !ruby/object:Gem::Dependency
148
+ name: coveralls
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.8'
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: 0.8.1
157
+ type: :development
158
+ prerelease: false
159
+ version_requirements: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: '0.8'
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.8.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: codeclimate-test-reporter
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.4'
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: 0.4.7
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '0.4'
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: 0.4.7
187
+ description: Bungies Destiny API in an easily consumable ruby gem!
188
+ email:
189
+ - pat@pdaily.me
190
+ executables: []
191
+ extensions: []
192
+ extra_rdoc_files: []
193
+ files:
194
+ - ".gitignore"
195
+ - ".rspec"
196
+ - ".travis.yml"
197
+ - CODE_OF_CONDUCT.md
198
+ - Gemfile
199
+ - LICENSE.txt
200
+ - README.md
201
+ - Rakefile
202
+ - bin/console
203
+ - bin/setup
204
+ - destiny_rb.gemspec
205
+ - lib/destiny_rb.rb
206
+ - lib/destiny_rb/advisors.rb
207
+ - lib/destiny_rb/client.rb
208
+ - lib/destiny_rb/item_explorer.rb
209
+ - lib/destiny_rb/manifest.rb
210
+ - lib/destiny_rb/manifest_definitions.rb
211
+ - lib/destiny_rb/vendors.rb
212
+ - lib/destiny_rb/version.rb
213
+ homepage: https://github.com/PDaily/destiny-rb
214
+ licenses:
215
+ - MIT
216
+ metadata:
217
+ allowed_push_host: https://rubygems.org
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
227
+ required_rubygems_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ requirements: []
233
+ rubyforge_project:
234
+ rubygems_version: 2.4.8
235
+ signing_key:
236
+ specification_version: 4
237
+ summary: Basic Ruby implementation of Bungies Destiny API
238
+ test_files: []