evertils-common 0.3.1 → 0.3.2

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: c5c3bbd18a393a156658617c52141aac0f240d20
4
- data.tar.gz: 3a2c99ccf274dd74564e4455ad99da612a5d8aeb
3
+ metadata.gz: 5373e916dd2c6812cf51d1fb29552c4a31e4e849
4
+ data.tar.gz: 411679ae6c66dfc2f84ed56eae1195409409a5b5
5
5
  SHA512:
6
- metadata.gz: 4dfe0cb7e60bdf8df02e1310476bb651bd70fa4209bc6dfae4ddf97d02d8b1e2c9dcf362fa5d8f1e585a31967725a1c13a63ba58a429a7624d0b33ddb7deb4ef
7
- data.tar.gz: 1da86f2c6fed45d76ba2a7a241c93dcc5828aa4cc29d949708fe270fbeb6e546559708f41185d993e3ef57ccdbaa8e4b1991ce03d73f003d7672b82631118c6f
6
+ metadata.gz: 31a683b20d62bff159d805ecff5345b9dd1e2d78673b10859f2886af7ec724bdb97fc142fe7dcfbcc9b566097f6defa71e78e70c015523a9d596b04f31e9e7f7
7
+ data.tar.gz: 98d9a69fedef985a87162eacdf63674fd771ac1bddd45e3ac5f04356c9c60100bfd5f25e13844e35d7c8bf1197291b66f97239910f0eb1bedb7707764b48a49d
data/.hound.yml ADDED
@@ -0,0 +1,2 @@
1
+ ruby:
2
+ config_file: .rubocop.yml
data/.rubocop.yml ADDED
@@ -0,0 +1,320 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2016-07-26 11:49:15 -0600 using RuboCop version 0.42.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Cop supports --auto-correct.
11
+ Lint/DeprecatedClassMethods:
12
+ Exclude:
13
+ - 'lib/evertils/common/entity/notebooks.rb'
14
+
15
+ # Offense count: 1
16
+ Lint/ShadowingOuterLocalVariable:
17
+ Exclude:
18
+ - 'lib/evertils/test/base.rb'
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: ContextCreatingMethods.
22
+ Lint/UselessAccessModifier:
23
+ Exclude:
24
+ - 'lib/evertils/common/authentication.rb'
25
+
26
+ # Offense count: 9
27
+ Lint/UselessAssignment:
28
+ Exclude:
29
+ - 'lib/evertils/common/entity/note.rb'
30
+ - 'lib/evertils/common/query/simple.rb'
31
+
32
+ # Offense count: 10
33
+ Metrics/AbcSize:
34
+ Max: 46
35
+
36
+ # Offense count: 2
37
+ # Configuration parameters: CountComments.
38
+ Metrics/ClassLength:
39
+ Max: 117
40
+
41
+ # Offense count: 2
42
+ Metrics/CyclomaticComplexity:
43
+ Max: 20
44
+
45
+ # Offense count: 65
46
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
47
+ # URISchemes: http, https
48
+ Metrics/LineLength:
49
+ Max: 176
50
+
51
+ # Offense count: 13
52
+ # Configuration parameters: CountComments.
53
+ Metrics/MethodLength:
54
+ Max: 45
55
+
56
+ # Offense count: 2
57
+ # Configuration parameters: CountKeywordArgs.
58
+ Metrics/ParameterLists:
59
+ Max: 6
60
+
61
+ # Offense count: 1
62
+ Metrics/PerceivedComplexity:
63
+ Max: 11
64
+
65
+ # Offense count: 2
66
+ # Cop supports --auto-correct.
67
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
68
+ # SupportedStyles: prefer_alias, prefer_alias_method
69
+ Style/Alias:
70
+ Exclude:
71
+ - 'lib/evertils/common/entity/note.rb'
72
+ - 'lib/evertils/common/entity/notes.rb'
73
+
74
+ # Offense count: 1
75
+ Style/ClassVars:
76
+ Exclude:
77
+ - 'lib/evertils/test/base.rb'
78
+
79
+ # Offense count: 6
80
+ # Cop supports --auto-correct.
81
+ Style/ColonMethodCall:
82
+ Exclude:
83
+ - 'lib/evertils/common/converter/yaml_to_enml.rb'
84
+ - 'lib/evertils/common/entity/note.rb'
85
+ - 'lib/evertils/common/entity/notebooks.rb'
86
+ - 'lib/evertils/common/entity/stack.rb'
87
+ - 'lib/evertils/test/base.rb'
88
+
89
+ # Offense count: 1
90
+ # Cop supports --auto-correct.
91
+ # Configuration parameters: Keywords.
92
+ # Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
93
+ Style/CommentAnnotation:
94
+ Exclude:
95
+ - 'Rakefile'
96
+
97
+ # Offense count: 3
98
+ # Cop supports --auto-correct.
99
+ # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
100
+ # SupportedStyles: assign_to_condition, assign_inside_condition
101
+ Style/ConditionalAssignment:
102
+ Exclude:
103
+ - 'lib/evertils/common/manager/note.rb'
104
+ - 'lib/evertils/common/manager/notebook.rb'
105
+ - 'lib/evertils/common/manager/tag.rb'
106
+
107
+ # Offense count: 25
108
+ Style/Documentation:
109
+ Enabled: false
110
+
111
+ # Offense count: 1
112
+ # Cop supports --auto-correct.
113
+ Style/EmptyLines:
114
+ Exclude:
115
+ - 'Rakefile'
116
+
117
+ # Offense count: 3
118
+ # Cop supports --auto-correct.
119
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
120
+ # SupportedStyles: empty_lines, no_empty_lines
121
+ Style/EmptyLinesAroundClassBody:
122
+ Exclude:
123
+ - 'lib/evertils/common/converter/yaml_to_enml.rb'
124
+ - 'lib/evertils/test/base.rb'
125
+
126
+ # Offense count: 4
127
+ # Cop supports --auto-correct.
128
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
129
+ # SupportedStyles: empty_lines, no_empty_lines
130
+ Style/EmptyLinesAroundModuleBody:
131
+ Exclude:
132
+ - 'lib/evertils/common.rb'
133
+ - 'lib/evertils/test.rb'
134
+
135
+ # Offense count: 2
136
+ # Cop supports --auto-correct.
137
+ # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
138
+ Style/ExtraSpacing:
139
+ Exclude:
140
+ - 'Rakefile'
141
+ - 'lib/evertils/test/base.rb'
142
+
143
+ # Offense count: 1
144
+ # Configuration parameters: MinBodyLength.
145
+ Style/GuardClause:
146
+ Exclude:
147
+ - 'lib/evertils/common/authentication.rb'
148
+
149
+ # Offense count: 5
150
+ # Cop supports --auto-correct.
151
+ # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
152
+ # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
153
+ Style/HashSyntax:
154
+ Exclude:
155
+ - 'Rakefile'
156
+ - 'lib/evertils/common/authentication.rb'
157
+
158
+ # Offense count: 3
159
+ # Cop supports --auto-correct.
160
+ # Configuration parameters: MaxLineLength.
161
+ Style/IfUnlessModifier:
162
+ Exclude:
163
+ - 'Rakefile'
164
+ - 'lib/evertils/common/authentication.rb'
165
+
166
+ # Offense count: 2
167
+ # Cop supports --auto-correct.
168
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
169
+ # SupportedStyles: normal, rails
170
+ Style/IndentationConsistency:
171
+ Exclude:
172
+ - 'lib/evertils/common/converter/yaml_to_enml.rb'
173
+
174
+ # Offense count: 1
175
+ # Cop supports --auto-correct.
176
+ Style/LeadingCommentSpace:
177
+ Exclude:
178
+ - 'test/test_notes.rb'
179
+
180
+ # Offense count: 3
181
+ # Cop supports --auto-correct.
182
+ Style/MethodCallParentheses:
183
+ Exclude:
184
+ - 'lib/evertils/common/enml.rb'
185
+
186
+ # Offense count: 10
187
+ # Cop supports --auto-correct.
188
+ Style/NegatedIf:
189
+ Exclude:
190
+ - 'lib/evertils/common/enml.rb'
191
+ - 'lib/evertils/common/entity/note.rb'
192
+ - 'lib/evertils/common/entity/notebook.rb'
193
+ - 'lib/evertils/common/entity/notebooks.rb'
194
+ - 'lib/evertils/common/entity/stack.rb'
195
+ - 'lib/evertils/common/query/time.rb'
196
+ - 'lib/evertils/test/base.rb'
197
+
198
+ # Offense count: 16
199
+ # Cop supports --auto-correct.
200
+ # Configuration parameters: EnforcedOctalStyle, SupportedOctalStyles.
201
+ # SupportedOctalStyles: zero_with_o, zero_only
202
+ Style/NumericLiteralPrefix:
203
+ Exclude:
204
+ - 'test/test_notes.rb'
205
+ - 'test/test_time_queries.rb'
206
+
207
+ # Offense count: 1
208
+ # Cop supports --auto-correct.
209
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
210
+ # SupportedStyles: predicate, comparison
211
+ Style/NumericPredicate:
212
+ Exclude:
213
+ - 'lib/evertils/common/entity/notes.rb'
214
+
215
+ # Offense count: 1
216
+ # Cop supports --auto-correct.
217
+ # Configuration parameters: PreferredDelimiters.
218
+ Style/PercentLiteralDelimiters:
219
+ Exclude:
220
+ - 'evertils-common.gemspec'
221
+
222
+ # Offense count: 1
223
+ # Cop supports --auto-correct.
224
+ Style/PerlBackrefs:
225
+ Exclude:
226
+ - 'lib/evertils/common/kernel.rb'
227
+
228
+ # Offense count: 3
229
+ # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
230
+ # NamePrefix: is_, has_, have_
231
+ # NamePrefixBlacklist: is_, has_, have_
232
+ # NameWhitelist: is_a?
233
+ Style/PredicateName:
234
+ Exclude:
235
+ - 'spec/**/*'
236
+ - 'lib/evertils/common.rb'
237
+ - 'lib/evertils/common/generic.rb'
238
+ - 'lib/evertils/test.rb'
239
+
240
+ # Offense count: 7
241
+ # Cop supports --auto-correct.
242
+ Style/RedundantBegin:
243
+ Exclude:
244
+ - 'lib/evertils/common/authentication.rb'
245
+ - 'lib/evertils/common/entity/note.rb'
246
+ - 'lib/evertils/common/entity/notebooks.rb'
247
+ - 'lib/evertils/common/entity/stack.rb'
248
+ - 'lib/evertils/common/query/simple.rb'
249
+
250
+ # Offense count: 1
251
+ # Cop supports --auto-correct.
252
+ Style/RedundantSelf:
253
+ Exclude:
254
+ - 'lib/evertils/common/kernel.rb'
255
+
256
+ # Offense count: 3
257
+ # Cop supports --auto-correct.
258
+ # Configuration parameters: AllowForAlignment.
259
+ Style/SpaceAroundOperators:
260
+ Exclude:
261
+ - 'Rakefile'
262
+ - 'lib/evertils/common/authentication.rb'
263
+ - 'lib/evertils/test/base.rb'
264
+
265
+ # Offense count: 114
266
+ # Cop supports --auto-correct.
267
+ # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
268
+ # SupportedStyles: single_quotes, double_quotes
269
+ Style/StringLiterals:
270
+ Enabled: false
271
+
272
+ # Offense count: 2
273
+ # Cop supports --auto-correct.
274
+ # Configuration parameters: IgnoredMethods.
275
+ # IgnoredMethods: respond_to, define_method
276
+ Style/SymbolProc:
277
+ Exclude:
278
+ - 'lib/evertils/common/converter/yaml_to_enml.rb'
279
+ - 'lib/evertils/common/enml.rb'
280
+
281
+ # Offense count: 32
282
+ # Cop supports --auto-correct.
283
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
284
+ # SupportedStyles: final_newline, final_blank_line
285
+ Style/TrailingBlankLines:
286
+ Enabled: false
287
+
288
+ # Offense count: 1
289
+ # Cop supports --auto-correct.
290
+ # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
291
+ # SupportedStyles: comma, consistent_comma, no_comma
292
+ Style/TrailingCommaInLiteral:
293
+ Exclude:
294
+ - 'lib/evertils/common/authentication.rb'
295
+
296
+ # Offense count: 1
297
+ # Cop supports --auto-correct.
298
+ Style/TrailingWhitespace:
299
+ Exclude:
300
+ - 'lib/evertils/common/converter/yaml_to_enml.rb'
301
+
302
+ # Offense count: 2
303
+ # Cop supports --auto-correct.
304
+ Style/UnneededPercentQ:
305
+ Exclude:
306
+ - 'evertils-common.gemspec'
307
+
308
+ # Offense count: 8
309
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
310
+ # SupportedStyles: snake_case, camelCase
311
+ Style/VariableName:
312
+ Exclude:
313
+ - 'lib/evertils/common/authentication.rb'
314
+
315
+ # Offense count: 5
316
+ # Cop supports --auto-correct.
317
+ Style/ZeroLengthPredicate:
318
+ Exclude:
319
+ - 'lib/evertils/common/authentication.rb'
320
+ - 'lib/evertils/test/base.rb'
data/Rakefile CHANGED
@@ -18,6 +18,7 @@ task :cleanup do
18
18
  end
