kagerator 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDRmMDI2OWE2YTQ5MjNmZDYxNGViN2JiM2NlMDU5OWU5MzA5NjEzYg==
5
+ data.tar.gz: !binary |-
6
+ NDk2MGE2MDZhMWQwMzhkZWI1YjYxZTg3YmRjZmE2ZjVmOTliNzMwZQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjJiYmNjY2I3ZGQ4YTk1Mjg3MDhiYTg3YWVhN2U1ZTg2MDMyNDY2YTA0N2Yz
10
+ OTcyOTYzOGEzOWZiN2M0OGE2MmIyNDExZjU5Y2U5Njk5OTY5M2VmMDk0YWYz
11
+ ZTc4ZjA1OTQ2Y2NmMzJjNDcyN2I2MTk2ZTM5ZTI5MDQxMjRhMzY=
12
+ data.tar.gz: !binary |-
13
+ NzRlNGRiMDhkZjczYTZiMzFjOGRlNmM3MTNkYTQzOTBhNDkxM2Y4ODlmY2E4
14
+ MzM4NmJkNjY2YTllM2M0Njg1OWYxMjQ2YmNjMWMzMWQ1NjY3MzljZTUzYWUx
15
+ ZGExMDVkODcyMTZjOTA3ZDdhYWNlMjRmOGVjMTQwYTJmYTkzOWQ=
@@ -1,3 +1,4 @@
1
+ require 'base64'
1
2
  require File.dirname(__FILE__) + '/kagerator/request'
2
3
  ##
3
4
  # The main Kagerator class for consumption
@@ -66,4 +67,46 @@ module Kagerator
66
67
  })
67
68
  server.from_json
68
69
  end
70
+
71
+ ##
72
+ # Attempt to authenticate to the server using your KAG account username/password
73
+ #
74
+ # @param [String] username
75
+ # @param [String] password
76
+ # @return [Boolean] True if authenticated, false if failed
77
+ #
78
+ def self.authenticate(username,password)
79
+ begin
80
+ resp = Kagerator::Request.execute({
81
+ :url => "player/#{username}/token/new",
82
+ :method => :get,
83
+ :headers => {
84
+ :Authorization => "Basic "+Base64.encode64("#{username}:#{password}")
85
+ }
86
+ })
87
+ if resp
88
+ token = resp.from_json
89
+ token = token[:playerToken]
90
+ resp = Kagerator::Request.execute({
91
+ :url => "player/#{username}/token/#{token}",
92
+ :method => :get,
93
+ :headers => {
94
+ :Authorization => "Basic "+Base64.encode64("#{username}:#{password}")
95
+ }
96
+ })
97
+ if resp
98
+ resp = resp.from_json
99
+ if resp[:playerTokenStatus]
100
+ true
101
+ end
102
+ else
103
+ false
104
+ end
105
+ else
106
+ false
107
+ end
108
+ rescue
109
+ false
110
+ end
111
+ end
69
112
  end
@@ -22,7 +22,7 @@ module Kagerator
22
22
  end
23
23
 
24
24
  def execute &block
25
- response = ::RestClient.send(@method,API_URL+@url)
25
+ response = ::RestClient.send(@method,API_URL+@url,@headers)
26
26
  if block_given?
27
27
  block.call(response, self, & block)
28
28
  end
@@ -1,4 +1,4 @@
1
1
  module Kagerator
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  def self.version; VERSION; end
4
4
  end
metadata CHANGED
@@ -1,113 +1,101 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kagerator
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.0.3
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Shaun McCormick
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
11
+ date: 2013-03-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rest-client
16
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - '='
19
18
  - !ruby/object:Gem::Version
20
19
  version: 1.6.7
21
- none: false
22
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.7
27
- none: false
28
- prerelease: false
29
- type: :runtime
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: json
32
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - '='
35
32
  - !ruby/object:Gem::Version
36
33
  version: 1.7.6
