ft_42 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ft_42.rb +23 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 051de4f40afc1f66babddd02b0ff57edfc089974
4
- data.tar.gz: c9d8ae2c26a384c2ed40f02fe61d8fd953c39162
3
+ metadata.gz: c634527047f7476d436a1253fd0c4edc2c722b16
4
+ data.tar.gz: 22c71971b199534fd21dce9a9b00ff7a12dc321c
5
5
  SHA512:
6
- metadata.gz: c660b6ebb7179f9e5cfc5c5f6ec84d56ca949025016c4f28ca161047f990862fd6547731ef3f4aac8146ea8440dd96b4ebed58482aee6dd8d18bf02b49c8b30e
7
- data.tar.gz: '084398ae0a05c678759216d35ebb293752c4cc2700a94c1ea7b2a6879213296eddefbafed1c58927d33338d9dc26a9d436e152ca1893ee659276fe0f33ffdf47'
6
+ metadata.gz: 3a7e1ec7c1a340edf2140af8a089f90bceacae00aadf6a25cf3d286bb6e85871c820cd884c27ad7b30fafd5820846e9b381d5f12f22631ed34299f6ed5636748
7
+ data.tar.gz: b11e520e552f54bc532d1e0bc0add6727748c510fe8662f4ed17e0ba9f37135f77667e6eb3e8ee7f437046f5c921d10630cffcc109e73c322aee94501b660f8a
data/lib/ft_42.rb CHANGED
@@ -21,10 +21,18 @@ class FT_42
21
21
  if (args.first == "project")
22
22
  puts "This is a big request, it may take a minute or two."
23
23
  if (args.include?("after"))
24
- date = args.pop(3).join(" ")
25
- date = DateTime.parse(date)
24
+ after = args.pop(3).join(" ")
25
+ after = DateTime.parse(after)
26
26
  args.pop
27
- ft_42 = Client.new(args.second, args.last, date)
27
+ ft_42 = Client.new(args.second, args.last, after)
28
+ elsif (args.include?("between"))
29
+ before = args.pop(3).join(" ")
30
+ before = DateTime.parse(before)
31
+ args.pop
32
+ after = args.pop(3).join(" ")
33
+ after = DateTime.parse(after)
34
+ args.pop
35
+ ft_42 = Client.new(args.second, args.last, after, before)
28
36
  else
29
37
  ft_42 = Client.new(args.second, args.last)
30
38
  end
@@ -66,12 +74,13 @@ end
66
74
 
67
75
 
68
76
  class Client
69
- attr_reader :input_1, :input_2, :input_3, :token
77
+ attr_reader :input_1, :input_2, :input_3, :input_4, :token
70
78
 
71
- def initialize(input_1, input_2 = nil, input_3 = nil)
79
+ def initialize(input_1, input_2 = nil, input_3 = nil, input_4 = nil)
72
80
  @input_1 = input_1
73
81
  @input_2 = input_2
74
82
  @input_3 = input_3
83
+ @input_4 = input_4
75
84
  @token = Token.new.token
76
85
  end
77
86
 
@@ -98,7 +107,7 @@ class Client
98
107
  begin
99
108
  tries ||= 3
100
109
  if input_3
101
- response = token.get("/v2/projects_users?filter[campus]=#{campus['id']}&filter[project_id]=#{project['id']}&range[created_at]=#{after},#{right_now}", params: { page: i, per_page: 100 }).parsed
110
+ response = token.get("/v2/projects_users?filter[campus]=#{campus['id']}&filter[project_id]=#{project['id']}&range[created_at]=#{after},#{before}", params: { page: i, per_page: 100 }).parsed
102
111
  else
103
112
  response = token.get("/v2/projects_users?filter[campus]=#{campus['id']}&filter[project_id]=#{project['id']}", params: { page: i, per_page: 100 }).parsed
104
113
  end
@@ -125,6 +134,14 @@ class Client
125
134
  input_3.to_time.to_s.split(" ")[0...-1].join("T")
126
135
  end
127
136
 
137
+ def before
138
+ if input_4
139
+ input_4.to_time.to_s.split(" ")[0...-1].join("T")
140
+ else
141
+ Time.current.beginning_of_week.to_s.split(" ")[0...-1].join("T")
142
+ end
143
+ end
144
+
128
145
  def time_ago
129
146
  if input_2
130
147
  time = Time.current - (input_2.to_i * 7).days
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ft_42
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Fernandez