uni 0.0.6 → 0.0.7
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 +8 -8
 - data/.gitignore +1 -0
 - data/README.md +28 -18
 - data/lib/uni.rb +4 -1
 - data/lib/uni/private_info.rb +61 -0
 - data/lib/uni/public_info.rb +1 -3
 - data/lib/uni/version.rb +1 -1
 - data/spec/lib/uni_spec.rb +5 -0
 - metadata +2 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            !binary "U0hBMQ==":
         
     | 
| 
       3 
3 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       4 
     | 
    
         
            -
                 
     | 
| 
      
 4 
     | 
    
         
            +
                ZjcyZGYzMGQwMmUzOGNhYmRlOTg2YWUyZWUyNjMyY2VlNDZiZDRkYQ==
         
     | 
| 
       5 
5 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
      
 6 
     | 
    
         
            +
                MjFjYmI3OWI5ZmE2ZDA4ZjI1NGFiOGE5ZDBkMjBhZmY3MmRjMGMxNQ==
         
     | 
| 
       7 
7 
     | 
    
         
             
            !binary "U0hBNTEy":
         
     | 
| 
       8 
8 
     | 
    
         
             
              metadata.gz: !binary |-
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 9 
     | 
    
         
            +
                N2Q3NTFmZDhmZmZlMDZkNjU1ZmVlODJjOWI5MTNiZTU2MzRjZDhhNDFhMmMw
         
     | 
| 
      
 10 
     | 
    
         
            +
                YWFlNmQ4ZDg2MmZjMjhiODQwZDUwN2UzMmExNjFhODVhMTUzMzg0MmQzODIw
         
     | 
| 
      
 11 
     | 
    
         
            +
                NzJlNTkyMjBhNGU3MTllOTkyZjhkMTk5NzMwNTAwYzk5MTQxMWY=
         
     | 
| 
       12 
12 
     | 
    
         
             
              data.tar.gz: !binary |-
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
       15 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                MDkxZWIyNTkxNWU0ZWRkNTFiYTRiZDlhMzZiMzljMGJhMDAyZjY4ZGQwMzRh
         
     | 
| 
      
 14 
     | 
    
         
            +
                NjY2ZGRlNzZlMWIyMDJlZTIwNjkxZTU3MGEwOGVmZTJmMDhhZDlmMGViNTZl
         
     | 
| 
      
 15 
     | 
    
         
            +
                MzEzNDczNDE0NTgxOTFlZTEzMDhiN2U3YzBjZmFiZWE2ZWVlNDM=
         
     | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,32 +1,42 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## Uni
         
     | 
| 
       1 
