uniara_virtual_parser 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.
- checksums.yaml +4 -4
- data/lib/uniara_virtual_parser/client.rb +1 -2
- data/lib/uniara_virtual_parser/services/grades.rb +2 -2
- data/lib/uniara_virtual_parser/services/login.rb +1 -1
- data/lib/uniara_virtual_parser/version.rb +1 -1
- data/spec/uniara_virtual_parser/services/grades_spec.rb +1 -1
- data/spec/uniara_virtual_parser/services/login_spec.rb +2 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b61ea827910906965e309da6334f7ed073fa88f7
|
|
4
|
+
data.tar.gz: 0609cde591bbb78981843a6675a37f8b9b879a55
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04d3109b575cd643c9f8747e1b80f7923ecda00a7fdf8fb40c0cebaceb3d0440a3b778ce6732969c33400e08229f52630f6f28c8320b00bd10c0028dfca42e0f
|
|
7
|
+
data.tar.gz: 101b000a8d99b80a8bd9dd9f77c75f96de01507dceaa1f3f86907307f726bf5b9f7efae4f85af9eb2053bb03b0570a266aed2af749449951c67317f60b01153e
|
|
@@ -8,9 +8,8 @@ module UniaraVirtualParser
|
|
|
8
8
|
class << self
|
|
9
9
|
extend Forwardable
|
|
10
10
|
def_delegators :client, :post
|
|
11
|
-
attr_accessor :token
|
|
12
11
|
|
|
13
|
-
def get_with_token(path)
|
|
12
|
+
def get_with_token(path, token)
|
|
14
13
|
client.get(path) do |request|
|
|
15
14
|
request.header[:cookie] = "PHPSESSID=#{token};"
|
|
16
15
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module UniaraVirtualParser
|
|
2
2
|
module Services
|
|
3
3
|
module Grades
|
|
4
|
-
def grades
|
|
5
|
-
response = Client.get_with_token('/alunos/consultas/notas/')
|
|
4
|
+
def grades(token)
|
|
5
|
+
response = Client.get_with_token('/alunos/consultas/notas/', token)
|
|
6
6
|
parse_grades response.body
|
|
7
7
|
end
|
|
8
8
|
|
|
@@ -5,7 +5,7 @@ module UniaraVirtualParser
|
|
|
5
5
|
response = Client.post('/login', username: ra, senha: password)
|
|
6
6
|
cookies = response.header['Set-Cookie']
|
|
7
7
|
fail InvalidLogin unless /UVXS233E3=S/.match cookies
|
|
8
|
-
|
|
8
|
+
cookies.match(/PHPSESSID=([^;]*);/)[1]
|
|
9
9
|
end
|
|
10
10
|
end
|
|
11
11
|
end
|
|
@@ -7,7 +7,7 @@ module UniaraVirtualParser
|
|
|
7
7
|
it 'fetch the content of uniara virtual and bring the array with grades' do
|
|
8
8
|
stub_request(:get, "http://virtual.uniara.com.br/alunos/consultas/notas/").
|
|
9
9
|
to_return(:status => 200, body: uniara_virtual_fixture("grades.html").read, headers: {})
|
|
10
|
-
grades = described_class.grades
|
|
10
|
+
grades = described_class.grades 'batman'
|
|
11
11
|
expect(grades.first.name).to eq "ADMINISTRAÇÃO E ECONOMIA"
|
|
12
12
|
expect(grades.length).to eq 14
|
|
13
13
|
end
|
|
@@ -18,13 +18,12 @@ module UniaraVirtualParser
|
|
|
18
18
|
}
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
it '
|
|
21
|
+
it 'returns the token in the Client' do
|
|
22
22
|
stub_request(:post, 'http://virtual.uniara.com.br/login')
|
|
23
23
|
.with(body: body)
|
|
24
24
|
.to_return(status: 200, body: '', headers: response_headers)
|
|
25
25
|
|
|
26
|
-
expect
|
|
27
|
-
.to change(Client, :token)
|
|
26
|
+
expect(described_class.login 'bruce', 'wayne').to be
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
|