19
19
  end
20
20
 
21
+
21
22
  # hack from
22
23
  # http://stackoverflow.com/questions/1689504/how-do-i-make-a-rake-task-run-after-all-other-tasks-i-e-a-rake-afterbuild-tas
23
24
  current_tasks = Rake.application.top_level_tasks
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_runtime_dependency 'mime-types'
25
25
  spec.add_runtime_dependency "evernote-thrift"
26
- spec.add_runtime_dependency "notifaction"
26
+ spec.add_runtime_dependency "notifaction", "~> 0.4.3"
27
27
  end
@@ -4,6 +4,8 @@ require 'yaml'
4
4
  require 'mime/types'
5
5
  require 'date'
6
6
 
7
+ require 'evertils/common/kernel'
8
+ require 'evertils/common/generic'
7
9
  require 'evertils/common/enml'
8
10
  require 'evertils/common/entity'
9
11
  require 'evertils/common/query'
@@ -2,7 +2,7 @@ require 'singleton'
2
2
 
3
3
  module Evertils
4
4
  module Common
5
- class Authentication
5
+ class Authentication < Common::Generic
6
6
  include Singleton
7
7
 
8
8
  def initialize
@@ -16,6 +16,8 @@ module Evertils
16
16
 
17
17
  # prepare the main data model access point
18
18
  prepare_note_store
19
+ rescue Evernote::EDAM::Error::EDAMUserException => e
20
+ handle_edam_errors(e)
19
21
  rescue Evernote::EDAM::Error::EDAMSystemException => e
20
22
  handle_edam_errors(e)
21
23
  end
@@ -36,9 +38,10 @@ module Evertils
36
38
  else
37
39
  @noteStore.method(func.to_s).call(Evertils.token)
38
40
  end
41
+ rescue Evernote::EDAM::Error::EDAMUserException => e
42
+ handle_edam_errors(e)
39
43
  rescue Evernote::EDAM::Error::EDAMSystemException => e
40
- Notify.warning e.inspect
41
- nil
44
+ handle_edam_errors(e)
42
45
  end
43
46
  end
44
47
 
@@ -49,9 +52,10 @@ module Evertils
49
52
  else
50
53
  @userStore.method(func.to_s).call
51
54
  end
55
+ rescue Evernote::EDAM::Error::EDAMUserException => e
56
+ handle_edam_errors(e)
52
57
  rescue Evernote::EDAM::Error::EDAMSystemException => e
53
- Notify.warning e.inspect
54
- nil
58
+ handle_edam_errors(e)
55
59
  end
56
60
  end
57
61
 
@@ -64,6 +68,10 @@ module Evertils
64
68
  userStoreProtocol = Thrift::BinaryProtocol.new(userStoreTransport)
