evertils 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a297001fe3422429dc834fdf46aac20f178c4a05
4
- data.tar.gz: cf6d72162013a24f9a096d6bf3c6b8eb2df8061a
3
+ metadata.gz: f712f62fd717a1cc4db805d018b1a476e73845e3
4
+ data.tar.gz: 5105f65a7bb0afad5b1b35786d3ffb6a73486c20
5
5
  SHA512:
6
- metadata.gz: 941beafd5f7132064e68b8fd1265485f4ecbd2b26fec8129a1159ffeb80e2bccd00663eafe9f9d96fd9fef304baade9c1ac3c047ba578c655bdcdaf60fa2c86d
7
- data.tar.gz: 8dc0676210fb91536d1568e021ea7858e8cf3e2e66e9800e504bd257012323755f2f46d1611d92b16940a48759921c2b0f0de13a58b974a19ab0e87a18eef328
6
+ metadata.gz: 2d5f649580c493c3804711586fa1837bb1924c2c6d44eee85c2321f13f2808339884c24214ca2d12d7f2b70eb3d71aeac2fe2ee75d493bbd579c73c38d1d4db8
7
+ data.tar.gz: 85fd2030f14e7658575de94fff3a43cb3bff7cfa4d157cf1366a7ff2fa4df24d3643f9f1482b1a375fbbdbb0534c1a83cbe00d2a6e4d61b50ac97dbe861b0626
@@ -1,7 +1,7 @@
1
1
  module Granify
2
2
  module Controller
3
3
  class Generate < Controller::Base
4
- attr_accessor :force
4
+ attr_accessor :force, :start
5
5
 
6
6
  def pre_exec
7
7
  begin
@@ -25,6 +25,10 @@ module Granify
25
25
  opt.on("-f", "--force", "Force execution") do
26
26
  @force = true
27
27
  end
28
+
29
+ opt.on("-s", "--start=START", "Specify a date for the note") do |date|
30
+ @start = DateTime.parse(date)
31
+ end
28
32
  end.parse!
29
33
 
30
34
  super
@@ -36,12 +40,12 @@ module Granify
36
40
  end
37
41
 
38
42
  if !@force
39
- if @model.note_exists
43
+ if @model.note_exists(@start)
40
44
  Notify.error("There's already a log for today!")
41
45
  end
42
46
  end
43
47
 
44
- @model.create_deployment_note
48
+ @model.create_deployment_note(@start)
45
49
  end
46
50
 
47
51
  # generate daily notes
@@ -134,9 +134,10 @@ module Granify
134
134
  @@store.findNotes(@@developer_token, filter, nil, 300)
135
135
  end
136
136
 
137
- def note_exists
137
+ def note_exists(requested_date)
138
138
  results = Helper::Results.new
139
- template = date_templates[command]
139
+ tmpl = date_templates(requested_date)
140
+ template = tmpl[command]
140
141
  note = find_note(template)
141
142
 
142
143
  # Evernote's search matches things like the following, so we have to get
@@ -153,10 +154,13 @@ module Granify
153
154
  results.should_eval_to(false)
154
155
  end
155
156
 
156
- def create_note(title = date_templates[command.capitalize], body = template_contents, p_notebook_name = nil, file = nil, share_note = false, created_on = nil)
157
+ def create_note(title = command.capitalize, body = template_contents, p_notebook_name = nil, file = nil, share_note = false, created_on = nil)
157
158
  # final output
158
159
  output = {}
159
160
 
161
+ tmpl = date_templates
162
+ title = tmpl[title]
163
+
160
164
  # Create note object
161
165
  our_note = ::Evernote::EDAM::Type::Note.new
162
166
  our_note.resources = []
@@ -231,10 +235,12 @@ module Granify
231
235
  output
232
236
  end
233
237
 
234
- def create_deployment_note
238
+ def create_deployment_note(requested_date)
235
239
  # final output
236
240
  output = {}
237
241
 
242
+ requested_date = DateTime.now if requested_date.nil?
243
+
238
244
  # Create note object
239
245
  our_note = ::Evernote::EDAM::Type::Note.new
240
246
  our_note.resources = []
@@ -257,7 +263,8 @@ module Granify
257
263
  n_body += "<en-note>#{body}</en-note>"
258
264
 
259
265
  # setup note properties
260
- our_note.title = date_templates[NOTEBOOK_DEPLOYMENT]
266
+ tmpl = date_templates(requested_date)
267
+ our_note.title = tmpl[NOTEBOOK_DEPLOYMENT]
261
268
  our_note.content = n_body
262
269
 
263
270
  parent_notebook = notebook_by_name(NOTEBOOK_DEPLOYMENT)
@@ -297,8 +304,8 @@ module Granify
297
304
 
298
305
  # Legacy notes will have single/double character denotations for day of
299
306
  # week, this maps them.
300
- def day_of_week
301
- case Date.today.strftime('%a')
307
+ def day_of_week(arg_date = Date.today.strftime('%a'))
308
+ case arg_date
302
309
  when 'Mon'
303
310
  :M
304
311
  when 'Tue'
@@ -325,15 +332,15 @@ module Granify
325
332
  end
326
333
  end
327
334
 
328
- def date_templates
329
- now = DateTime.now
330
- end_of_week = now + 4 # days
335
+ def date_templates(arg_date = DateTime.now)
336
+ dow = day_of_week(arg_date.strftime('%a'))
337
+ end_of_week = arg_date + 4 # days
331
338
 
332
339
  {
333
- :Daily => "Daily Log [#{now.strftime('%B %-d')} - #{day_of_week}]",
334
- :Weekly => "Weekly Log [#{now.strftime('%B %-d')} - #{end_of_week.strftime('%B %-d')}]",
335
- :Monthly => "Monthly Log [#{now.strftime('%B %Y')}]",
336
- :Deployments => "#{now.strftime('%B %-d')} - #{day_of_week}"
340
+ :Daily => "Daily Log [#{arg_date.strftime('%B %-d')} - #{dow}]",
341
+ :Weekly => "Weekly Log [#{arg_date.strftime('%B %-d')} - #{end_of_week.strftime('%B %-d')}]",
342
+ :Monthly => "Monthly Log [#{arg_date.strftime('%B %Y')}]",
343
+ :Deployments => "#{arg_date.strftime('%B %-d')} - #{dow}"
337
344
  }
338
345
  end
339
346
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Granify
2
- VERSION = '0.1.17'
2
+ VERSION = '0.1.18'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evertils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe