PolyNotify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/PolyNotify.gemspec +25 -0
- data/README.md +4 -0
- data/config/example.yml +4 -0
- data/lib/PolyNotify.rb +46 -0
- data/lib/PolyNotify/dossier_etudiant.rb +41 -0
- data/lib/PolyNotify/utilities.rb +19 -0
- data/lib/PolyNotify/version.rb +3 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8973d45a4b9b9419d4743417e0df8207e9c0715a
|
4
|
+
data.tar.gz: b36c83f652ab9ce2309bdc9605b45ddf2d55d21d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c56195488d3df9f05f5f356a5df4a1a61a5d2aa7ef3fcd1ff8d17f40de200a1035e123b426a9a3b6db2d8e1b69b136ab68b17565cef48102a678dd399876c42f
|
7
|
+
data.tar.gz: 0f2103051937ec30d8ee7167ec8ce6bd906ec19e81f6be93a185390a9e0a5a3146dbe4f1de735e58024739a2827b844439d44f7ee46e3c948d700e2851638e17
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
coverage
|
6
|
+
InstalledFiles
|
7
|
+
lib/bundler/man
|
8
|
+
pkg
|
9
|
+
rdoc
|
10
|
+
spec/reports
|
11
|
+
test/tmp
|
12
|
+
test/version_tmp
|
13
|
+
tmp
|
14
|
+
|
15
|
+
# YARD artifacts
|
16
|
+
.yardoc
|
17
|
+
_yardoc
|
18
|
+
doc/
|
19
|
+
|
20
|
+
# Rubymine
|
21
|
+
.idea/
|
22
|
+
|
23
|
+
# Private file
|
24
|
+
config/config.yml
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
PolyNotify (0.0.1)
|
5
|
+
httparty
|
6
|
+
nokogiri
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
httparty (0.11.0)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
mini_portile (0.5.2)
|
15
|
+
multi_json (1.8.0)
|
16
|
+
multi_xml (0.5.5)
|
17
|
+
nokogiri (1.6.0)
|
18
|
+
mini_portile (~> 0.5.0)
|
19
|
+
rake (10.0.4)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
PolyNotify!
|
26
|
+
bundler (~> 1.3)
|
27
|
+
rake
|
data/PolyNotify.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'PolyNotify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "PolyNotify"
|
8
|
+
spec.version = PolyNotify::VERSION
|
9
|
+
spec.authors = ["Chris911"]
|
10
|
+
spec.email = ["Christophe.naud.dulude@gmail.com"]
|
11
|
+
spec.description = "Notifier for Polytechnique Montreal student portal"
|
12
|
+
spec.summary = "Notifier for Polytechnique Montreal student portal"
|
13
|
+
spec.homepage = "https://github.com/Chris911/PolyNotify"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "httparty"
|
24
|
+
spec.add_runtime_dependency "nokogiri"
|
25
|
+
end
|
data/README.md
ADDED
data/config/example.yml
ADDED
data/lib/PolyNotify.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'digest/md5'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require_relative 'PolyNotify/utilities'
|
7
|
+
require_relative 'PolyNotify/dossier_etudiant'
|
8
|
+
|
9
|
+
module PolyNotify
|
10
|
+
class Client
|
11
|
+
[HTTParty, Utilities, Dossier_Etudiant].each do |inc|
|
12
|
+
include inc
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@baseurl = 'https://www4.polymtl.ca'
|
17
|
+
@headers = {'User-Agent' => 'PolyNotify v0.1'}
|
18
|
+
@checksum_file = "#{ENV['HOME']}/.polynotify"
|
19
|
+
@inputs = {}
|
20
|
+
|
21
|
+
# For HTTParty
|
22
|
+
self.class.base_uri @baseurl
|
23
|
+
self.class.headers @headers
|
24
|
+
end
|
25
|
+
|
26
|
+
def load_config_file(file)
|
27
|
+
@config = YAML.load(File.open(file))
|
28
|
+
end
|
29
|
+
|
30
|
+
def load_config_hash(hash)
|
31
|
+
@config = hash
|
32
|
+
end
|
33
|
+
|
34
|
+
def checksum
|
35
|
+
@checksum
|
36
|
+
end
|
37
|
+
|
38
|
+
def last_checksum
|
39
|
+
File.read(@checksum_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
def save_checksum
|
43
|
+
File.open(@checksum_file, 'w') { |file| file.write(@checksum) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module PolyNotify
|
2
|
+
module Dossier_Etudiant
|
3
|
+
|
4
|
+
def log_in
|
5
|
+
body = {code: @config['CODE'], nip: @config['PASSWORD'], naissance: @config['DDN']}
|
6
|
+
data = post('/servlet/ValidationServlet', :body => body, :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
7
|
+
doc = Nokogiri.parse(data)
|
8
|
+
save_data doc
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_resultats_finaux
|
12
|
+
body = @inputs
|
13
|
+
data = post('/servlet/PresentationResultatsTrimServlet', :body => body, :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
14
|
+
doc = Nokogiri.parse(data)
|
15
|
+
extract_notes doc
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_horaire(session)
|
19
|
+
@inputs['trimestre'] = session
|
20
|
+
body = @inputs
|
21
|
+
data = post('/servlet/PresentationHorairePersServlet', :body => body, :headers => {'Content-Type' => 'application/x-www-form-urlencoded'})
|
22
|
+
doc = Nokogiri.parse(data)
|
23
|
+
extract_horaire doc
|
24
|
+
end
|
25
|
+
|
26
|
+
def save_data (doc)
|
27
|
+
doc.css('input').each do |input|
|
28
|
+
@inputs[input['name']] = input['value'] unless input['name'].include? 'btn'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def extract_notes(doc)
|
33
|
+
tables = doc.css('table').select {|table| table['width'] == '75%'}
|
34
|
+
@checksum = Digest::MD5.hexdigest(tables[0])
|
35
|
+
end
|
36
|
+
|
37
|
+
def extract_horaire(doc)
|
38
|
+
horaire = doc.css('table').select {|table| table['cellspacing'] == '5'}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module PolyNotify
|
2
|
+
module Utilities
|
3
|
+
# HTTParty get wrapper. This serves to clean up code, as well as throw webserver errors wherever needed
|
4
|
+
#
|
5
|
+
def get *args, &block
|
6
|
+
response = self.class.get *args, &block
|
7
|
+
raise WebserverError, response.code unless response.code == 200
|
8
|
+
response
|
9
|
+
end
|
10
|
+
|
11
|
+
# HTTParty POST wrapper. This serves to clean up code, as well as throw webserver errors wherever needed
|
12
|
+
#
|
13
|
+
def post *args, &block
|
14
|
+
response = self.class.post *args, &block
|
15
|
+
raise WebserverError, response.code unless response.code == 200
|
16
|
+
response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: PolyNotify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris911
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Notifier for Polytechnique Montreal student portal
|
70
|
+
email:
|
71
|
+
- Christophe.naud.dulude@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- PolyNotify.gemspec
|
80
|
+
- README.md
|
81
|
+
- config/example.yml
|
82
|
+
- lib/PolyNotify.rb
|
83
|
+
- lib/PolyNotify/dossier_etudiant.rb
|
84
|
+
- lib/PolyNotify/utilities.rb
|
85
|
+
- lib/PolyNotify/version.rb
|
86
|
+
homepage: https://github.com/Chris911/PolyNotify
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.0.3
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Notifier for Polytechnique Montreal student portal
|
110
|
+
test_files: []
|