uqam_grade_notification 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9e1f1a5c003b5f71c81c10f79096dabb6448898
4
- data.tar.gz: c9885635447fe35996a2a55689a72fdab0400ef2
3
+ metadata.gz: dd36bd57e50e12a03c26f0e7221e5dd8187fe2aa
4
+ data.tar.gz: 82ed74a72b629fc08b1d25c2d999b72c0da1efef
5
5
  SHA512:
6
- metadata.gz: 0d0bce3c4ebe50f302b5672cb766bd2b1823c1fb5adf3c6b6b0899948ee65ba3631b4bb372d960abf5d8a49081a275176dc0ae011a8b10549ee4061883a6a1ca
7
- data.tar.gz: 6c8041bc2a95ee3304b302ac549c95872814a7936b3bfa739f44229bf06c48fac92dc85a55af848f53e4e23f49a116f8e48872a0235c2d5be03b73b1e00dd947
6
+ metadata.gz: 95294dd71d5fb727c0e95ec80f294c9f884eadd82dc7cf0edd55dc6b37c7eed0c36d7edc76d0b97815e9cfcb85cf291bd6d5d49a1f01be3b0608195394889108
7
+ data.tar.gz: 9a37c6e87eb46e0140dc7a85b1d26c03d71dbab59c5cd2e4c167302d26ba60463a0ec7ff06d4cdbaf4053407661ea9e243132365956cc0d55ce2841004135029
@@ -29,7 +29,7 @@ configuration =
29
29
  if File.exist?(UqamGradeNotification::CONFIG_FILE)
30
30
  JSON.parse(File.open(UqamGradeNotification::CONFIG_FILE).read)
31
31
  else
32
- configuration_cli
32
+ UqamGradeNotification.configuration_cli
33
33
  end
34
34
 
35
35
  student = UqamGradeNotification::Student.new(configuration)
@@ -2,6 +2,7 @@ require 'fileutils'
2
2
  require 'json'
3
3
  require 'highline'
4
4
  require 'digest'
5
+ require 'active_support/hash_with_indifferent_access'
5
6
  require 'uqam_grade_notification/version'
6
7
  require 'uqam_grade_notification/student'
7
8
  require 'uqam_grade_notification/notifier'
@@ -9,7 +9,6 @@ module UqamGradeNotification
9
9
  end
10
10
 
11
11
  def notify_of_changes
12
- current_grades = student.grades.to_json
13
12
  if grades_have_changed?
14
13
  p "Grades have not changed since last checked."
15
14
  else
@@ -4,11 +4,12 @@ module UqamGradeNotification
4
4
  class Notifier
5
5
  attr_reader :phone
6
6
 
7
- def initialize user_info
8
- @phone = user_info.fetch("phone")
9
- @twilio_account_id = user_info.fetch("twilio_account_id")
10
- @twilio_token = user_info.fetch("twilio_token")
11
- @twilio_phone = user_info.fetch("twilio_phone")
7
+ def initialize args
8
+ args = HashWithIndifferentAccess.new(args)
9
+ @phone = args.fetch("phone")
10
+ @twilio_account_id = args.fetch("twilio_account_id")
11
+ @twilio_token = args.fetch("twilio_token")
12
+ @twilio_phone = args.fetch("twilio_phone")
12
13
  end
13
14
 
14
15
  def sms(message)
@@ -6,9 +6,10 @@ module UqamGradeNotification
6
6
  class Student
7
7
  attr_reader :code, :password
8
8
 
9
- def initialize user_info
10
- @code = user_info.fetch("code")
11
- @password = user_info.fetch("password")
9
+ def initialize args
10
+ args = HashWithIndifferentAccess.new(args)
11
+ @code = args.fetch("code")
12
+ @password = args.fetch("password")
12
13
  end
13
14
 
14
15
  def grades
@@ -60,17 +61,17 @@ module UqamGradeNotification
60
61
  end
61
62
 
62
63
  def token
63
- @token ||= login.body["token"]
64
+ @token ||= get_token
64
65
  end
65
66
 
66
- def login
67
+ def get_token
67
68
  connection.post do |req|
68
69
  req.url "/authentification"
69
70
  req.headers['Content-Type'] = 'application/json;charset=UTF-8'
70
71
  req.headers['Origin'] = 'https://portailetudiant.uqam.ca'
71
72
  req.headers['Referer'] = 'https://portailetudiant.uqam.ca'
72
- req.body = {identifiant: code, motDePasse: password}.to_json
73
- end
73
+ req.body = {identifiant: code, motDePasse: password}
74
+ end.body["token"]
74
75
  end
75
76
  end
76
77
  end
@@ -1,3 +1,3 @@
1
1
  module UqamGradeNotification
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib", "lib/uqam_grade_notification"]
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.9"
21
+ spec.add_development_dependency "rspec"
21
22
  spec.add_development_dependency "rake", "~> 10.0"
22
- spec.add_dependency "nokogiri"
23
+ spec.add_dependency "activesupport"
23
24
  spec.add_dependency "faraday"
24
25
  spec.add_dependency "faraday_middleware"
25
26
  spec.add_dependency "faraday-cookie_jar"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uqam_grade_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Croteau-Pothier
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
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'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: nokogiri
56
+ name: activesupport
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="