log4ever 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MzUxNDFhYjU1YTcyYWZlMjhkYzM0ZjY1MWE4ODkzODgwMTA2MzcyOA==
5
- data.tar.gz: !binary |-
6
- NzE2OGU2NjFmZDhmMGQ0MDE4MzkzMWJiM2I2ODFhODYxMzY3Y2RhNQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- OWQ0NzI2Nzk4ODk4MzcwNjNhNGVmZjcwYzU3MGJjNjdjNDg4NTJhYTg1NTJj
10
- YzViNTQ0MTU4NjNiMGU3ZjFjNGYzNzZhNTJmMjhlYTYyMDg5YjNjZDBiZjA0
11
- M2I1ZjkxMWRiNzEzNTFmNzQzMTY4ZmQ3ZGY4YzQ4MDhhODNjYjQ=
12
- data.tar.gz: !binary |-
13
- YjI2NzMzYmZiM2VjYmIxZDczY2NlYjI5OWU0NTMyNmFkNWI5ZWNmMDg2NDU3
14
- MDc3NTNiODhlNTE0YmUyNDNmOTgwNjk4ODZjZWZlMzIzYTc3YWViYjBkYzdi
15
- MzBiY2VjMmMzMWNkYjZjZGU5YmUzNzY4YTdlOGU2MjllNGNiYTQ=
2
+ SHA1:
3
+ metadata.gz: 8875273e847f20359d003311d9db05446cc29edf
4
+ data.tar.gz: b467ce75804859526aa28efdebb006f107e8a148
5
+ SHA512:
6
+ metadata.gz: ac9133e8cac593f1238eb74927921741e4a51675221dc0de1cef44a13c0cf3fbd3c37bf6d307af16238e783474aedac112213d2ff4aa50d7cdd076a5c3c0c5dc
7
+ data.tar.gz: 81c33ff7df80e54bae18ff4cf7e7220ac2c404f7b98d0bdda8186ba0b7271a196901a3d4b35524f4559ff6d5399e8cae428c239cac6051f3f5541a048cf39cc0
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
  gem 'log4r'
3
- gem 'active_support'
3
+ gem 'activesupport'
4
4
  gem 'i18n'
5
5
  gem 'nokogiri'
6
6
  gem 'evernote_oauth'
data/Gemfile.lock CHANGED
@@ -1,23 +1,34 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- active_support (3.0.0)
5
- activesupport (= 3.0.0)
6
- activesupport (3.0.0)
7
- evernote-thrift (1.25.0)
8
- evernote_oauth (0.2.1)
4
+ activesupport (4.0.4)
5
+ i18n (~> 0.6, >= 0.6.9)
6
+ minitest (~> 4.2)
7
+ multi_json (~> 1.3)
8
+ thread_safe (~> 0.1)
9
+ tzinfo (~> 0.3.37)
10
+ atomic (1.1.16)
11
+ evernote-thrift (1.25.1)
12
+ evernote_oauth (0.2.3)
9
13
  evernote-thrift
10
14
  oauth (>= 0.4.1)
11
- i18n (0.6.0)
15
+ i18n (0.6.9)
12
16
  log4r (1.1.10)
13
- nokogiri (1.5.5)
17
+ mini_portile (0.5.2)
18
+ minitest (4.7.5)
19
+ multi_json (1.9.2)
20
+ nokogiri (1.6.1)
21
+ mini_portile (~> 0.5.0)
14
22
  oauth (0.4.7)
23
+ thread_safe (0.2.0)
24
+ atomic (>= 1.1.7, < 2)
25
+ tzinfo (0.3.39)
15
26
 
16
27
  PLATFORMS
17
28
  ruby
18
29
 
19
30
  DEPENDENCIES
20
- active_support
31
+ activesupport
21
32
  evernote_oauth
22
33
  i18n
23
34
  log4r
data/README.md CHANGED
@@ -35,7 +35,7 @@ Output:
35
35
 
36
36
  2012-08-06 21:12:31 Evernote[INFO]: log output
37
37
 
38
- The output results are stored in Evernote.
38
+ The output results are stored in Evernote.
39
39
 
40
40
  ###ChangeLog
