eveapi 0.0.1.pre

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: 1248f371a209e6329df0461a1fc00eeb63e4fb61
4
+ data.tar.gz: 237193ef01bf0729f3fa9d1083fa6891d262c19f
5
+ SHA512:
6
+ metadata.gz: 4793f738569932608b0d2f7eba85089017ceb0ff92ee79f3310d6f41a57cabe9194539c07c4408e43fb3ae606102e96857246534bcba0ad421d1b26fbf3a3326
7
+ data.tar.gz: beb087f551fd42284e9482559a71c9dbe986b014c9c0b10bf9e4e0f5145c3d2a7a7b5fb063d286ed6a5edabc919de2fb872f4e34c5946d4575fc823a881b2a12
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ README.md
3
+ ChangeLog.md
4
+
5
+ LICENSE.txt
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ /.bundle
2
+ /Gemfile.lock
3
+ /html/
4
+ /pkg/
5
+ /vendor/cache/*.gem
6
+ /coverage
data/.rdoc_options ADDED
@@ -0,0 +1,16 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - .
6
+ charset: UTF-8
7
+ exclude:
8
+ hyperlink_all: false
9
+ line_numbers: false
10
+ main_page: README.md
11
+ markup: markdown
12
+ show_hash: false
13
+ tab_width: 8
14
+ title: eveapi Documentation
15
+ visibility: :protected
16
+ webcvs:
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 1.9
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ deploy:
9
+ provider: rubygems
10
+ api_key: <%= ENV['RUBYGEMS_API_KEY'] %>
data/ChangeLog.md ADDED
@@ -0,0 +1,4 @@
1
+ ### 0.0.1 / 2015-09-07
2
+
3
+ * Initial release:
4
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Adam Ladachowski
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # eveapi
2
+
3
+ * [Homepage](https://rubygems.org/gems/eveapi)
4
+ * [Documentation](http://rubydoc.info/gems/eveapi/frames)
5
+ * [Email](mailto:adam at saiden.pl)
6
+
7
+ [![Build Status](https://secure.travis-ci.org/aladac/eveapi.svg?branch=master)](https://travis-ci.org/aladac/eveapi)
8
+ [![Code Climate](https://codeclimate.com/github/aladac/eveapi/badges/gpa.svg)](https://codeclimate.com/github/aladac/eveapi)
9
+ [![Test Coverage](https://codeclimate.com/github/aladac/eveapi/badges/coverage.svg)](https://codeclimate.com/github/aladac/eveapi/coverage)
10
+
11
+ ## Description
12
+
13
+ TODO: Description
14
+
15
+ ## Features
16
+
17
+ ## Examples
18
+
19
+ require 'eveapi'
20
+
21
+ ## Requirements
22
+
23
+ ## Install
24
+
25
+ $ gem install eveapi
26
+
27
+ ## Copyright
28
+
29
+ Copyright (c) 2015 Adam Ladachowski
30
+
31
+ See LICENSE.txt for details.
32
+
33
+ foobar
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler/setup'
7
+ rescue LoadError => e
8
+ abort e.message
9
+ end
10
+
11
+ require 'rake'
12
+
13
+ require 'bundler/gem_tasks'
14
+
15
+ require 'rdoc/task'
16
+ RDoc::Task.new
17
+ task :doc => :rdoc
18
+
19
+ require 'rspec/core/rake_task'
20
+ RSpec::Core::RakeTask.new
21
+
22
+ task :test => :spec
23
+ task :default => :spec
data/eveapi.gemspec ADDED
@@ -0,0 +1,60 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'eveapi/version'
14
+ EVEApi::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+
24
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
25
+
26
+ gem.files = `git ls-files`.split($/)
27
+ gem.files = glob[gemspec['files']] if gemspec['files']
28
+
29
+ gem.executables = gemspec.fetch('executables') do
30
+ glob['bin/*'].map { |path| File.basename(path) }
31
+ end
32
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
33
+
34
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
35
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
36
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
37
+
38
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
39
+ %w[ext lib].select { |dir| File.directory?(dir) }
40
+ })
41
+
42
+ gem.requirements = Array(gemspec['requirements'])
43
+ gem.required_ruby_version = gemspec['required_ruby_version']
44
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
45
+ gem.post_install_message = gemspec['post_install_message']
46
+
47
+ split = lambda { |string| string.split(/,\s*/) }
48
+
49
+ if gemspec['dependencies']
50
+ gemspec['dependencies'].each do |name,versions|
51
+ gem.add_dependency(name,split[versions])
52
+ end
53
+ end
54
+
55
+ if gemspec['development_dependencies']
56
+ gemspec['development_dependencies'].each do |name,versions|
57
+ gem.add_development_dependency(name,split[versions])
58
+ end
59
+ end
60
+ end
data/gemspec.yml ADDED
@@ -0,0 +1,20 @@
1
+ name: eveapi
2
+ summary: "EVEOnline API Client"
3
+ description: "ruby API Client for the space based MMO EVEOnline"
4
+ license: MIT
5
+ authors: Adam Ladachowski
6
+ email: adam@saiden.pl
7
+ homepage: https://rubygems.org/gems/eveapi
8
+
9
+ required_ruby_version: '>= 1.9'
10
+
11
+ dependencies:
12
+ excon: ~> 0.45
13
+ crack: ~> 0.4
14
+
15
+ development_dependencies:
16
+ bundler: ~> 1
17
+ codeclimate-test-reporter: ~> 0.1
18
+ rake: ~> 10.0
19
+ rdoc: ~> 4.0
20
+ rspec: ~> 3.0
data/lib/eveapi.rb ADDED
@@ -0,0 +1,21 @@
1
+ lib_dir = File.dirname(__FILE__)
2
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
3
+
4
+ require 'eveapi/version'
5
+ require 'eveapi/client'
6
+ require 'eveapi/request'
7
+ require 'excon'
8
+ require 'crack'
9
+
10
+ class String
11
+ def camelize
12
+ self.split("_").each {|s| s.capitalize! }.join("")
13
+ end
14
+ def underscore
15
+ self.scan(/[A-Z][a-z]*/).join("_").downcase
16
+ end
17
+ end
18
+
19
+ module EVEApi
20
+ API_ENDPOINT = 'https://api.eveonline.com'
21
+ end
@@ -0,0 +1,37 @@
1
+ module EVEApi
2
+ class Client
3
+ attr_accessor :connection
4
+ attr_accessor :key_id
5
+ attr_accessor :vcode
6
+ attr_accessor :character_id
7
+ attr_accessor :row_count
8
+
9
+ def initialize(key_id=nil, vcode=nil, character_id=nil)
10
+ @connection ||= Excon.new(API_ENDPOINT)
11
+ @key_id = key_id
12
+ @character_id = character_id
13
+ @vcode = vcode
14
+ end
15
+
16
+ def check_path(name)
17
+ parts = name.to_s.split('_')
18
+ return '' if parts.count < 2
19
+ "/#{parts[0]}/#{parts[1..-1].join('_').camelize}.xml.aspx"
20
+ end
21
+
22
+ def params
23
+ { 'rowCount' => row_count, 'keyID' => key_id, 'vCode' => vcode, 'characterID' => character_id }.select { |k,v| v }
24
+ end
25
+
26
+ def api_methods
27
+ api_call_list[:methods].map { |m| m['type'][0..3].downcase + '_' + m['name'].underscore }
28
+ end
29
+
30
+ def method_missing(name, *args, &block)
31
+ raise 'Invalid Method Name' if check_path(name).empty?
32
+ check_path(name)
33
+ request = EVEApi::Request.new @connection.get(path: check_path(name), query: params)
34
+ request.result
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ module EVEApi
2
+ class Request
3
+ attr_accessor :data
4
+ attr_accessor :result
5
+ attr_accessor :response
6
+
7
+ def initialize(response=nil)
8
+ @response = response
9
+ raise 'No such method' if response.status == 404
10
+ @data = parse_xml
11
+ @result = self.parse_result
12
+ raise error if error
13
+ end
14
+
15
+ def error
16
+ data['eveapi'].has_key?('error') ? data['eveapi']['error'] : false
17
+ end
18
+
19
+ def parse_xml
20
+ Crack::XML.parse(response.body)
21
+ end
22
+
23
+ def parse_result
24
+ begin
25
+ data['eveapi']['result']['rowset']['row']
26
+ rescue NoMethodError
27
+ data['eveapi']['result']
28
+ rescue TypeError
29
+ {
30
+ groups: data['eveapi']['result']['rowset'].first['row'],
31
+ methods: data['eveapi']['result']['rowset'].last['row']
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,4 @@
1
+ module EVEApi
2
+ # eveapi version
3
+ VERSION = "0.0.1.pre"
4
+ end
@@ -0,0 +1,46 @@
1
+ require 'spec_helper'
2
+ require 'eveapi'
3
+
4
+ describe EVEApi do
5
+ context 'whithout auth' do
6
+ it "there should be a connection class" do
7
+ expect { EVEApi::Client.new }.not_to raise_error
8
+ end
9
+
10
+ it "connection instance variable should be of class Excon::Connection" do
11
+ expect(EVEApi::Client.new.connection).to be_a(Excon::Connection)
12
+ end
13
+
14
+ it "check_path method should return an empty string when name contains of 1 part" do
15
+ expect(EVEApi::Client.new.check_path('name')).to eq('')
16
+ end
17
+
18
+ it "check_path method should return a path string when name contains of 2 or more parts" do
19
+ expect(EVEApi::Client.new.check_path('name_name')).to be_a(String)
20
+ expect(EVEApi::Client.new.check_path('name_name')).not_to be_empty
21
+ end
22
+
23
+ it "params should return an empty hash when no param variables present" do
24
+ expect(EVEApi::Client.new.params).to be_a(Hash)
25
+ expect(EVEApi::Client.new.params).to be_empty
26
+ end
27
+
28
+ it "calling a method present in the EVEApi should success" do
29
+ expect { EVEApi::Client.new.server_server_status }.not_to raise_error
30
+ end
31
+
32
+ it "calling a method not present in the EVEApi should fail" do
33
+ expect { EVEApi::Client.new.some_bs_method }.to raise_error(RuntimeError)
34
+ end
35
+
36
+ it "calling api_methods should return an Array of method symobls" do
37
+ expect(EVEApi::Client.new.api_methods).to be_an(Array)
38
+ end
39
+ end
40
+ end
41
+
42
+ describe EVEApi::Request do
43
+ it 'there should be a EVEApi::Response class' do
44
+ expect { EVEApi::Request }.not_to raise_error
45
+ end
46
+ end
@@ -0,0 +1,10 @@
1
+ unless ENV['CODECLIMATE_REPO_TOKEN']
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+ require "codeclimate-test-reporter"
6
+ CodeClimate::TestReporter.start
7
+ require 'rspec'
8
+ require 'eveapi/version'
9
+
10
+ include EVEApi
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eveapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Adam Ladachowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: excon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.45'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.45'
27
+ - !ruby/object:Gem::Dependency
28
+ name: crack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.4'
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'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rdoc
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.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'
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'
111
+ description: ruby API Client for the space based MMO EVEOnline
112
+ email: adam@saiden.pl
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files:
116
+ - ChangeLog.md
117
+ - LICENSE.txt
118
+ - README.md
119
+ files:
120
+ - ".document"
121
+ - ".gitignore"
122
+ - ".rdoc_options"
123
+ - ".rspec"
124
+ - ".travis.yml"
125
+ - ChangeLog.md
126
+ - Gemfile
127
+ - LICENSE.txt
128
+ - README.md
129
+ - Rakefile
130
+ - eveapi.gemspec
131
+ - gemspec.yml
132
+ - lib/eveapi.rb
133
+ - lib/eveapi/client.rb
134
+ - lib/eveapi/request.rb
135
+ - lib/eveapi/version.rb
136
+ - spec/eveapi_spec.rb
137
+ - spec/spec_helper.rb
138
+ homepage: https://rubygems.org/gems/eveapi
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '1.9'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.4.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: EVEOnline API Client
162
+ test_files: []