37
- none: false
38
- requirement: !ruby/object:Gem::Requirement
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
39
37
  requirements:
40
38
  - - '='
41
39
  - !ruby/object:Gem::Version
42
40
  version: 1.7.6
43
- none: false
44
- prerelease: false
45
- type: :runtime
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: symboltable
48
- version_requirements: !ruby/object:Gem::Requirement
43
+ requirement: !ruby/object:Gem::Requirement
49
44
  requirements:
50
45
  - - '='
51
46
  - !ruby/object:Gem::Version
52
47
  version: 1.0.2
53
- none: false
54
- requirement: !ruby/object:Gem::Requirement
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
55
51
  requirements:
56
52
  - - '='
57
53
  - !ruby/object:Gem::Version
58
54
  version: 1.0.2
59
- none: false
60
- prerelease: false
61
- type: :runtime
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- none: false
70
57
  requirement: !ruby/object:Gem::Requirement
71
58
  requirements:
72
59
  - - ! '>='
73
60
  - !ruby/object:Gem::Version
74
61
  version: '0'
75
- none: false
76
- prerelease: false
77
62
  type: :development
78
- - !ruby/object:Gem::Dependency
79
- name: rspec
63
+ prerelease: false
80
64
  version_requirements: !ruby/object:Gem::Requirement
81
65
  requirements:
82
66
  - - ! '>='
83
67
  - !ruby/object:Gem::Version
84
68
  version: '0'
85
- none: false
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
86
71
  requirement: !ruby/object:Gem::Requirement
87
72
  requirements:
88
73
  - - ! '>='
89
74
  - !ruby/object:Gem::Version
90
75
  version: '0'
91
- none: false
92
- prerelease: false
93
76
  type: :development
94
- - !ruby/object:Gem::Dependency
95
- name: guard-rspec
77
+ prerelease: false
96
78
  version_requirements: !ruby/object:Gem::Requirement
97
79
  requirements:
98
80
  - - ! '>='
99
81
  - !ruby/object:Gem::Version
100
82
  version: '0'
101
- none: false
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
102
85
  requirement: !ruby/object:Gem::Requirement
103
86
  requirements:
104
87
  - - ! '>='
105
88
  - !ruby/object:Gem::Version
106
89
  version: '0'
107
- none: false
108
- prerelease: false
109
90
  type: :development
110
- description: Easy, quick consumption and reading of the King Arthur's Gold Public API
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Easy, quick consumption and reading of the King Arthur's Gold Public
98
+ API
111
99
  email:
112
100
  - splittingred@gmail.com
113
101
  executables: []
@@ -115,14 +103,15 @@ extensions: []
115
103
  extra_rdoc_files: []
116
104
  files:
117
105
  - README.md
118
- - lib/kagerator.rb
119
106
  - lib/kagerator/request.rb
120
107
  - lib/kagerator/response.rb
121
108
  - lib/kagerator/version.rb
109
+ - lib/kagerator.rb
122
110
  homepage: https://github.com/splittingred/kagerator
123
111
  licenses:
124
112
  - GPLv2
125
- post_install_message:
113
+ metadata: {}
114
+ post_install_message:
126
115
  rdoc_options: []
127
116
  require_paths:
128
117
  - lib
@@ -131,19 +120,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
120
  - - ! '>='
132
121
  - !ruby/object:Gem::Version
133
122
  version: 1.9.2
134
- none: false
135
123
  required_rubygems_version: !ruby/object:Gem::Requirement
136
124
  requirements:
137
125
  - - ! '>='
138
126
  - !ruby/object:Gem::Version
139
127
  version: 1.3.6
140
- none: false
141
128
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 1.8.25
144
- signing_key:
145
- specification_version: 3
129
+ rubyforge_project:
130
+ rubygems_version: 2.0.3
131
+ signing_key:
132
+ specification_version: 4
146
133
  summary: Easy consumption of the KAG API
147
134
  test_files: []
148
- has_rdoc:
149
- ...