41
41
  * 0.0.1
@@ -62,6 +62,8 @@ Change the parameter of EvetnoteOutputter class, use evernote_oauth.
62
62
  Performance improvement.
63
63
  * 0.1.2
64
64
  Bug fix.
65
+ * 0.1.3
66
+ Ruby2.0.0 support. Bug fix.
65
67
 
66
68
  ##License
67
69
  Licensed under the MIT
@@ -3,63 +3,72 @@ require 'log4r/outputter/evernoteoutputter'
3
3
  require 'evernote_oauth'
4
4
 
5
5
  module Log4ever
6
- VERSION = '0.1.2'
7
- class TypeError < StandardError; end
6
+ VERSION = '0.1.3'
7
+
8
+ class EvernoteError < StandardError; end
9
+
8
10
  module ShiftAge
9
11
  DAILY = 1
10
12
  WEEKLY = 2
11
13
  MONTHLY = 3
12
14
  end
13
15
 
16
+ class EvernoteAuth
17
+ attr_reader :auth_token
18
+ attr_reader :note_store
19
+
20
+ def initialize(auth_token, is_sandbox = false)
21
+ @auth_token = auth_token
22
+ @note_store = EvernoteOAuth::Client.new({
23
+ :token => auth_token,
24
+ :sandbox => is_sandbox
25
+ }).note_store
26
+ end
27
+ end
28
+
14
29
  class Evernote
15
- @@note_store = nil
16
-
30
+ @@auth_store = nil
31
+
32
+ # Execute authentication to evernote
17
33
  def initialize(auth_token, is_sandbox = false)
18
- if @@note_store.nil?
19
- @@auth_token = auth_token
20
- @@note_store = EvernoteOAuth::Client.new({
21
- :token => auth_token,
22
- :sandbox => is_sandbox
23
- }).note_store
34
+ if @@auth_store.nil?
35
+ @@auth_store = EvernoteAuth.new(auth_token, is_sandbox)
24
36
  end
25
37
  end
26
38
 
27
39
  # get registered notebook or create new notebook
28
40
  # search the notebook under the stack if stack_name specific
29
41
  def notebook
30
- Notebook.new
42
+ Notebook.new(@@auth_store)
31
43
  end
32
44
 
33
45
  # get registered note or create new note
34
46
  def note(notebook)
35
- Note.new(notebook)
47
+ Note.new(notebook, @@auth_store)
36
48
  end
37
49
 
50
+ # get registered tag or create new tag
38
51
  def tag(note)
39
- Tag.new(note)
52
+ Tag.new(note, @@auth_store)
40
53
  end
54
+ end
41
55
 
42
- # encode for evernote internal charset
43
- def to_ascii(str)
44
- str.force_encoding("ASCII-8BIT") unless str.nil?
56
+ class Notebook
57
+ # constructor
58
+ def initialize(auth_store)
59
+ @auth_store = auth_store
45
60
  end
46
- end
47
61
 
48
- class Notebook < Evernote
49
- def initialize; end
50
-
51
62
  # get notebook
52
63
  def get(notebook_name, stack_name = nil)
53
64
  # return cache if same notebook and stack
54
65
  return @notebook if @notebook_name == notebook_name && @stack_name == stack_name
55
66
  # get notebook list from evernote
56
- @notebooks = @@note_store.listNotebooks(@@auth_token) if @notebooks.nil?
57
- @notebook = nil
67
+ @notebooks = @auth_store.note_store.listNotebooks(@auth_store.auth_token) if @notebooks.nil?
68
+ @notebook = nil
58
69
  @notebook_name = notebook_name
59
70
  @stack_name = stack_name
60
71
  @notebooks.each do |notebook|
61
- notebook_name = to_ascii(notebook_name)
62
- stack_name = to_ascii(stack_name)
63
72
  if notebook.name == notebook_name && notebook.stack == stack_name
64
73
  Log4r::Logger.log_internal { "Get notebook: #{stack_name}/#{notebook_name}" }
65
74
  @notebook = notebook
@@ -76,57 +85,58 @@ module Log4ever
76
85
  clear
77
86
  get(notebook_name, stack_name)
78
87
  end
