ft_42 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/ft_42 +36 -0
  3. data/lib/ft_42.rb +1 -36
  4. metadata +5 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 801af7017034fb3ac11660d6706473a21381ab98
4
- data.tar.gz: e5b84123a0e4530f5ae1e6d50672fc7557a03db1
3
+ metadata.gz: abad1a5f8fa491b18462c90d7f0634afaee817ac
4
+ data.tar.gz: c61ce28f085fb0ceb03d40a898328241277717da
5
5
  SHA512:
6
- metadata.gz: 77bb29cfca2ee5d812470ff0268f031768104b977df871da999839251fda6f1a7c90cecd2c9c6e6bf7edf7e666da64ede6e419d6a6eadc18365237d6f54a885f
7
- data.tar.gz: f0aaddc3f024b6480779abad25b436a8b7ace63631028db9762a4390048f0ba0d7199ce9e76a0b09ea2ae2fa020154762dc8b930d91fe7afef33e91165c642b1
6
+ metadata.gz: a38c56121ecfa828c29699e71444443614d56fd590db604f4f6d1f66c4a5478f7cbfdc498f1f029dcf12430f5103f529cc29e9670ebc282d802a26178ed3dc2a
7
+ data.tar.gz: 4153c12c7114160edc6963a993e1ed2a7002eda043b1ec6a2a80fe154ab371c1322de95d9f47e88f61db64daa13e16e5d5acb7b3c66cfc892fd6ef9c310c2e90
data/bin/ft_42 ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "active_support/all"
4
+ require "pastel"
5
+ require "oauth2"
6
+ require "ruby-progressbar"
7
+
8
+ HOURS_NEEDED = 38
9
+ USERNAME = ARGV[0];
10
+ UID = ENV.fetch("FT42_UID")
11
+ SECRET = ENV.fetch("FT42_SECRET")
12
+
13
+ client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
14
+ token = client.client_credentials.get_token
15
+
16
+ time_ago = Time.current.beginning_of_week.to_s.split(" ")[0...-1].join("T")
17
+ right_now = Time.current.to_s.split(" ")[0...-1].join("T")
18
+
19
+ sessions = token.get("/v2/users/#{USERNAME}/locations?range[begin_at]=#{time_ago},#{right_now}", params: { per_page: 60 }).parsed
20
+
21
+ duration = 0
22
+ sessions.each do |session|
23
+ begin_at = session["begin_at"].to_time
24
+ end_at = session["end_at"].to_time
25
+ duration += (end_at - begin_at)
26
+ end
27
+
28
+ hours = (duration / 60 / 60).round
29
+
30
+ pastel = Pastel.new
31
+ puts pastel.bright_green.bold("#{USERNAME}") + " has " + pastel.bright_green.bold("#{hours} #{hours == 1 ? 'hour' : 'hours'}") + " in the clusters this week"
32
+
33
+ percent_complete = ((hours.to_f / HOURS_NEEDED.to_f) * 100).round
34
+ progressbar_needed = ProgressBar.create(progress_mark: "█", length: 60, format: "%t: |" + pastel.bright_green("%B") + "| #{hours}/38 hours")
35
+ percent_complete.times { progressbar_needed.increment }
36
+ puts progressbar_needed
data/lib/ft_42.rb CHANGED
@@ -1,37 +1,2 @@
1
- require "active_support/all"
2
- require "pastel"
3
- require "oauth2"
4
- require "ruby-progressbar"
5
- require "dotenv"
6
-
7
- Dotenv.load
8
-
9
- HOURS_NEEDED = 38
10
- USERNAME = ARGV[0];
11
- UID = ENV.fetch("UID")
12
- SECRET = ENV.fetch("SECRET")
13
-
14
- client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
15
- token = client.client_credentials.get_token
16
-
17
- time_ago = Time.current.beginning_of_week.to_s.split(" ")[0...-1].join("T")
18
- right_now = Time.current.to_s.split(" ")[0...-1].join("T")
19
-
20
- sessions = token.get("/v2/users/#{USERNAME}/locations?range[begin_at]=#{time_ago},#{right_now}", params: { per_page: 60 }).parsed
21
-
22
- duration = 0
23
- sessions.each do |session|
24
- begin_at = session["begin_at"].to_time
25
- end_at = session["end_at"].to_time
26
- duration += (end_at - begin_at)
1
+ class FT_42
27
2
  end
28
-
29
- hours = (duration / 60 / 60).round
30
-
31
- pastel = Pastel.new
32
- puts pastel.bright_green.bold("#{USERNAME}") + " has " + pastel.bright_green.bold("#{hours} #{hours == 1 ? 'hour' : 'hours'}") + " in the clusters this week"
33
-
34
- percent_complete = ((hours.to_f / HOURS_NEEDED.to_f) * 100).round
35
- progressbar_needed = ProgressBar.create(length: 60, format: "%t: |" + pastel.bright_green("%B") + "| #{hours}/38 hours")
36
- percent_complete.times { progressbar_needed.increment }
37
- puts progressbar_needed
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ft_42
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Fernandez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-04 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_support/all
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: action_view
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pastel
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,27 +66,15 @@ dependencies:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: dotenv
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
69
  description: General information for 42 students
98
70
  email: matiasfmolinari@gmail.com
99
- executables: []
71
+ executables:
72
+ - ft_42
100
73
  extensions: []
101
74
  extra_rdoc_files: []
102
75
  files:
103
76
  - lib/ft_42.rb
77
+ - bin/ft_42
104
78
  homepage: http://rubygems.org/gems/ft_42
105
79
  licenses:
106
80
  - MIT