evertils 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/controllers/generate.rb +15 -1
- data/lib/helpers/evernote.rb +69 -4
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34b47cca996f377fe18994fdc93ec4434c9f7126
|
4
|
+
data.tar.gz: b2ba6dfa2f4fe920170f6febc85fe08fd655b338
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de9b29c76857ed63808f68198358d2c0a8e819e5008a88747e389dee021434f00f2ebff139deeaadc8ae5d5df77ed52995a90d8998729fb8c1418d87a972f13
|
7
|
+
data.tar.gz: 90b6c2828c1b535a594bae9275aadcbe7f574c398e66757b618b2f72d1556bcc070d84a498781166158f276aad40858e09d0aa704c08c6ce47c2bd0e1ea9c498
|
data/lib/controllers/generate.rb
CHANGED
@@ -9,7 +9,7 @@ module Granify
|
|
9
9
|
@model = Granify::Helper.load('evernote')
|
10
10
|
|
11
11
|
# all methods require internet to make API calls
|
12
|
-
@methods_require_internet.push(:daily, :weekly, :monthly)
|
12
|
+
@methods_require_internet.push(:daily, :weekly, :monthly, :deployment)
|
13
13
|
|
14
14
|
# user = @model.user
|
15
15
|
# Notify.success("Welcome, #{user.name} (#{user.username})")
|
@@ -30,6 +30,20 @@ module Granify
|
|
30
30
|
super
|
31
31
|
end
|
32
32
|
|
33
|
+
def deployment
|
34
|
+
if STDIN.tty?
|
35
|
+
Notify.error("This command relies on piped data to generate note data")
|
36
|
+
end
|
37
|
+
|
38
|
+
if !@force
|
39
|
+
if @model.note_exists
|
40
|
+
Notify.error("There's already a log for today!")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
@model.create_deployment_note
|
45
|
+
end
|
46
|
+
|
33
47
|
# generate daily notes
|
34
48
|
def daily
|
35
49
|
if !@force
|
data/lib/helpers/evernote.rb
CHANGED
@@ -3,6 +3,12 @@ module Granify
|
|
3
3
|
class Evernote
|
4
4
|
@@developer_token = ENV["EVERTILS_TOKEN"]
|
5
5
|
|
6
|
+
# required user-created notebooks
|
7
|
+
NOTEBOOK_DAILY = :Daily
|
8
|
+
NOTEBOOK_WEEKLY = :Weekly
|
9
|
+
NOTEBOOK_MONTHLY = :Monthly
|
10
|
+
NOTEBOOK_DEPLOYMENT = :Deployments
|
11
|
+
|
6
12
|
def initialize
|
7
13
|
authenticate
|
8
14
|
end
|
@@ -148,6 +154,9 @@ module Granify
|
|
148
154
|
end
|
149
155
|
|
150
156
|
def create_note(title = date_templates[$request.command], body = template_contents, p_notebook_name = nil, file = nil, share_note = false, created_on = nil)
|
157
|
+
# final output
|
158
|
+
output = {}
|
159
|
+
|
151
160
|
# Create note object
|
152
161
|
our_note = ::Evernote::EDAM::Type::Note.new
|
153
162
|
our_note.resources = []
|
@@ -195,7 +204,6 @@ module Granify
|
|
195
204
|
|
196
205
|
## Attempt to create note in Evernote account
|
197
206
|
begin
|
198
|
-
output = {}
|
199
207
|
output[:note] = @@store.createNote(@@developer_token, our_note)
|
200
208
|
|
201
209
|
if share_note
|
@@ -223,6 +231,62 @@ module Granify
|
|
223
231
|
output
|
224
232
|
end
|
225
233
|
|
234
|
+
def create_deployment_note
|
235
|
+
# final output
|
236
|
+
output = {}
|
237
|
+
|
238
|
+
# Create note object
|
239
|
+
our_note = ::Evernote::EDAM::Type::Note.new
|
240
|
+
our_note.resources = []
|
241
|
+
our_note.tagNames = []
|
242
|
+
|
243
|
+
# format output, expected format:
|
244
|
+
# PR_DESCRIPTION (https://github.com/repo/repo/pull/PR_NUM)
|
245
|
+
# - Created by GIT_USER
|
246
|
+
# - Branch: GIT_BRANCH
|
247
|
+
# - Merged by GIT_USER on 30/6/2015 @ 06:09:27pm
|
248
|
+
# - Changes: https://github.com/repo/repo/pull/PR_NUM.diff
|
249
|
+
# ============================================================
|
250
|
+
# 1 PR(s) merged from 2015-06-30 18:00:00 to 2015-07-01 17:59:59
|
251
|
+
# ============================================================
|
252
|
+
body = JSON.parse(STDIN.gets).join
|
253
|
+
body = body.gsub("\n", '<br />')
|
254
|
+
|
255
|
+
n_body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
256
|
+
n_body += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
|
257
|
+
n_body += "<en-note>#{body}</en-note>"
|
258
|
+
|
259
|
+
# setup note properties
|
260
|
+
our_note.title = date_templates[NOTEBOOK_DEPLOYMENT]
|
261
|
+
our_note.content = n_body
|
262
|
+
|
263
|
+
parent_notebook = notebook_by_name(NOTEBOOK_DEPLOYMENT)
|
264
|
+
|
265
|
+
# parent_notebook is optional; if omitted, default notebook is used
|
266
|
+
if parent_notebook.is_a? ::Evernote::EDAM::Type::Notebook
|
267
|
+
our_note.notebookGuid = parent_notebook.guid
|
268
|
+
end
|
269
|
+
|
270
|
+
# Attempt to create note in Evernote account
|
271
|
+
begin
|
272
|
+
output[:note] = @@store.createNote(@@developer_token, our_note)
|
273
|
+
rescue ::Evernote::EDAM::Error::EDAMUserException => edue
|
274
|
+
##Something was wrong with the note data
|
275
|
+
# See EDAMErrorCode enumeration for error code explanation
|
276
|
+
# http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode
|
277
|
+
Notify.error "EDAMUserException: #{edue}\nCode #{edue.errorCode}: #{edue.parameter}\nExtended:\n#{edue.inspect}"
|
278
|
+
rescue ::Evernote::EDAM::Error::EDAMNotFoundException => ednfe
|
279
|
+
# Parent Notebook GUID doesn't correspond to an actual notebook
|
280
|
+
Notify.error "EDAMNotFoundException: Invalid parent notebook GUID"
|
281
|
+
end
|
282
|
+
|
283
|
+
# A parent notebook object exists, otherwise it was saved to the default
|
284
|
+
# notebook
|
285
|
+
Notify.success("#{parent_notebook.name}/#{our_note.title} created")
|
286
|
+
|
287
|
+
output
|
288
|
+
end
|
289
|
+
|
226
290
|
def generate_stats
|
227
291
|
{
|
228
292
|
"Statistic description" => 9845.3894
|
@@ -265,9 +329,10 @@ module Granify
|
|
265
329
|
end_of_week = now + 4 # days
|
266
330
|
|
267
331
|
{
|
268
|
-
:
|
269
|
-
:
|
270
|
-
:
|
332
|
+
:Daily => "Daily Log [#{now.strftime('%B %-d')} - #{day_of_week}]",
|
333
|
+
:Weekly => "Weekly Log [#{now.strftime('%B %-d')} - #{end_of_week.strftime('%B %-d')}]",
|
334
|
+
:Monthly => "Monthly Log [#{now.strftime('%B %Y')}]",
|
335
|
+
:Deployments => "#{now.strftime('%B %-d')} - #{day_of_week}"
|
271
336
|
}
|
272
337
|
end
|
273
338
|
end
|
data/lib/version.rb
CHANGED