79
-
88
+
80
89
  # create notebook
81
90
  def create(notebook_name, stack_name = nil)
82
91
  notebook = ::Evernote::EDAM::Type::Notebook.new
83
92
  notebook.name = notebook_name
84
93
  notebook.stack = stack_name
85
94
  begin
86
- @notebook = @@note_store.createNotebook(@@auth_token, notebook)
95
+ @notebook = @auth_store.note_store.createNotebook(@auth_store.auth_token, notebook)
87
96
  Log4r::Logger.log_internal { "Create notebook: #{stack_name}/#{notebook_name}" }
88
97
  @notebook
89
98
  rescue => e
90
99
  Log4r::Logger.log_internal { e.message }
91
- nil
100
+ raise EvernoteError, "Create notebook failed. Probably, already exists notebook of same name." if @notebook.nil?
92
101
  end
93
102
  end
94
-
103
+
95
104
  # notebook guid
96
105
  def guid; @notebook.guid end
97
106
 
98
107
  # clear notebook object
99
108
  def clear
100
- @notebooks = @@note_store.listNotebooks(@@auth_token)
109
+ @notebooks = @auth_store.note_store.listNotebooks(@auth_store.auth_token)
101
110
  @notebook = nil
102
111
  end
103
112
  end
104
113
 
105
- class Note < Evernote
114
+ class Note
106
115
  XML_TEMPLATE_BYTE = 237
107
-
108
- def initialize(notebook)
116
+
117
+ def initialize(notebook, auth_store)
109
118
  return unless @params.nil? || @params.empty?
110
119
  @params = {}
120
+ @auth_store = auth_store
111
121
  @notebook = notebook
112
122
  if !@notebook.kind_of? ::Evernote::EDAM::Type::Notebook
113
- raise TypeError, "Expected kind of Notebook, got #{@notebook.class}", caller
123
+ raise EvernoteError, "Expected kind of Notebook, got #{@notebook.class}", caller
114
124
  elsif !@notebook.respond_to? 'guid'
115
125
  raise NoMethodError, "#{@notebook.class} do not has method: guid", caller
116
126
  end
117
127
  end
118
-
128
+
119
129
  # content size
120
130
  def size
121
131
  content.bytesize > 0 ? content.bytesize - XML_TEMPLATE_BYTE : 0
122
132
  end
123
-
133
+
124
134
  # note guid
125
135
  def guid; @note.guid end
126
136
 
127
137
  # set new title
128
138
  def title=(str)
129
- @params[:title] = to_ascii(str)
139
+ @params[:title] = str
130
140
  end
131
141
 
132
142
  # get tag's guid list
@@ -141,28 +151,28 @@ module Log4ever
141
151
 
142
152
  # append content
143
153
  def addContent(text)
144
- new_html = "<div style='font-family: Courier New'>#{text}</div>"
154
+ new_html = "<div style='font-family: Courier New'>" + text + "</div>"
145
155
  content_xml.at('en-note').inner_html += new_html
146
- @params[:content] = @content_ = to_ascii(content_xml.to_xml)
156
+ @params[:content] = @content_ = content_xml.to_xml
147
157
  end
148
-
158
+
149
159
  # set new content
150
160
  def content=(text)
151
- @params[:content] = @content_ = to_ascii("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
161
+ @params[:content] = @content_ = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
152
162
  "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n" +
153
163
  "<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">\n" +
154
- "<div style=\"font-family: Courier New\">#{text}</div></en-note>")
155
- end
164
+ "<div style=\"font-family: Courier New\">" + text + "</div></en-note>"
165
+ end
156
166
 
157
167
  # create note
158
168
  def create
159
- @@note_store.createNote(@@auth_token, createNote)
169
+ @auth_store.note_store.createNote(@auth_store.auth_token, createNote)
160
170
  clear
161
171
  end
162
172
 
163
173
  # update note
164
174
  def update
165
- @@note_store.updateNote(@@auth_token, updateNote)
175
+ @auth_store.note_store.updateNote(@auth_store.auth_token, updateNote)
166
176
  end
167
177
 
168
178
  # clear note object
@@ -171,7 +181,7 @@ module Log4ever
171
181
  @note = @content_ = @content_xml = nil
