martlet 0.0.3 → 0.0.4

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.
Files changed (4) hide show
  1. data/README.md +24 -1
  2. data/bin/martlet +57 -0
  3. data/lib/martlet/version.rb +1 -1
  4. metadata +5 -3
data/README.md CHANGED
@@ -18,10 +18,33 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ ### Ruby
22
+
21
23
  $ irb
22
24
  >> require 'martlet'
23
25
  >> client = Martlet.new('your.name@mail.mcgill.ca', 'topsecret')
24
26
  >> pp client.grades
25
27
  {"COMP 206"=>"A",
26
28
  "COMP 250"=>"A"
27
- ...
29
+ ...
30
+
31
+ ### Shell
32
+
33
+ $ martlet grades
34
+ Minerva email: your.name@mail.mcgill.ca
35
+ Password:
36
+ Authenticating...
37
+ Fetching grades...
38
+ COMP 206: A
39
+ COMP 250: A
40
+ ...
41
+
42
+ Store your credentials in ~/.martlet to avoid typing them every time
43
+
44
+ $ cat ~/.martlet
45
+ email: 'your.name@mail.mcgill.ca'
46
+ password: 'topsecret'
47
+ $ martlet grades
48
+ Authenticating...
49
+ Fetching grades....
50
+ ...
data/bin/martlet ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join File.dirname(__FILE__), '..', 'lib'
3
+ require 'rubygems'
4
+ require 'martlet'
5
+ require 'yaml'
6
+ require 'io/console'
7
+
8
+ def usage
9
+ puts <<-STR
10
+ USAGE:
11
+ martlet [command]
12
+
13
+ COMMANDS:
14
+ grades Lists all your grades. This is the default command.
15
+ STR
16
+ end
17
+
18
+ def get_credentials
19
+ config_path = File.join ENV['HOME'], '.martlet'
20
+ email = nil
21
+ password = nil
22
+
23
+ if File.exist?(config_path)
24
+ config = YAML.load_file config_path
25
+ email = config['email']
26
+ password = config['password']
27
+ else
28
+ print 'Minerva email: '
29
+ email = gets.chomp
30
+
31
+ print 'Password: '
32
+ password = STDIN.noecho(&:gets).chomp
33
+ puts
34
+ end
35
+
36
+ return email, password
37
+ end
38
+
39
+ args = ARGV.dup
40
+ ARGV.clear
41
+
42
+ case args.shift
43
+ when nil, 'grades'
44
+ email, password = get_credentials
45
+
46
+ puts 'Authenticating...'
47
+ client = Martlet.new(email, password)
48
+
49
+ puts 'Fetching grades...'
50
+ grades = client.grades
51
+
52
+ grades.each do |number, grade|
53
+ puts "#{number}: #{grade}"
54
+ end
55
+ else
56
+ usage
57
+ end
@@ -1,3 +1,3 @@
1
1
  module Martlet
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: martlet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-22 00:00:00.000000000 Z
12
+ date: 2013-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -62,7 +62,8 @@ dependencies:
62
62
  description: Ruby client for McGill's student portal, Minerva.
63
63
  email:
64
64
  - hello@alexcoco.com
65
- executables: []
65
+ executables:
66
+ - martlet
66
67
  extensions: []
67
68
  extra_rdoc_files: []
68
69
  files:
@@ -71,6 +72,7 @@ files:
71
72
  - LICENSE.txt
72
73
  - README.md
73
74
  - Rakefile
75
+ - bin/martlet
74
76
  - lib/martlet.rb
75
77
  - lib/martlet/authenticator.rb
76
78
  - lib/martlet/client.rb