lacuna 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lacuna.rb +29 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e03e847bc99ee187e2123d35c96c6c5250667522
4
- data.tar.gz: 7fbd7e23672ff56eb2a82e8604479303be7f7bdb
3
+ metadata.gz: af46cbe3601f8f84bc8c08ad470e15909b918c4b
4
+ data.tar.gz: 1b8ccfe2dd303a96235dbe014cf9d6822a047649
5
5
  SHA512:
6
- metadata.gz: ea0d01b6e175948009a737a1eed5953f73395c898bdfe39332b0c73b5d0cd518184f9d493b3d520f554d960bc309be21aaac16af2107f14e725d0edf8aabf790
7
- data.tar.gz: 3f8c2ad1e55cd59fe37ab9dd85c9770a1434ed1c3667c2f2a91c8c3faa31c1c43503a1aada5dc311cd6298d7c3f76afe51293411be1a7334a88c7bfc243980ca
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.1'
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 @session_id
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 !@session_id
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
- @session_id = res['session_id']
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.1
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-25 00:00:00.000000000 Z
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