172
182
  initialize(@notebook)
173
183
  end
174
-
184
+
175
185
  # get latest note object
176
186
  def get
177
187
  return @note unless @note.nil?
@@ -180,11 +190,11 @@ module Log4ever
180
190
  filter.notebookGuid = @notebook.guid
181
191
  filter.timeZone = "Asia/Tokyo"
182
192
  filter.ascending = false # descending
183
- note_list = @@note_store.findNotes(@@auth_token, filter, 0, 1)
193
+ note_list = @auth_store.note_store.findNotes(@auth_store.auth_token, filter, 0, 1)
184
194
  if note_list.notes.empty?
185
195
  Log4r::Logger.log_internal { "Note not found at #{@notebook.guid}" }
186
196
  @note = ::Evernote::EDAM::Type::Note.new
187
- else
197
+ else
188
198
  @note = note_list.notes[0]
189
199
  end
190
200
  @note
@@ -195,7 +205,7 @@ module Log4ever
195
205
  clear
196
206
  get
197
207
  end
198
-
208
+
199
209
  # create note object
200
210
  def createNote
201
211
  @note = ::Evernote::EDAM::Type::Note.new
@@ -203,26 +213,26 @@ module Log4ever
203
213
  @params.each{|method, value| @note.send("#{method.to_s}=", value)}
204
214
  @note
205
215
  end
206
-
216
+
207
217
  # get note object
208
218
  def updateNote
209
219
  @note.nil? and get
210
220
  @note.content = @params[:content]
211
221
  @note
212
222
  end
213
-
214
- # get created time
223
+
224
+ # get created time
215
225
  def created_at
216
226
  time = get.created.to_s
217
227
  ut = time.slice(0, time.length - 3)
218
228
  Time.at(ut.to_f)
219
229
  end
220
-
230
+
221
231
  # get note content text
222
232
  def content
223
233
  return @content_ unless @content_.nil?
224
234
  @note.nil? and get
225
- @content_ = !@note.nil? && !@note.guid.nil? ? @@note_store.getNoteContent(@@auth_token, @note.guid) : ""
235
+ @content_ = !@note.nil? && !@note.guid.nil? ? @auth_store.note_store.getNoteContent(@auth_store.auth_token, @note.guid) : ""
226
236
  end
227
237
 
228
238
  # get note content xml object
@@ -237,9 +247,10 @@ module Log4ever
237
247
  end
238
248
  end
239
249
 
240
- class Tag < Evernote
241
- def initialize(note)
250
+ class Tag
251
+ def initialize(note, auth_store)
242
252
  @note = note
253
+ @auth_store = auth_store
243
254
  end
244
255
 
245
256
  # set tag list
@@ -253,7 +264,7 @@ module Log4ever
253
264
  return if @list.nil? || @list.empty?
254
265
  return @tag_guids unless @tag_guids.nil?
255
266
  @list = [@list] unless @list.kind_of?(Array)
256
- @tags = @@note_store.listTags(@@auth_token) if @tags.nil?
267
+ @tags = @auth_store.note_store.listTags(@auth_store.auth_token) if @tags.nil?
257
268
  @tag_guids = @list.map do |tag|
258
269
  tag_obj = to_obj(tag) || create(tag)
259
270
  tag_obj.guid
@@ -265,7 +276,7 @@ module Log4ever
265
276
  clear
266
277
  get
267
278
  end
268
-
279
+
269
280
  # clear note object
270
281
  def clear
271
282
  @tags = nil
@@ -277,14 +288,14 @@ module Log4ever
277
288
  def create(tag_name)
278
289
  tag = ::Evernote::EDAM::Type::Tag.new
279
290
  tag.name = tag_name
280
- tag_obj = @@note_store.createTag(@@auth_token, tag)
291
+ tag_obj = @auth_store.note_store.createTag(@auth_store.auth_token, tag)
281
292
  Log4r::Logger.log_internal { "Create tag: #{tag_name}" }
282
293
  tag_obj
283
294
  end
284
295
 
285
296
  # tag name to tag object
286
297
  def to_obj(tag_name)