65
69
  @userStore = ::Evernote::EDAM::UserStore::UserStore::Client.new(userStoreProtocol)
66
70
  @user = call_user(:getUser, Evertils.token)
71
+ @major_ver = ::Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR
72
+ @minor_ver = ::Evernote::EDAM::UserStore::EDAM_VERSION_MINOR
73
+
74
+ @version = "#{@major_ver}.#{@minor_ver}"
67
75
 
68
76
  if Evertils.is_test?
69
77
  Notify.spit "TEST USER: #{info[:user]}"
@@ -79,16 +87,14 @@ module Evertils
79
87
  end
80
88
 
81
89
  def requires_update
82
- #entity = @userStore.checkVersion("evernote-data", ::Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, ::Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
83
- entity = call_user(:checkVersion, "evernote-data", ::Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR, ::Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
84
-
85
- @version = "#{::Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR}.#{::Evernote::EDAM::UserStore::EDAM_VERSION_MINOR}"
86
-
87
- !entity
90
+ !call_user(:checkVersion, "evernote-data", @major_ver, @minor_ver)
88
91
  end
89
92
 
93
+ private
94
+
90
95
  def handle_edam_errors(e)
91
96
  Notify.warning("Problem authenticating, EDAM code #{e.errorCode}")
97
+ Notify.warning("Type: #{e.class}")
92
98
 
93
99
  case e.errorCode
94
100
  when 1
@@ -131,11 +137,10 @@ module Evertils
131
137
  minutes = (e.rateLimitDuration/60).to_i
132
138
  message = "You are rate limited! Wait #{minutes} minutes"
133
139
  end
134
-
140
+
135
141
  Notify.warning(message)
136
142
  exit(0)
137
143
  end
138
-
139
144
  end
140
145
  end
141
146
  end