ig3client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ig3client.rb +19 -8
- data/lib/lib/errors.rb +6 -0
- metadata +5 -2
data/lib/ig3client.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
require '
|
2
|
-
require 'lib/errors.rb'
|
1
|
+
require 'etc'
|
3
2
|
require 'net/http'
|
4
3
|
require 'yaml'
|
5
4
|
require 'timeout'
|
6
5
|
require 'rubygems'
|
7
6
|
require 'facets'
|
7
|
+
require 'lib/util.rb'
|
8
|
+
require 'lib/errors.rb'
|
8
9
|
|
9
10
|
# External Options:
|
10
11
|
#
|
@@ -40,7 +41,7 @@ module Ig3tool
|
|
40
41
|
|
41
42
|
class Client
|
42
43
|
|
43
|
-
attr_accessor :token
|
44
|
+
attr_accessor :token, :username
|
44
45
|
|
45
46
|
def initialize(host="infogroep.be", port="2007", timeout=0)
|
46
47
|
@host = host
|
@@ -52,6 +53,12 @@ module Ig3tool
|
|
52
53
|
rescue Exception => e
|
53
54
|
@token = nil
|
54
55
|
end
|
56
|
+
|
57
|
+
begin
|
58
|
+
@username = File.read(File.expand_path("~/.ig3user")).strip
|
59
|
+
rescue Exception => e
|
60
|
+
@username = Etc.getpwuid(Process::Sys.geteuid).name
|
61
|
+
end
|
55
62
|
end
|
56
63
|
|
57
64
|
def valid_token?
|
@@ -70,14 +77,19 @@ module Ig3tool
|
|
70
77
|
|
71
78
|
def wannabe!(h)
|
72
79
|
username = h["username"]
|
73
|
-
passwd
|
80
|
+
passwd = h["password"]
|
74
81
|
# request token
|
75
82
|
# if ok => store in file
|
76
83
|
# else => throw exception
|
77
84
|
@token = method_missing("wannabe!", {"username" => username,"password" => passwd})
|
78
|
-
|
79
|
-
|
80
|
-
|
85
|
+
|
86
|
+
File.open(File.expand_path("~/.ig3token"), "wb") do |f|
|
87
|
+
f.write @token
|
88
|
+
end
|
89
|
+
|
90
|
+
File.open(File.expand_path("~/.ig3user"), "wb") do |f|
|
91
|
+
f.write @username
|
92
|
+
end
|
81
93
|
#rescue Token => t
|
82
94
|
# raise PermissionDenied
|
83
95
|
end
|
@@ -86,7 +98,6 @@ module Ig3tool
|
|
86
98
|
def method_missing(msg, *args, &block)
|
87
99
|
msg = msg.to_s
|
88
100
|
|
89
|
-
|
90
101
|
if match = /^async_(.*)/.match(msg)
|
91
102
|
raise "Async method called, no block given!" unless block_given?
|
92
103
|
Thread.new do
|
data/lib/lib/errors.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ig3client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Pinte
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -31,6 +31,7 @@ extra_rdoc_files: []
|
|
31
31
|
|
32
32
|
files:
|
33
33
|
- lib/ig3client.rb
|
34
|
+
- lib/lib
|
34
35
|
- lib/lib/errors.rb
|
35
36
|
- lib/lib/util.rb
|
36
37
|
has_rdoc: false
|
@@ -40,6 +41,8 @@ rdoc_options: []
|
|
40
41
|
|
41
42
|
require_paths:
|
42
43
|
- lib
|
44
|
+
- lib
|
45
|
+
- lib/ui
|
43
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
44
47
|
requirements:
|
45
48
|
- - ">="
|