287
- tag_name = to_ascii(tag_name)
298
+ tag_name = tag_name
288
299
  @tags.each do |tag|
289
300
  if tag_name == tag.name
290
301
  Log4r::Logger.log_internal { "Get tag: #{tag_name}" }
@@ -5,6 +5,7 @@ require "log4r/staticlogger"
5
5
  require 'active_support'
6
6
  require 'active_support/time'
7
7
  require 'active_support/core_ext'
8
+ require 'nkf'
8
9
 
9
10
  module Log4r
10
11
  class EvernoteOutputter < Outputter
@@ -13,7 +14,7 @@ module Log4r
13
14
  super(_name, hash)
14
15
  validate(hash)
15
16
  end
16
-
17
+
17
18
  # synchronize note
18
19
  def sync
19
20
  @note = @evernote.note(@notebook)
@@ -29,11 +30,11 @@ module Log4r
29
30
  raise ArgumentError, "Sandbox must be type of boolean" unless is_sandbox == false || is_sandbox == true
30
31
  @auth_token = hash[:auth_token] || hash['auth_token'] || ""
31
32
  raise ArgumentError, "Must specify from auth token" if @auth_token.empty?
32
- notebook_name = hash[:notebook] || hash['notebook'] || ""
33
+ notebook_name = to_utf8(hash[:notebook] || hash['notebook'] || "")
33
34
  raise ArgumentError, "Must specify from notebook" if notebook_name.empty?
34
- stack_name = hash[:stack] || hash['stack']
35
+ stack_name = to_utf8(hash[:stack] || hash['stack'])
35
36
  @evernote = Log4ever::Evernote.new(@auth_token, is_sandbox)
36
- @tags = hash[:tags] || hash['tags'] || []
37
+ @tags = to_utf8(hash[:tags] || hash['tags'] || [])
37
38
  notebook = @evernote.notebook
38
39
  @notebook = notebook.get(notebook_name, stack_name)
39
40
  @hash = hash
@@ -56,21 +57,21 @@ module Log4r
56
57
  # write log to note
57
58
  def create_log(content)
58
59
  @note.clear
59
- @note.title = @name + " - " + Time.now.strftime("%Y-%m-%d %H:%M:%S")
60
+ @note.title = to_utf8(@name) + " - " + Time.now.strftime("%Y-%m-%d %H:%M:%S")
60
61
  @note.tags = @tag.get
61
- @note.content = content
62
+ @note.content = to_utf8(content)
62
63
  @note.create
63
64
  Logger.log_internal { "Create note: #{@note.guid}" }
64
65
  end
65
-
66
+
66
67
  # update log in note
67
68
  def update_log(content)
68
- @note.addContent(content)
69
+ @note.addContent(to_utf8(content))
69
70
  @note.tags = @tag.get
70
71
  @note.update
71
72
  Logger.log_internal { "Update note: #{@note.guid}" }
72
73
  end
73
-
74
+
74
75
  # more expensive, only for startup
75
76
  def note_size_requires_roll?
76
77
  @note.size == 0 || (@maxsize > 0 && @note.size >= @maxsize)
@@ -81,13 +82,13 @@ module Log4r
81
82
  !@endTime.nil? && Time.now.to_i >= @endTime
82
83
  end
83
84
 
84
- # diff note's tag and register tag
85
+ # diff note's tag and register tag
85
86
  def different_tag?
86
87
  note_tags = @note.tags || []
87
88
  tag = @tag.get || []
88
89
  (note_tags - tag).size != 0 || (tag - note_tags).size != 0
89
90
  end
90
-
91
+
91
92
  # max amount of log in note
92
93
  def set_maxsize(options)
93
94
  if options.has_key?(:maxsize) || options.has_key?('maxsize')
@@ -115,7 +116,7 @@ module Log4r
115
116
  @maxsize = 0
116
117
  end
117
118
  end
118
-
119
+
119
120
  # rolling interval
120
121
  def set_shift_age(options)
121
122
  if options.has_key?(:shift_age) || options.has_key?('shift_age')
@@ -145,5 +146,17 @@ module Log4r
145
146
  end
146
147
  end
147
148
  end