2 
     | 
    
         
             
            Simple interface de la [Orce](http://www.orce.uni.edu.pe/).
         
     | 
| 
       2 
     | 
    
         
            -
            Permite visualizar informacion publica, validar codigo, obtener la letra del mismo y consultar notas (password requerido)
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            Instalacion
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permite visualizar informacion publica, validar codigo, obtener la letra del mismo y consultar notas (password requerido, pronto ...)
         
     | 
| 
      
 4 
     | 
    
         
            +
            ## Instalacion
         
     | 
| 
       6 
5 
     | 
    
         
             
            ```bash
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
            $ gem install uni
         
     | 
| 
       8 
7 
     | 
    
         
             
            ```
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
8 
     | 
    
         
             
            ## Ejemplos de uso:
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
9 
     | 
    
         
             
            ### Obtener la letra del codigo:
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            Usando el algoritmo de MOD11
         
     | 
| 
       14 
11 
     | 
    
         
             
            ```ruby
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 12 
     | 
    
         
            +
            Uni.codigo_uni 19741084 # => "19741084H"
         
     | 
| 
       16 
13 
     | 
    
         
             
            ```
         
     | 
| 
       17 
     | 
    
         
            -
            De ser necesario un calculo de la letra mas rapido, usar fast_uni, pero antes se debe invocar a initialize en la constante 'Uni'
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 14 
     | 
    
         
            +
            De ser necesario un calculo de la letra mas rapido(memoria), usar fast_uni, pero antes se debe invocar a initialize en la constante 'Uni'
         
     | 
| 
       19 
15 
     | 
    
         
             
            ```ruby
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 16 
     | 
    
         
            +
            Uni.initialize
         
     | 
| 
      
 17 
     | 
    
         
            +
            Uni.fast_uni 19741084 # => "19741084H"
         
     | 
| 
       22 
18 
     | 
    
         
             
            ```
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
19 
     | 
    
         
             
            ### Consultar informacion basica:
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
            Tambien llamada informacion publica, que se obtiene al hacer busqueda de alumno.
         
     | 
| 
       26 
21 
     | 
    
         
             
            ```ruby
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            Uni.data "19741084H" # => {:codigo=>"19741084H", :nombre=>"...", :facultad=>"...", ...}
         
     | 
| 
       28 
23 
     | 
    
         
             
            ```
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
            ### Consultar cursos, seccion, evaluaciones, calificaciones, etc
         
     | 
| 
      
 25 
     | 
    
         
            +
            Se require conocer el codigo y password del alumno(regular).
         
     | 
| 
      
 26 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 27 
     | 
    
         
            +
            codigo = "20152015"
         
     | 
| 
      
 28 
     | 
    
         
            +
            password = "99999"
         
     | 
| 
      
 29 
     | 
    
         
            +
            notas = Uni.notas codigo, password
         
     | 
| 
      
 30 
     | 
    
         
            +
            ```
         
     | 
| 
      
 31 
     | 
    
         
            +
            Retorna un Array de Hashes, cada Hash corresponde a un curso
         
     | 
| 
      
 32 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 33 
     | 
    
         
            +
            puts notas[0]
         
     | 
| 
      
 34 
     | 
    
         
            +
            # { :curso => "CALCULO RECONTRAVARIABLE", :codigo => "CB102", :seccion => "U",
         
     | 
| 
      
 35 
     | 
    
         
            +
            #   :notas => {:practicas=>[["PRACTICA 1", "15", "--", "19.35%"], [...], ...],
         
     | 
| 
      
 36 
     | 
    
         
            +
            #              :examenes=>[["EXAMEN PARCIAL", "13", "--", "35.48%"], ...]}}
         
     | 
| 
      
 37 
     | 
    
         
            +
            ```
         
     | 
| 
      
 38 
     | 
    
         
            +
            ## Ideas/problemas/uso
         
     | 
| 
      
 39 
     | 
    
         
            +
            * TODO: Clase alumno, Uni.sample, filtrar, subir el modulo uni_private (cursos, notas, etc), cambiar de nombre a la gema
         
     | 
| 
       30 
40 
     | 
    
         
             
            * Sugerencias, dudas o problemas aqui en la repo o en su defecto a mi [email](mailto:cxrlospxndo@gmail.com).
         
     | 
| 
       31 
     | 
    
         
            -
            * De momento lo mas cool que he hecho con  
     | 
| 
      
 41 
     | 
    
         
            +
            * De momento lo mas cool que he hecho con esta gema es obtener esta info [2013-I](http://goo.gl/hqNKI)
         
     | 
| 
       32 
42 
     | 
    
         | 
    
        data/lib/uni.rb
    CHANGED
    
    | 
         @@ -1,5 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'mechanize'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'nokogiri'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       1 
4 
     | 
    
         
             
            require "uni/version"
         
     | 
| 
       2 
5 
     | 
    
         
             
            require "uni/public_info"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "uni/private_info"
         
     | 
| 
       3 
7 
     | 
    
         | 
| 
       4 
8 
     | 
    
         
             
            module Uni
         
     | 
| 
       5 
9 
     | 
    
         
             
              class Amijo
         
     | 
| 
         @@ -21,7 +25,6 @@ module Uni 
     | 
|
| 
       21 
25 
     | 
    
         
             
                  data = Uni::data codigo
         
     | 
| 
       22 
26 
     | 
    
         
             
                  puts data
         
     | 
| 
       23 
27 
     | 
    
         
             
                end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
28 
     | 
    
         
             
                ## cursos y notas
         
     | 
| 
       26 
29 
     | 
    
         
             
                #def top
         
     | 
| 
       27 
30 
     | 
    
         
             
                #  ...
         
     | 
| 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            URL = "http://www.orce.uni.edu.pe/"
         
     | 
| 
      
 2 
     | 
    
         
            +
            module Uni
         
     | 
| 
      
 3 
     | 
    
         
            +
              # Falta refactorizar, aplicar buenas practicas, tests, etc
         
     | 
| 
      
 4 
     | 
    
         
            +
              # http://www.orce.uni.edu.pe/recordNotas.php?op=cursos&flag=notas
         
     | 
| 
      
 5 
     | 
    
         
            +
              # http://www.orce.uni.edu.pe/recordNotas.php?op=notas&tipo=Teoria&codcur=GP102&facul=I&codsec=V
         
     | 
| 
      
 6 
     | 
    
         
            +
              # http://www.orce.uni.edu.pe/recordNotas.php?op=notas&tipo=Practicas&codcur=GP102&facul=I&codsec=V
         
     | 
| 
      
 7 
     | 
    
         
            +
              # Se muestran las tablas tal cual, para evitar problemas en # de practicas, monografias, laboratorios, etc
         
     | 
| 
      
 8 
     | 
    
         
            +
              # Obtiene las notas de un alumno regular
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @param codigo [String] Codigo del alumno # "20152015G"
         
     | 
| 
      
 10 
     | 
    
         
            +
              # @param password [String] password de orce # "12345"
         
     | 
| 
      
 11 
     | 
    
         
            +
              # @return [Array] Notas del ciclo
         
     | 
| 
      
 12 
     | 
    
         
            +
              def self.notas codigo, password
         
     | 
| 
      
 13 
     | 
    
         
            +
                cursos = []
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                agent = Mechanize.new
         
     | 
| 
      
 16 
     | 
    
         
            +
                params = {"txtusu" => codigo, "txtcla" => password}
         
     | 
| 
      
 17 
     | 
    
         
            +
                agent.post( URL + "logeo.php", params)
         
     | 
| 
      
 18 
     | 
    
         
            +
                agent.get URL + "recordNotas.php?op=cursos&flag=notas"
         
     | 
| 
      
 19 
     | 
    
         
            +
                pag = agent.page
         
     | 
| 
      
 20 
     | 
    
         
            +
                a=[]
         
     | 
| 
      
 21 
     | 
    
         
            +
                pag.parser.css('tr.fila td').each do |f|
         
     | 
| 
      
 22 
     | 
    
         
            +
                  a << f.text
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                n = a.size/5
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                (1..n).each do |i|
         
     | 
| 
      
 28 
     | 
    
         
            +
                  ans = { curso: "", codigo: "", seccion: "", notas: {} }
         
     | 
| 
      
 29 
     | 
    
         
            +
                  ind = (i-1)*5
         
     | 
| 
      
 30 
     | 
    
         
            +
                  curso = a[ind.. ind+4]
         
     | 
| 
      
 31 
     | 
    
         
            +
                  ans[:codigo] = curso[0]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  ans[:curso] = curso[1]
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ans[:seccion] = curso[2]
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  practicas = obtener_notas_de "Practicas", ans[:codigo], ans[:seccion], agent
         
     | 
| 
      
 36 
     | 
    
         
            +
                  examenes = obtener_notas_de "Teoria", ans[:codigo], ans[:seccion], agent
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  ans[:notas] = { practicas: practicas, examenes: examenes}
         
     | 
| 
      
 39 
     | 
    
         
            +
                  cursos << ans
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
                cursos
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
              # Obtiene las notas de un curso por tipo de evaluacion (practicas, teoria)
         
     | 
| 
      
 44 
     | 
    
         
            +
              # @return [Array] Nota del curso
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def self.obtener_notas_de evaluacion, codigo, seccion, agent
         
     | 
| 
      
 47 
     | 
    
         
            +
                agent.get URL+"recordNotas.php?op=notas&tipo=#{evaluacion}&codcur=#{codigo}&facul=I&codsec=#{seccion}"
         
     | 
| 
      
 48 
     | 
    
         
            +
                pag_evaluacion = agent.page
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                evaluacion=[]
         
     | 
| 
      
 51 
     | 
    
         
            +
                pag_evaluacion.parser.css("tr td").each_slice(4) do |f|
         
     | 
| 
      
 52 
     | 
    
         
            +
                  ans = []
         
     | 
| 
      
 53 
     | 
    
         
            +
                  f.each do |c|
         
     | 
| 
      
 54 
     | 
    
         
            +
                    ans << c.content.gsub(/\u00a0/, '') # 
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
                  evaluacion<<ans
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
                evaluacion.delete_at(0)
         
     | 
| 
      
 59 
     | 
    
         
            +
                evaluacion
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/uni/public_info.rb
    CHANGED
    
    | 
         @@ -1,9 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # encoding: utf-8
         
     | 
| 
       2 
     | 
    
         
            -
            require 'mechanize'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'nokogiri'
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
2 
     | 
    
         
             
            SITUACIONX = [ "SUSPENSION VOLUNTARIA", "ALUMNO REGULAR", "INACTIVO", "EN REGULARIZACION DE CURSO(S)", "EXPULSADO", "INACTIVO", "RETIRADO ", "FALLECIDO", "SUSPENSION ", "PROYECTO ESPECIAL ALUMNOS UNI"]
         
     | 
| 
       6 
3 
     | 
    
         
             
            SITUACIONY = [ "TITULADO", "BACHILLER", "EGRESADO"]
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       7 
5 
     | 
    
         
             
            module Uni
         
     | 
| 
       8 
6 
     | 
    
         
             
              SITUACION = SITUACIONX + SITUACIONY
         
     | 
| 
       9 
7 
     | 
    
         
             
              @x, @y = {}, {}
         
     | 
    
        data/lib/uni/version.rb
    CHANGED
    
    
    
        data/spec/lib/uni_spec.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       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.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Carlos Pando
         
     | 
| 
         @@ -94,6 +94,7 @@ files: 
     | 
|
| 
       94 
94 
     | 
    
         
             
            - README.md
         
     | 
| 
       95 
95 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       96 
96 
     | 
    
         
             
            - lib/uni.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/uni/private_info.rb
         
     | 
| 
       97 
98 
     | 
    
         
             
            - lib/uni/public_info.rb
         
     | 
| 
       98 
99 
     | 
    
         
             
            - lib/uni/version.rb
         
     | 
| 
       99 
100 
     | 
    
         
             
            - spec/lib/uni_spec.rb
         
     |