alego 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/alego.rb +28 -17
  2. data/lib/alego/version.rb +1 -1
  3. metadata +2 -2
@@ -4,10 +4,10 @@ require 'uri'
4
4
  require 'rexml/document'
5
5
 
6
6
  module Alego
7
-
7
+
8
8
  def denied
9
9
  end
10
-
10
+
11
11
  def pre_dispatch
12
12
  valida_login
13
13
  valida_tela
@@ -23,19 +23,19 @@ module Alego
23
23
  session[:usuario_id] = nil
24
24
  session[:usuario_corrente] = nil
25
25
  reset_session
26
- end
26
+ end
27
27
 
28
28
 
29
29
  def valida_login
30
30
  begin
31
31
  if session[:usuario_corrente]
32
32
  return true
33
- else
33
+ else
34
34
  flash[:erro] = "Falha no login"
35
35
  logout
36
36
  denied
37
37
  end
38
- rescue
38
+ rescue
39
39
  flash[:erro] = "Falha no login"
40
40
  logout
41
41
  denied
@@ -43,7 +43,7 @@ module Alego
43
43
  end
44
44
 
45
45
 
46
- protected
46
+ protected
47
47
  def valida_tela
48
48
  begin
49
49
  nome = controller_name
@@ -65,19 +65,19 @@ module Alego
65
65
 
66
66
 
67
67
  ####
68
-
68
+
69
69
  def production(is_production = true, url = nil)
70
70
  if (is_production)
71
71
  @@sgu_url = "https://172.16.0.36/sgu/"
72
72
  else
73
73
  @@sgu_url = "https://172.16.0.26/sgu/"
74
74
  end
75
-
75
+
76
76
  @@sgu_url = url if (url != nil)
77
77
  end
78
-
79
-
80
-
78
+
79
+
80
+
81
81
  def post(login, senha, sistema)
82
82
  resp = {}
83
83
  url = @@sgu_url + 'validar/' + login + '/' + senha + '/' + sistema +'.xml'
@@ -93,10 +93,10 @@ module Alego
93
93
 
94
94
  resp[:erro] = "Error: host connection fail"
95
95
  end
96
-
96
+
97
97
  if response != nil and response.code == "200"
98
- xml_data = response.body
99
- doc = REXML::Document.new(xml_data)
98
+ xml_data = response.body
99
+ doc = REXML::Document.new(xml_data)
100
100
  doc.elements.each('hash') do |ele|
101
101
  begin
102
102
  resp[:erro] = ele.elements['erro'].text
@@ -111,14 +111,25 @@ module Alego
111
111
  resp[:recursos] = resp[:recursos] + et.elements['nome-tela'].text+';'
112
112
  end
113
113
  end
114
+
115
+ resp[:lotacoes] = []
116
+ ele.elements.each('lotacoes') do |e|
117
+ e.elements.each('lotacao') do |el|
118
+ resp[:lotacoes] << {
119
+ :nome => el.elements['nome'].text,
120
+ :id => el.elements['id'].text.to_i
121
+ }
122
+ end
123
+ end
124
+
114
125
  resp[:status] = response.code
115
- end
126
+ end
116
127
  end
117
128
  else
118
129
  resp[:erro] = "Error: host connection fail"
119
130
  end
120
131
  resp
121
132
  end
122
-
123
133
 
124
- end
134
+
135
+ end
@@ -1,3 +1,3 @@
1
1
  module Alego
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alego
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Alego SGU Auth...
15
15
  email: