gw2_ruby 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a103fd9175cccac58107160e9abc50ed0c746ab
4
+ data.tar.gz: a33c6dcb52acb272f50c2882ce194ce4c2561cc8
5
+ SHA512:
6
+ metadata.gz: 749432ec7109cb44b617cd8efd5ef12ecc6723cc2c0ddbf7c9f7baad37667285c0c99c9953fb65f14e6a848b01653833f7275be2557849537d5f6f90b44e1774
7
+ data.tar.gz: caf8b422031f98725c465f2c34aa1334f4dae9d7d347b06ce5897f80774f432abef57a000c9c78c9eadaed84e021878fb07878daa7ac6ba42a413787d2d71adc
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gw2-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Andrew Turner
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.
@@ -0,0 +1,39 @@
1
+ # Gw2::Ruby
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/gw2/ruby`. 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 'gw2-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install gw2-ruby
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 `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` to 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
+ 1. Fork it ( https://github.com/[my-github-username]/gw2-ruby/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gw2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gw2_ruby"
8
+ spec.version = GW2::VERSION
9
+ spec.authors = ["Andrew Turner"]
10
+ spec.email = ["sunspar@sunspar.net"]
11
+
12
+ spec.summary = %q{Ruby wrapper for the Guild Wars 2 REST API.}
13
+ spec.homepage = "http://www.sunspar.net"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ # Development dependencies
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ # Runtime dependencies
26
+ spec.add_runtime_dependency "faraday", "~> 0.9"
27
+ spec.add_runtime_dependency "faraday_middleware"
28
+ spec.add_runtime_dependency "json", "~> 1.8"
29
+
30
+ end
@@ -0,0 +1,27 @@
1
+ module GW2
2
+ module API
3
+ class Account
4
+
5
+ def self.info
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.bank
10
+ #TODO: Implement
11
+ end
12
+
13
+ def self.materials
14
+ #TODO: Implement
15
+ end
16
+
17
+
18
+ class << self
19
+ private
20
+ def call_api params
21
+ #TODO: Implement
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ require 'gw2_ruby'
2
+
3
+ module GW2
4
+ module API
5
+ class Build
6
+
7
+ def self.get
8
+ return call_api
9
+ end
10
+
11
+ class << self
12
+ private
13
+ def call_api
14
+ resource = '/v2/build'
15
+ response = GW2::API::ANET_CONN_NOAUTH.get resource
16
+ return response.body
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ require 'gw2_ruby'
2
+
3
+ module GW2
4
+ module API
5
+ class Character
6
+
7
+ def self.all
8
+ #TODO: Implement
9
+ end
10
+
11
+ def self.where
12
+ #TODO: Implement
13
+ end
14
+
15
+ def self.where_ids ids=[]
16
+ #TODO: Implement
17
+ end
18
+
19
+ class << self
20
+ private
21
+ def call_api params
22
+ #TODO: Implement
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'gw2_ruby'
2
+
3
+ module GW2
4
+ module API
5
+ class Color
6
+
7
+ def self.all
8
+ return call_api
9
+ end
10
+
11
+ def self.where params={}
12
+ params[:ids] ||= 'all'
13
+ return call_api params
14
+ end
15
+
16
+ class << self
17
+ private
18
+ def call_api params={}
19
+ params[:lang] ||= 'en'
20
+
21
+ resource = '/v2/colors'
22
+
23
+ unless params[:lang].nil?
24
+ resource = "#{resource}?lang=#{params[:lang]}"
25
+ end
26
+
27
+ unless params[:ids].nil?
28
+ # Split the array, and concatenate them as a string of ids, separated by commas
29
+ ids_string = ''
30
+ params[:ids].each {|item| ids_string="#{ids_string},#{item}" }
31
+ resource = "#{resource}&ids=#{ids_string}"
32
+ end
33
+
34
+ response = GW2::API::ANET_CONN_NOAUTH.get resource
35
+ return response.body
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,77 @@
1
+ require 'gw2_ruby'
2
+
3
+ module GW2
4
+ module API
5
+ class Commerce
6
+
7
+ def self.coins_to_gems qty=0
8
+ #TODO: Implement
9
+ end
10
+
11
+ def self.gems_to_coins qty=0
12
+ #TODO: Implement
13
+ end
14
+
15
+ def self.listings_all
16
+ params = {}
17
+ params[:endpoint] = "/v2/commerce/listings"
18
+ return call_api params
19
+ end
20
+
21
+ def self.listings_where ids=[]
22
+ params = {}
23
+ params[:ids] = ids
24
+ params[:endpoint] = '/v2/commerce/listings'
25
+ return call_api params
26
+ end
27
+
28
+ def self.prices_all
29
+ params = {}
30
+ params[:endpoint] = '/v2/commerce/prices'
31
+ return call_api params
32
+ end
33
+
34
+ def self.prices_where ids=[]
35
+ params = {}
36
+ params[:ids] = ids
37
+ params[:endpoint] = '/v2/commerce/prices'
38
+ end
39
+
40
+ def self.current_buys key
41
+ #TODO: Implement
42
+ end
43
+
44
+ def self.current_sells key
45
+ #TODO: Implement
46
+ end
47
+
48
+ def self.past_buys key
49
+ #TODO: Implement
50
+ end
51
+
52
+ def self.past_sells key
53
+ #TODO: Implement
54
+ end
55
+
56
+ class << self
57
+ private
58
+ def call_api params
59
+ params[:lang] ||= 'en'
60
+ resource = "#{params[:endpoint]}?lang=#{params[:lang]}"
61
+
62
+ unless params[:ids].nil?
63
+ ids_string = ''
64
+ params[:ids].each {|item| ids_string="#{ids_string},#{item}" }
65
+ resource = "#{resource}&ids=#{ids_string}"
66
+ puts ids_string
67
+ puts resource
68
+ end
69
+
70
+ response = GW2::API::ANET_CONN_NOAUTH.get resource
71
+ return response.body
72
+ end
73
+ end
74
+
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,24 @@
1
+ module GW2
2
+ module API
3
+ class Continent
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where params={}
10
+ # if they have specific fields, we can customize the call
11
+ #continent id, floor id, region id, type
12
+ #TODO: Implement
13
+ end
14
+
15
+ class << self
16
+ private
17
+ def call_api params
18
+ #TODO: Implement
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ module GW2
2
+ module API
3
+ class File
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ return self.where [] # Does this kind of thing work?
8
+ end
9
+
10
+ def self.where ids=[]
11
+ #TODO: Implement
12
+ end
13
+
14
+ class << self
15
+ private
16
+ def call_api params
17
+ #TODO: Implement
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ module GW2
2
+ module API
3
+ class Floor
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where params={}
10
+ #continentId, floorId
11
+ #TODO: Implement
12
+ end
13
+
14
+
15
+
16
+ class << self
17
+ private
18
+ def call_api params
19
+ #TODO: Implement
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module GW2
2
+ module API
3
+ class Item
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where ids=[]
10
+ #TODO: Implement
11
+ end
12
+
13
+ class << self
14
+ private
15
+ def call_api params
16
+ #TODO: Implement
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module GW2
2
+ module API
3
+ class Map
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where params={}
10
+ #TODO: Implement
11
+ end
12
+
13
+ class << self
14
+ private
15
+ def call_api params
16
+ #TODO: Implement
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module GW2
2
+ module API
3
+ class Material
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where ids=[]
10
+ #TODO: Implement
11
+ end
12
+
13
+ class << self
14
+ private
15
+ def call_api params
16
+ #TODO: Implement
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module GW2
2
+ module API
3
+ class Quaggan
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where ids=[]
10
+ #TODO: Implement
11
+ end
12
+
13
+ class << self
14
+ private
15
+ def call_api params
16
+ #TODO: Implement
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,36 @@
1
+ module GW2
2
+ module API
3
+ class Recipe
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ # Recipes API with supplied item identifiers.
10
+ #
11
+ # Caller may supply one (or more) identifiers as an array.
12
+ def self.where ids=[]
13
+ #TODO: Implement
14
+ end
15
+
16
+ # Recipies Search by component type
17
+ #
18
+ # Argument: a hash containing either an :input or :output key which references either an integer item id, or string representing an item id
19
+ # If both input and output are specified, the API will only call with the input argument. As per the API,
20
+ # these parameters are mutually exclusive (https://wiki.guildwars2.com/wiki/API:2/recipes/search)
21
+ def self.search params={}
22
+ #type = input or output
23
+ #id = item id
24
+ #TODO: Implement
25
+ end
26
+
27
+ class << self
28
+ private
29
+ def call_api params
30
+ #TODO: Implement
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,22 @@
1
+ module GW2
2
+ module API
3
+ class Skin
4
+
5
+ def self.all
6
+ #TODO: Implement
7
+ end
8
+
9
+ def self.where ids=[]
10
+ #TODO: Implement
11
+ end
12
+
13
+ class << self
14
+ private
15
+ def call_api params
16
+ #TODO: Implement
17
+ end
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,18 @@
1
+ module GW2
2
+ module API
3
+ class TokenInfo
4
+
5
+ def self.info
6
+ #TODO: Implement
7
+ end
8
+
9
+ class << self
10
+ private
11
+ def call_api params
12
+ #TODO: Implement
13
+ end
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ #require_relative '../../gw2-ruby'
2
+
3
+ module GW2
4
+ module API
5
+ class World
6
+
7
+ def self.all
8
+ #TODO: Implement
9
+ end
10
+
11
+ def self.where ids=[]
12
+ #TODO: Implement
13
+ params = {}
14
+ if ids.any?
15
+ params[:ids] = ''
16
+ ids.each { |item| params[:ids] = "#{params[:ids]},#{item}"}
17
+ end
18
+
19
+ response = call_api params
20
+ return response
21
+ end
22
+
23
+ class << self
24
+ private
25
+ def call_api params
26
+ #TODO: Implement
27
+ end
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module GW2
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,49 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'faraday_middleware'
4
+
5
+ Dir[File.expand_path './lib/gw2/**/*.rb'].each {|f| require f}
6
+
7
+ module GW2
8
+ module API
9
+ #URL Root
10
+ API_ROOT = 'https://api.guildwars2.com/'
11
+ ANET_CONN_NOAUTH = Faraday.new GW2::API::API_ROOT do |conn|
12
+ conn.request :json
13
+ conn.response :json, :content_type => /\bjson$/
14
+ conn.adapter Faraday.default_adapter
15
+ end
16
+
17
+ ANET_CONN_AUTH = Faraday.new GW2::API::API_ROOT do |conn|
18
+ conn.request :oauth2, ''
19
+ conn.request :json
20
+ conn.response :json, :content_type => /\bjson$/
21
+ conn.adapter Faraday.default_adapter
22
+ end
23
+
24
+ ENDPOINT = {
25
+ :account => '/v2/account',
26
+ :build => '/v2/build',
27
+ :colors => '/v2/colors',
28
+ :commerce_exchange => '/v2/commerce/exchange',
29
+ :commerce_exchange_coins => '/v2/commerce/exchange/coins',
30
+ :commerce_exchange_gems => '/v2/commerce/exchange/gems',
31
+ :commerce_listings => '/v2/commerce/listings',
32
+ :commerce_prices => '/v2/commerce/prices',
33
+ :commerce_transactions => '/v2/commerce/transactions',
34
+ :continents => '/v2/continents',
35
+ :files => '/v2/files',
36
+ :floors => '/v2/floors',
37
+ :items => '/v2/items',
38
+ :maps => '/v2/maps',
39
+ :quaggans => '/v2/quaggans',
40
+ :recipes => '/v2/recipes',
41
+ :recipes_search => '/v2/recipes/search',
42
+ :skins => '/v2/skins',
43
+ :worlds => '/v2/worlds'
44
+ }
45
+
46
+ end
47
+ end
48
+
49
+
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gw2_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Turner
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday_middleware
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.8'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.8'
83
+ description:
84
+ email:
85
+ - sunspar@sunspar.net
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - gw2_ruby.gemspec
98
+ - lib/gw2/api/account.rb
99
+ - lib/gw2/api/build.rb
100
+ - lib/gw2/api/character.rb
101
+ - lib/gw2/api/color.rb
102
+ - lib/gw2/api/commerce.rb
103
+ - lib/gw2/api/continent.rb
104
+ - lib/gw2/api/file.rb
105
+ - lib/gw2/api/floor.rb
106
+ - lib/gw2/api/item.rb
107
+ - lib/gw2/api/map.rb
108
+ - lib/gw2/api/material.rb
109
+ - lib/gw2/api/quaggan.rb
110
+ - lib/gw2/api/recipe.rb
111
+ - lib/gw2/api/skin.rb
112
+ - lib/gw2/api/token_info.rb
113
+ - lib/gw2/api/world.rb
114
+ - lib/gw2/version.rb
115
+ - lib/gw2_ruby.rb
116
+ homepage: http://www.sunspar.net
117
+ licenses:
118
+ - MIT
119
+ metadata: {}
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.4.5
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Ruby wrapper for the Guild Wars 2 REST API.
140
+ test_files: []