149
+
150
+ # encode for evernote internal charset
151
+ # convert character encoding to UTF-8 from Shift_JIS or EUC-JP
152
+ def to_utf8(mixed)
153
+ if mixed.kind_of? Array
154
+ mixed.each {|elem| to_utf8(elem)}
155
+ else mixed.kind_of? String
156
+ charset = NKF.guess(mixed).name
157
+ charset == "UTF-8" ? mixed : mixed.encode!("UTF-8", charset)
158
+ end
159
+ mixed
160
+ end
148
161
  end
149
162
  end
data/log4ever.gemspec CHANGED
@@ -11,9 +11,10 @@ Gem::Specification.new do |gem|
11
11
  gem.name = "log4ever"
12
12
  gem.require_paths = ["lib"]
13
13
  gem.add_dependency('log4r', '>= 1.1.10')
14
- gem.add_dependency('active_support', '>= 3.0.0')
15
- gem.add_dependency('i18n', '>= 0.6.0')
16
- gem.add_dependency('evernote_oauth', '>= 0.2.1')
17
- gem.version = '0.1.2'
14
+ gem.add_dependency('activesupport', '>= 4.0.4')
15
+ gem.add_dependency('i18n', '>= 0.6.9')
16
+ gem.add_dependency('evernote_oauth', '>= 0.2.3')
17
+ gem.version = '0.1.3'
18
+ gem.license = 'MIT'
18
19
  end
19
20
 
@@ -7,7 +7,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec/spec_helper')
7
7
 
8
8
  describe Log4ever, 'が実行する処理' do
9
9
  LOGGER_NAME = 'Log4ever'
10
-
10
+
11
11
  before do
12
12
  @formatter = Log4r::PatternFormatter.new(
13
13
  :pattern => "%d %C[%l]: %M ",
@@ -37,7 +37,6 @@ describe Log4ever, 'が実行する処理' do
37
37
  describe 'Log4rのEvernote書き出し処理' do
38
38
  it '書き出しが成功すること' do
39
39
  log_content = "aaa"
40
- formatter_content = "\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s.*?\[.*?\]:\s(.*)\\n"
41
40
  @params[:maxsize] = 1
42
41
  logger.outputters = evernoteOutputter
43
42
  logger.debug(log_content)
@@ -53,7 +52,7 @@ describe Log4ever, 'が実行する処理' do
53
52
  end
54
53
  end
55
54
  end
56
-
55
+
57
56
  describe 'Log4rの初期化処理(正常系)' do
58
57
  it 'パラメータのチェックでエラーが出ないこと' do
59
58
  logger.outputters = Log4r::EvernoteOutputter.new(LOGGER_NAME, @params)
@@ -125,21 +124,24 @@ describe Log4ever, 'が実行する処理' do
125
124
  end
126
125
 
127
126
  it '存在するノートブックと同名のノートブックは作成できないこと' do
128
- @evernote = Log4ever::Evernote.new(@params[:auth_token])
129
- @notebook = @evernote.notebook
130
- notebook_obj = @notebook.create(@params[:notebook], @params[:stack])
131
- notebook_obj.should be_nil
127
+ proc {
128
+ @evernote = Log4ever::Evernote.new(@params[:auth_token])
129
+ @notebook = @evernote.notebook
130
+ notebook_obj = @notebook.create(@params[:notebook], @params[:stack])
131
+ }.should raise_error()
132
132
  end
133
133
 
134
134
  it 'ノートブックの取得に失敗しかつ存在するノートブックと同名のノートブックが指定された場合、作成できないこと' do
135
- @evernote = Log4ever::Evernote.new(@params[:auth_token])
136
- @notebook = @evernote.notebook
137
- stack_name = Time.now.to_i.to_s
138
- notebook_obj = @notebook.create(@params[:notebook], stack_name)
139
- notebook_obj.should be_nil
135
+ proc {
136
+ @evernote = Log4ever::Evernote.new(@params[:auth_token])
137
+ @notebook = @evernote.notebook
138
+ stack_name = Time.now.to_i.to_s
139
+ notebook_obj = @notebook.create(@params[:notebook], stack_name)
140
+ notebook_obj.should be_nil
141
+ }.should raise_error()
140
142
  end
141
143
  end
142
-
144
+
143
145
  describe 'Log4everの処理' do
144
146
  it 'タグが存在しない場合、新規作成されること' do
145
147
  @params[:tags] = [Time.now.to_i.to_s]
@@ -210,5 +212,38 @@ describe Log4ever, 'が実行する処理' do
210
212
  }.should_not raise_error()
