uni 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +10 -0
- data/README.md +1 -0
- data/lib/uni/params.rb +6 -0
- data/lib/uni/private_info.rb +6 -4
- data/lib/uni/public_info.rb +12 -0
- data/lib/uni/version.rb +1 -1
- data/spec/lib/uni_spec.rb +16 -9
- data/spec/spec_helper.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2IwMjg3NTE2YTM5Y2Y3NzllYWE1NWY1NjYxYWY4ZjI1NDk0OThlNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDg5YTdlYThkNWEzNmI4ODVjN2Q1MjYzYzAzNTA0MDhkMzYzYWRkZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmRkZmJlYTgwYzAyZTg1YTM4OTUzNDEwY2YyMjY3YTc1NGE4ZTIwNWY5ZmVj
|
10
|
+
ZTg4ZTM4M2M3NGJjNzVhZDliYTM2ZjRjNWYzZDVlNzVlNjEzNTMzNDNjZjRl
|
11
|
+
YTJkNGVkYmM5ZTFhMjhlNzk1ZGM4MWUzZDZiMTk2MmJhNDA5YjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTdkNDIyMjIwYjQyNWI5ZDUyYTE1N2M4NzY5ZDI4NzBhNDJlMzY4ZGZjYmYy
|
14
|
+
NjIzZDNlMGQ3N2E3MWQ5ZjM1Yzg3ZWE0MTJkNmI1ZjQwNzcyMjg4MDBlZWEy
|
15
|
+
YmFhNTRhZjk4YmEzMmY5Y2ZmOWUxZjQ0NTA0NTMxZmFmNjJiNjY=
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/uni.png)](http://badge.fury.io/rb/uni) [![Build Status](https://travis-ci.org/cxrlospxndo/uni.png?branch=master)](https://travis-ci.org/cxrlospxndo/uni)
|
1
2
|
## Uni
|
2
3
|
Simple interface de la [Orce](http://www.orce.uni.edu.pe/).
|
3
4
|
Permite visualizar informacion publica, validar codigo, obtener la letra del mismo y consultar notas del ultimo ciclo
|
data/lib/uni/params.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
module Uni
|
2
3
|
URL = 'http://www.orce.uni.edu.pe/'
|
3
4
|
SITUACION = [ 'SUSPENSION VOLUNTARIA', 'ALUMNO REGULAR', 'INACTIVO', 'EN REGULARIZACION DE CURSO(S)',
|
4
5
|
'EXPULSADO', 'INACTIVO', 'RETIRADO ', 'FALLECIDO', 'SUSPENSION ', 'PROYECTO ESPECIAL ALUMNOS UNI',
|
5
6
|
'TITULADO', 'BACHILLER', 'EGRESADO']
|
7
|
+
FACULTADES = {'INGENIERÍA INDUSTRIAL Y DE SISTEMAS' => 'I', 'ARQUITECTURA, URBANISMO Y ARTES' => 'A', 'CIENCIAS' => 'N',
|
8
|
+
'INGENIERÍA AMBIENTAL' => 'S', 'INGENIERÍA CIVIL' => 'C', 'INGENIERÍA ECONÓMICA Y CIENCIAS SOCIALES' => 'E',
|
9
|
+
'INGENIERÍA ELÉCTRICA Y ELECTRÓNICA' => 'L', 'INGENIERÍA GEOLÓGICA, MINERA Y METALÚRGICA' => 'G',
|
10
|
+
'INGENIERÍA MECÁNICA' => 'M', 'INGENIERÍA DE PETRÓLEO, GAS NATURAL Y PETROQUÍMICA' => 'P',
|
11
|
+
'INGENIERÍA QUÍMICA Y TEXTIL' => 'Q'}
|
6
12
|
end
|
data/lib/uni/private_info.rb
CHANGED
@@ -20,6 +20,8 @@ module Uni
|
|
20
20
|
pag.parser.css('tr.fila td').each do |f|
|
21
21
|
a << f.text
|
22
22
|
end
|
23
|
+
school = Uni.get_facultad codigo
|
24
|
+
id = Uni::FACULTADES[school]
|
23
25
|
|
24
26
|
n = a.size/5
|
25
27
|
|
@@ -31,8 +33,8 @@ module Uni
|
|
31
33
|
ans[:curso] = curso[1]
|
32
34
|
ans[:seccion] = curso[2]
|
33
35
|
|
34
|
-
practicas = obtener_notas_de 'Practicas', ans[:codigo], ans[:seccion], agent
|
35
|
-
examenes = obtener_notas_de 'Teoria', ans[:codigo], ans[:seccion], agent
|
36
|
+
practicas = obtener_notas_de 'Practicas', ans[:codigo], ans[:seccion], id, agent
|
37
|
+
examenes = obtener_notas_de 'Teoria', ans[:codigo], ans[:seccion], id, agent
|
36
38
|
|
37
39
|
ans[:notas] = { practicas: practicas, examenes: examenes}
|
38
40
|
cursos << ans
|
@@ -42,8 +44,8 @@ module Uni
|
|
42
44
|
# Obtiene las notas de un curso por tipo de evaluacion (practicas, teoria)
|
43
45
|
# @return [Array] Nota del curso
|
44
46
|
|
45
|
-
def self.obtener_notas_de evaluacion, codigo, seccion, agent
|
46
|
-
agent.get Uni::URL+"recordNotas.php?op=notas&tipo=#{evaluacion}&codcur=#{codigo}&facul
|
47
|
+
def self.obtener_notas_de evaluacion, codigo, seccion, id, agent
|
48
|
+
agent.get Uni::URL+"recordNotas.php?op=notas&tipo=#{evaluacion}&codcur=#{codigo}&facul=#{id}&codsec=#{seccion}"
|
47
49
|
pag_evaluacion = agent.page
|
48
50
|
|
49
51
|
evaluacion=[]
|
data/lib/uni/public_info.rb
CHANGED
@@ -51,6 +51,7 @@ module Uni
|
|
51
51
|
# @return [Hash] Informacion publica obtenida de la Orce
|
52
52
|
|
53
53
|
def self.data codigo
|
54
|
+
return Hash.new unless codigo
|
54
55
|
codigo = codigo_uni codigo if codigo.is_a? Fixnum
|
55
56
|
agent = @base
|
56
57
|
cod = codigo.upcase
|
@@ -99,4 +100,15 @@ module Uni
|
|
99
100
|
a[6].split('-').join(' ') == '' ? false:true
|
100
101
|
end
|
101
102
|
# deberia ser codigo.valid?, de momento lo dejamos en Uni.valido? "20072531a"
|
103
|
+
# helpers
|
104
|
+
def self.get_facultad codigo
|
105
|
+
return '' unless codigo
|
106
|
+
codigo = codigo_uni codigo if codigo.is_a? Fixnum
|
107
|
+
agent = @base
|
108
|
+
cod = codigo.upcase
|
109
|
+
url = Uni::URL + "detaalu.php?id=#{cod}&op=detalu"
|
110
|
+
page = agent.get url
|
111
|
+
f = page.parser.css('tr td')[9]
|
112
|
+
f.text
|
113
|
+
end
|
102
114
|
end
|
data/lib/uni/version.rb
CHANGED
data/spec/lib/uni_spec.rb
CHANGED
@@ -87,6 +87,10 @@ describe 'Uni' do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|
90
|
+
describe '#get_facultad' do
|
91
|
+
specify { Uni.get_facultad('20072531g').should eql 'INGENIERÍA INDUSTRIAL Y DE SISTEMAS' }
|
92
|
+
specify { Uni.get_facultad('20104512B').should eql 'INGENIERÍA AMBIENTAL' }
|
93
|
+
end
|
90
94
|
describe '#data' do
|
91
95
|
let(:regular) { Uni::data '20072531G' }
|
92
96
|
let(:titulado) { Uni::data '19100003B' }
|
@@ -98,6 +102,9 @@ describe 'Uni' do
|
|
98
102
|
it 'returns a Hash' do
|
99
103
|
regular.should be_an_instance_of Hash
|
100
104
|
end
|
105
|
+
it 'returns an empty Hash if codigo is nil' do
|
106
|
+
Uni.data(nil).should eql Hash.new
|
107
|
+
end
|
101
108
|
it 'returns an empty Hash if codigo is invalid' do
|
102
109
|
invalido.should eql Hash.new
|
103
110
|
inv_fixnum.should eql Hash.new
|
@@ -128,19 +135,19 @@ describe 'Uni' do
|
|
128
135
|
xit 'returns an empty Array for invalid codigo and/or password'
|
129
136
|
xit 'works with codigo as Fixnum or String'
|
130
137
|
|
131
|
-
context '
|
138
|
+
context 'items' do
|
132
139
|
xit 'should be an instance of Hash'
|
133
140
|
xit 'should have the keys :curso, :codigo, :seccion, :notas'
|
134
|
-
xit 'should have
|
135
|
-
xit 'should have
|
136
|
-
context ':notas' do
|
137
|
-
xit 'contains :practicas and :examenes'
|
138
|
-
context ':practicas and :examenes' do
|
141
|
+
xit 'should have a String as value for :curso, :codigo and :seccion'
|
142
|
+
xit 'should have a Hash as value for :notas'
|
143
|
+
context 'has key :notas' do
|
144
|
+
xit 'contains keys :practicas and :examenes'
|
145
|
+
context 'its keys :practicas and :examenes' do
|
139
146
|
xit 'contains an instance of Array'
|
140
|
-
xit '
|
147
|
+
xit 'represents an evaluation has fields: type, grade, complaint and a fail rate'
|
141
148
|
end
|
142
149
|
end
|
143
150
|
end
|
144
|
-
|
145
151
|
end
|
146
|
-
end
|
152
|
+
end
|
153
|
+
puts Uni.notas "20072531g", 91424
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Pando Morales
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -89,6 +89,7 @@ extensions: []
|
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
91
|
- .gitignore
|
92
|
+
- .travis.yml
|
92
93
|
- Gemfile
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|