lacuna 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lacuna.rb +29 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af46cbe3601f8f84bc8c08ad470e15909b918c4b
|
4
|
+
data.tar.gz: 1b8ccfe2dd303a96235dbe014cf9d6822a047649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eccfd26de7a5eb756957d74a13851303cd872264fe4f50a84ebaa9d1ccc1bd260a1c1ae2deef894d53ca64d6745e7c4b029482631a17c048380b64f649b6b37f
|
7
|
+
data.tar.gz: 3e1d1e3a2fcd71b174470234369f3b24ac91772b9f1083adf9156b90b3911616660b0a2965e9ab905d7f5ea0aa5f21738e5a2eb225841a4b879264e1feacd128
|
data/lib/lacuna.rb
CHANGED
@@ -5,12 +5,35 @@ require 'net/http'
|
|
5
5
|
require 'openssl'
|
6
6
|
require 'json'
|
7
7
|
|
8
|
+
class Session
|
9
|
+
@@session = nil
|
10
|
+
|
11
|
+
def self.set(val)
|
12
|
+
@@session = val
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.end
|
16
|
+
self.set nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get
|
20
|
+
@@session
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.valid?
|
24
|
+
# TODO: take into account the two hour session timeout.
|
25
|
+
!@@session.nil?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
8
29
|
class Lacuna
|
9
|
-
VERSION = '0.0.
|
30
|
+
VERSION = '0.0.2'
|
10
31
|
|
11
32
|
API_KEYS = {
|
12
33
|
# Private key : 66090c68-2d51-47fa-b406-44dc98e6f6d3
|
13
34
|
'us1' => 'bbd9b648-6e45-419d-bdaf-5726919c4a64',
|
35
|
+
# Private key : 3a9c5121-0939-4ef9-82c2-7c1aa4f7d1bc
|
36
|
+
'pt' => '3746d4a2-0f44-44db-9308-22a85c234aab',
|
14
37
|
}
|
15
38
|
|
16
39
|
LACUNA_DOMAIN = 'lacunaexpanse.com'
|
@@ -69,8 +92,10 @@ class LacunaModule
|
|
69
92
|
:method => post_method,
|
70
93
|
:params => data
|
71
94
|
}
|
95
|
+
|
96
|
+
# Include session id in requests that need it
|
72
97
|
if "#{post_module}/#{post_method}" != 'empire/login'
|
73
|
-
body[:params].unshift
|
98
|
+
body[:params].unshift Session.get
|
74
99
|
end
|
75
100
|
|
76
101
|
request.body = JSON.generate body
|
@@ -88,13 +113,13 @@ class LacunaModule
|
|
88
113
|
|
89
114
|
# Check that we're logged in, if not, get session a set up.
|
90
115
|
def session_stuff
|
91
|
-
if
|
116
|
+
if !Session.valid?
|
92
117
|
res = self.send(@base_url, 'empire', 'login', [
|
93
118
|
@args[:name],
|
94
119
|
@args[:password],
|
95
120
|
@args[:api_key],
|
96
121
|
])
|
97
|
-
|
122
|
+
Session.set res['session_id']
|
98
123
|
else
|
99
124
|
# check time
|
100
125
|
return
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lacuna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan McCallum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2010-05-
|
11
|
+
date: 2010-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Lacuna is a Ruby library for using the API of The Lacuna Expanse.
|
14
14
|
email: nmccallum7@gmail.com
|