211
213
  end
212
214
 
215
+ it 'スタックにUTF-8以外の文字列を指定した時、エラーが発生しないこと' do
216
+ proc {
217
+ @params[:stack] = "\xA4\xA2\xA4\xA2\xA4\xA2"
218
+ @params[:notebook] = Time.now.to_i.to_s
219
+ logger.outputters = Log4r::EvernoteOutputter.new('evernote', @params)
220
+ logger.debug("test")
221
+ }.should_not raise_error()
222
+ end
223
+
224
+ it 'ノートブックにUTF-8以外の文字列を指定した時、エラーが発生しないこと' do
225
+ proc {
226
+ @params[:notebook] = "\xA4\xA2" + Time.now.to_i.to_s
227
+ logger.outputters = Log4r::EvernoteOutputter.new('evernote', @params)
228
+ logger.debug("test")
229
+ }.should_not raise_error()
230
+ end
231
+
232
+ it 'タグにUTF-8以外の文字列を指定した時、エラーが発生しないこと' do
233
+ proc {
234
+ @params[:tags] = ['Log', "\x82\xA0\x82\xA0", "\xA4\xA2"]
235
+ logger.outputters = Log4r::EvernoteOutputter.new('evernote', @params)
236
+ logger.debug("test")
237
+ }.should_not raise_error()
238
+ end
239
+
240
+ it 'ノートにUTF-8以外の文字列を指定した時、エラーが発生しないこと' do
241
+ proc {
242
+ logger = Log4r::Logger.new(LOGGER_NAME)
243
+ logger.outputters = Log4r::EvernoteOutputter.new('evernote', @params)
244
+ logger.debug("\x82\xA0") # Shift_JIS
245
+ logger.debug("\xA4\xA2") # EUC-JP
246
+ }.should_not raise_error()
247
+ end
213
248
  end
214
249
  end
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ module Log4ever
5
5
  def config_xml
6
6
  File.dirname(__FILE__) + "/../config/log4r.xml"
7
7
  end
8
-
8
+
9
9
  def evernote_auth
10
10
  path = File.dirname(__FILE__) + "/../config/evernote.auth.yml"
11
11
  YAML.load_file(path)["auth_token"]
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4ever
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - mapserver2007
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-22 00:00:00.000000000 Z
11
+ date: 2014-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: log4r
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.10
27
27
  - !ruby/object:Gem::Dependency
28
- name: active_support
28
+ name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.0
33
+ version: 4.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.0
40
+ version: 4.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: i18n
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.6.0
47
+ version: 0.6.9
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.6.0
54
+ version: 0.6.9
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: evernote_oauth
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.2.1
61
+ version: 0.2.3
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.2.1
68
+ version: 0.2.3
69
69
  description: log4ever is simple logger for evernote. It is available as an extension
70
70
  of log4r.
71
71
  email:
@@ -87,7 +87,8 @@ files:
87
87
  - spec/log4ever_spec.rb
88
88
  - spec/spec_helper.rb
89
89
  homepage: https://github.com/mapserver2007/log4ever
90
- licenses: []
90
+ licenses:
91
+ - MIT
91
92
  metadata: {}
92
93
  post_install_message:
93
94
  rdoc_options: []
@@ -95,17 +96,17 @@ require_paths:
95
96
  - lib
96
97
  required_ruby_version: !ruby/object:Gem::Requirement
97
98
  requirements:
98
- - - ! '>='
99
+ - - '>='
99
100
  - !ruby/object:Gem::Version
100
101
  version: '0'
101
102
  required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  requirements:
103
- - - ! '>='
104
+ - - '>='
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
108
  rubyforge_project:
108
- rubygems_version: 2.0.5
109
+ rubygems_version: 2.0.14
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: log4ever is simple logger for evernote.