log4ever 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +2 -1
- data/Rakefile +5 -0
- data/lib/log4r/evernote.rb +132 -73
- data/lib/log4r/outputter/evernoteoutputter.rb +17 -9
- data/log4ever.gemspec +1 -1
- data/spec/log4ever_spec.rb +95 -16
- metadata +5 -15
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
N2Q3NDZjNzIwZTc2Yjg5M2MwNjI4YTEwN2E0MDkzMzZkMmI5NmNhMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWY2MWRkOGU0M2FhMTE5OWNiN2ExNTBiZTY5OWU4ZDE1ZWY3ODQ3Ng==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MDMwNTdlYmM3NDc1ODI1ZWMzYWEyMjVjNmQ3ODRhNjFmMDQ2NWQyZGM1Yjk5
|
10
|
+
MjVmNDc3NTRiOWRiZjk1NWViY2JmZDk1YjIwZGQ1YTJjYWNhNGE2YzVkM2Fl
|
11
|
+
N2E2MzA0OTEwYzIxYjFmNGQ1NDAxMTk1N2U0NTlkNjI1YmNmMjA=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGI5M2Q2ZGQ5MjIyNGE4ZDFlYjgwMTk3OGM5MjYyYzVmMTI2NGEwMzE0Zjdm
|
14
|
+
NGNiMWNhNWIzOWY2NTgxNWE5ZWJiMTA4NGIwMmNhN2U4YTA4NTcyOTM5ZGZj
|
15
|
+
ZDgzZjYyOWM4Y2Y1ZGY3NDZlNDM0NDAzNjIzN2Q1NzcwYjIwMDg=
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/log4r/evernote.rb
CHANGED
@@ -3,21 +3,18 @@ require 'log4r/outputter/evernoteoutputter'
|
|
3
3
|
require 'evernote_oauth'
|
4
4
|
|
5
5
|
module Log4ever
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.1'
|
7
7
|
class TypeError < StandardError; end
|
8
8
|
module ShiftAge
|
9
9
|
DAILY = 1
|
10
10
|
WEEKLY = 2
|
11
11
|
MONTHLY = 3
|
12
12
|
end
|
13
|
-
end
|
14
13
|
|
15
|
-
|
16
|
-
include Log4ever
|
17
|
-
class MyEvernote
|
14
|
+
class Evernote
|
18
15
|
@@note_store = nil
|
19
16
|
|
20
|
-
def initialize(
|
17
|
+
def initialize(auth_token, is_sandbox = false)
|
21
18
|
if @@note_store.nil?
|
22
19
|
@@auth_token = auth_token
|
23
20
|
@@note_store = EvernoteOAuth::Client.new({
|
@@ -28,42 +25,18 @@ module Log4r
|
|
28
25
|
end
|
29
26
|
|
30
27
|
# get registered notebook or create new notebook
|
31
|
-
|
32
|
-
|
28
|
+
# search the notebook under the stack if stack_name specific
|
29
|
+
def notebook
|
30
|
+
Notebook.new
|
33
31
|
end
|
34
32
|
|
35
33
|
# get registered note or create new note
|
36
|
-
def
|
37
|
-
Note.new(
|
38
|
-
end
|
39
|
-
|
40
|
-
# get registerd tag list
|
41
|
-
def get_tags(tag_names)
|
42
|
-
tag_names.map do |tag_name|
|
43
|
-
get_tag(tag_name) || create_tag(tag_name)
|
44
|
-
end
|
34
|
+
def note(notebook)
|
35
|
+
Note.new(notebook)
|
45
36
|
end
|
46
37
|
|
47
|
-
|
48
|
-
|
49
|
-
return if tag_name.empty?
|
50
|
-
tag_name = to_ascii(tag_name)
|
51
|
-
@@note_store.listTags(@@auth_token).each do |tag|
|
52
|
-
if tag_name == tag.name
|
53
|
-
Logger.log_internal { "Get tag: #{tag_name}" }
|
54
|
-
return tag
|
55
|
-
end
|
56
|
-
end
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
|
60
|
-
# create tag object
|
61
|
-
def create_tag(tag_name)
|
62
|
-
tag = Evernote::EDAM::Type::Tag.new
|
63
|
-
tag.name = tag_name
|
64
|
-
tag_obj = @@note_store.createTag(@@auth_token, tag)
|
65
|
-
Logger.log_internal { "Create tag: #{tag_name}" }
|
66
|
-
tag_obj
|
38
|
+
def tag(note)
|
39
|
+
Tag.new(note)
|
67
40
|
end
|
68
41
|
|
69
42
|
# encode for evernote internal charset
|
@@ -72,39 +45,51 @@ module Log4r
|
|
72
45
|
end
|
73
46
|
end
|
74
47
|
|
75
|
-
class Notebook <
|
76
|
-
def initialize
|
77
|
-
return unless @notebook.nil?
|
78
|
-
@notebook_name = notebook_name
|
79
|
-
@stack_name = stack_name
|
80
|
-
get(notebook_name, stack_name) || create(notebook_name, stack_name)
|
81
|
-
end
|
82
|
-
|
83
|
-
# get notebook object
|
84
|
-
def getNotebookObject; @notebook end
|
48
|
+
class Notebook < Evernote
|
49
|
+
def initialize; end
|
85
50
|
|
86
51
|
# get notebook
|
87
|
-
def get(notebook_name, stack_name)
|
88
|
-
|
52
|
+
def get(notebook_name, stack_name = nil)
|
53
|
+
# return cache if same notebook and stack
|
54
|
+
return @notebook if @notebook_name == notebook_name && @stack_name == stack_name
|
55
|
+
# get notebook list from evernote
|
56
|
+
@notebooks = @@note_store.listNotebooks(@@auth_token) if @notebooks.nil?
|
57
|
+
@notebook = nil
|
58
|
+
@notebook_name = notebook_name
|
59
|
+
@stack_name = stack_name
|
60
|
+
@notebooks.each do |notebook|
|
89
61
|
notebook_name = to_ascii(notebook_name)
|
90
62
|
stack_name = to_ascii(stack_name)
|
91
63
|
if notebook.name == notebook_name && notebook.stack == stack_name
|
92
|
-
Logger.log_internal { "Get notebook: #{stack_name}/#{notebook_name}" }
|
64
|
+
Log4r::Logger.log_internal { "Get notebook: #{stack_name}/#{notebook_name}" }
|
93
65
|
@notebook = notebook
|
94
66
|
break
|
95
67
|
end
|
96
68
|
end
|
69
|
+
# create new notebook if notebook is nil
|
70
|
+
create(notebook_name, stack_name) if @notebook.nil?
|
97
71
|
@notebook
|
98
72
|
end
|
73
|
+
|
74
|
+
# get newest notebook
|
75
|
+
def get!(notebook_name, stack_name = nil)
|
76
|
+
clear
|
77
|
+
get(notebook_name, stack_name)
|
78
|
+
end
|
99
79
|
|
100
80
|
# create notebook
|
101
|
-
def create(notebook_name, stack_name)
|
102
|
-
notebook = Evernote::EDAM::Type::Notebook.new
|
81
|
+
def create(notebook_name, stack_name = nil)
|
82
|
+
notebook = ::Evernote::EDAM::Type::Notebook.new
|
103
83
|
notebook.name = notebook_name
|
104
84
|
notebook.stack = stack_name
|
105
|
-
|
106
|
-
|
107
|
-
|
85
|
+
begin
|
86
|
+
@notebook = @@note_store.createNotebook(@@auth_token, notebook)
|
87
|
+
Log4r::Logger.log_internal { "Create notebook: #{stack_name}/#{notebook_name}" }
|
88
|
+
@notebook
|
89
|
+
rescue => e
|
90
|
+
Log4r::Logger.log_internal { e.message }
|
91
|
+
nil
|
92
|
+
end
|
108
93
|
end
|
109
94
|
|
110
95
|
# notebook guid
|
@@ -112,29 +97,26 @@ module Log4r
|
|
112
97
|
|
113
98
|
# clear notebook object
|
114
99
|
def clear
|
100
|
+
@notebooks = @@note_store.listNotebooks(@@auth_token)
|
115
101
|
@notebook = nil
|
116
|
-
initialize(@notebook_name, @stack_name)
|
117
102
|
end
|
118
103
|
end
|
119
104
|
|
120
|
-
class Note <
|
105
|
+
class Note < Evernote
|
121
106
|
XML_TEMPLATE_BYTE = 237
|
122
107
|
|
123
108
|
def initialize(notebook)
|
124
109
|
return unless @params.nil? || @params.empty?
|
125
110
|
@params = {}
|
126
111
|
@notebook = notebook
|
127
|
-
|
128
|
-
|
112
|
+
#@tag = Tag.new
|
113
|
+
if !@notebook.kind_of? ::Evernote::EDAM::Type::Notebook
|
114
|
+
raise TypeError, "Expected kind of Notebook, got #{@notebook.class}", caller
|
129
115
|
elsif !@notebook.respond_to? 'guid'
|
130
|
-
raise NoMethodError,
|
116
|
+
raise NoMethodError, "#{@notebook.class} do not has method: guid", caller
|
131
117
|
end
|
132
|
-
getNote
|
133
118
|
end
|
134
119
|
|
135
|
-
# get note object
|
136
|
-
def getNoteObject; @note end
|
137
|
-
|
138
120
|
# content size
|
139
121
|
def size
|
140
122
|
content.bytesize > 0 ? content.bytesize - XML_TEMPLATE_BYTE : 0
|
@@ -148,9 +130,14 @@ module Log4r
|
|
148
130
|
@params[:title] = to_ascii(str)
|
149
131
|
end
|
150
132
|
|
133
|
+
# get tag's guid list
|
134
|
+
def tags
|
135
|
+
get.tagGuids
|
136
|
+
end
|
137
|
+
|
151
138
|
# set tags
|
152
|
-
def tags=(
|
153
|
-
@params[:tagGuids] =
|
139
|
+
def tags=(tagGuids)
|
140
|
+
@params[:tagGuids] = tagGuids
|
154
141
|
end
|
155
142
|
|
156
143
|
# append content
|
@@ -186,25 +173,33 @@ module Log4r
|
|
186
173
|
initialize(@notebook)
|
187
174
|
end
|
188
175
|
|
189
|
-
|
190
|
-
|
191
|
-
|
176
|
+
# get latest note object
|
177
|
+
def get
|
178
|
+
return @note unless @note.nil?
|
179
|
+
filter = ::Evernote::EDAM::NoteStore::NoteFilter.new
|
180
|
+
filter.order = ::Evernote::EDAM::Type::NoteSortOrder::CREATED
|
192
181
|
filter.notebookGuid = @notebook.guid
|
193
182
|
filter.timeZone = "Asia/Tokyo"
|
194
183
|
filter.ascending = false # descending
|
195
184
|
note_list = @@note_store.findNotes(@@auth_token, filter, 0, 1)
|
196
185
|
if note_list.notes.empty?
|
197
|
-
Logger.log_internal { "Note not found at #{@notebook.guid}" }
|
198
|
-
@note = Evernote::EDAM::Type::Note.new
|
186
|
+
Log4r::Logger.log_internal { "Note not found at #{@notebook.guid}" }
|
187
|
+
@note = ::Evernote::EDAM::Type::Note.new
|
199
188
|
else
|
200
189
|
@note = note_list.notes[0]
|
201
190
|
end
|
202
191
|
@note
|
203
192
|
end
|
193
|
+
|
194
|
+
# get latest note object(newest object)
|
195
|
+
def get!
|
196
|
+
clear
|
197
|
+
get
|
198
|
+
end
|
204
199
|
|
205
200
|
# create note object
|
206
201
|
def createNote
|
207
|
-
@note = Evernote::EDAM::Type::Note.new
|
202
|
+
@note = ::Evernote::EDAM::Type::Note.new
|
208
203
|
@note.notebookGuid = @notebook.guid
|
209
204
|
@params.each{|method, value| @note.send("#{method.to_s}=", value)}
|
210
205
|
@note
|
@@ -212,7 +207,7 @@ module Log4r
|
|
212
207
|
|
213
208
|
# get note object
|
214
209
|
def updateNote
|
215
|
-
|
210
|
+
@note.nil? and get
|
216
211
|
@note.content = @params[:content]
|
217
212
|
@note
|
218
213
|
end
|
@@ -227,6 +222,7 @@ module Log4r
|
|
227
222
|
# get note content text
|
228
223
|
def content
|
229
224
|
return @content_ unless @content_.nil?
|
225
|
+
@note.nil? and get
|
230
226
|
@content_ = !@note.nil? && !@note.guid.nil? ? @@note_store.getNoteContent(@@auth_token, @note.guid) : ""
|
231
227
|
end
|
232
228
|
|
@@ -235,5 +231,68 @@ module Log4r
|
|
235
231
|
return @content_xml unless @content_xml.nil?
|
236
232
|
@content_xml = Nokogiri::XML(content)
|
237
233
|
end
|
234
|
+
|
235
|
+
# clear note object
|
236
|
+
def clear
|
237
|
+
@note = nil
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
class Tag < Evernote
|
242
|
+
def initialize(note)
|
243
|
+
@note = note
|
244
|
+
end
|
245
|
+
|
246
|
+
# set tag list
|
247
|
+
def names=(list)
|
248
|
+
@list = list
|
249
|
+
@tag_guids = nil
|
250
|
+
end
|
251
|
+
|
252
|
+
# get tag objects
|
253
|
+
def get
|
254
|
+
return if @list.nil? || @list.empty?
|
255
|
+
return @tag_guids unless @tag_guids.nil?
|
256
|
+
@list = [@list] unless @list.kind_of?(Array)
|
257
|
+
@tags = @@note_store.listTags(@@auth_token) if @tags.nil?
|
258
|
+
@tag_guids = @list.map do |tag|
|
259
|
+
tag_obj = to_obj(tag) || create(tag)
|
260
|
+
tag_obj.guid
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# get newest tag objects
|
265
|
+
def get!
|
266
|
+
clear
|
267
|
+
get
|
268
|
+
end
|
269
|
+
|
270
|
+
# clear note object
|
271
|
+
def clear
|
272
|
+
@tags = nil
|
273
|
+
@tag_guids = nil
|
274
|
+
end
|
275
|
+
|
276
|
+
private
|
277
|
+
# create tag object
|
278
|
+
def create(tag_name)
|
279
|
+
tag = ::Evernote::EDAM::Type::Tag.new
|
280
|
+
tag.name = tag_name
|
281
|
+
tag_obj = @@note_store.createTag(@@auth_token, tag)
|
282
|
+
Log4r::Logger.log_internal { "Create tag: #{tag_name}" }
|
283
|
+
tag_obj
|
284
|
+
end
|
285
|
+
|
286
|
+
# tag name to tag object
|
287
|
+
def to_obj(tag_name)
|
288
|
+
tag_name = to_ascii(tag_name)
|
289
|
+
@tags.each do |tag|
|
290
|
+
if tag_name == tag.name
|
291
|
+
Log4r::Logger.log_internal { "Get tag: #{tag_name}" }
|
292
|
+
return tag
|
293
|
+
end
|
294
|
+
end
|
295
|
+
nil
|
296
|
+
end
|
238
297
|
end
|
239
298
|
end
|
@@ -16,7 +16,9 @@ module Log4r
|
|
16
16
|
|
17
17
|
# synchronize note
|
18
18
|
def sync
|
19
|
-
@note = @evernote.
|
19
|
+
@note = @evernote.note(@notebook)
|
20
|
+
@tag = @evernote.tag(@note)
|
21
|
+
@tag.names = @tags
|
20
22
|
set_maxsize(@hash) # for rolling
|
21
23
|
set_shift_age(@hash) # for rolling
|
22
24
|
end
|
@@ -30,10 +32,10 @@ module Log4r
|
|
30
32
|
notebook_name = hash[:notebook] || hash['notebook'] || ""
|
31
33
|
raise ArgumentError, "Must specify from notebook" if notebook_name.empty?
|
32
34
|
stack_name = hash[:stack] || hash['stack']
|
33
|
-
@evernote =
|
34
|
-
tags =
|
35
|
-
|
36
|
-
@notebook =
|
35
|
+
@evernote = Log4ever::Evernote.new(@auth_token, is_sandbox)
|
36
|
+
@tags = hash[:tags] || hash['tags'] || []
|
37
|
+
notebook = @evernote.notebook
|
38
|
+
@notebook = notebook.get(notebook_name, stack_name)
|
37
39
|
@hash = hash
|
38
40
|
sync
|
39
41
|
end
|
@@ -43,7 +45,7 @@ module Log4r
|
|
43
45
|
# write log
|
44
46
|
def write(content)
|
45
47
|
sync
|
46
|
-
if note_size_requires_roll? || time_requires_roll?
|
48
|
+
if note_size_requires_roll? || time_requires_roll? || different_tag?
|
47
49
|
create_log(content)
|
48
50
|
else
|
49
51
|
update_log(content)
|
@@ -55,7 +57,7 @@ module Log4r
|
|
55
57
|
def create_log(content)
|
56
58
|
@note.clear
|
57
59
|
@note.title = @name + " - " + Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
58
|
-
@note.tags = @
|
60
|
+
@note.tags = @tag.get
|
59
61
|
@note.content = content
|
60
62
|
@note.create
|
61
63
|
Logger.log_internal { "Create note: #{@note.guid}" }
|
@@ -64,7 +66,7 @@ module Log4r
|
|
64
66
|
# update log in note
|
65
67
|
def update_log(content)
|
66
68
|
@note.addContent(content)
|
67
|
-
@note.tags = @
|
69
|
+
@note.tags = @tag.get
|
68
70
|
@note.update
|
69
71
|
Logger.log_internal { "Update note: #{@note.guid}" }
|
70
72
|
end
|
@@ -78,6 +80,13 @@ module Log4r
|
|
78
80
|
def time_requires_roll?
|
79
81
|
!@endTime.nil? && Time.now.to_i >= @endTime
|
80
82
|
end
|
83
|
+
|
84
|
+
# diff note's tag and register tag
|
85
|
+
def different_tag?
|
86
|
+
note_tags = @note.tags || []
|
87
|
+
tag = @tag.get || []
|
88
|
+
(note_tags - tag).size != 0 || (tag - note_tags).size != 0
|
89
|
+
end
|
81
90
|
|
82
91
|
# max amount of log in note
|
83
92
|
def set_maxsize(options)
|
@@ -137,5 +146,4 @@ module Log4r
|
|
137
146
|
end
|
138
147
|
end
|
139
148
|
end
|
140
|
-
|
141
149
|
end
|
data/log4ever.gemspec
CHANGED
data/spec/log4ever_spec.rb
CHANGED
@@ -41,9 +41,10 @@ describe Log4ever, 'が実行する処理' do
|
|
41
41
|
@params[:maxsize] = 1
|
42
42
|
logger.outputters = evernoteOutputter
|
43
43
|
logger.debug(log_content)
|
44
|
-
@evernote =
|
45
|
-
@notebook = @evernote.
|
46
|
-
|
44
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
45
|
+
@notebook = @evernote.notebook
|
46
|
+
notebook_obj = @notebook.get(@params[:notebook], @params[:stack])
|
47
|
+
@note = @evernote.note(notebook_obj)
|
47
48
|
write_log = @note.content_xml.children[1].children.reverse[0].text
|
48
49
|
if /\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s.*?\[.*?\]:\s(.*)/ =~ write_log
|
49
50
|
log_content.should == $1.strip
|
@@ -65,7 +66,7 @@ describe Log4ever, 'が実行する処理' do
|
|
65
66
|
end
|
66
67
|
|
67
68
|
describe 'Log4rの初期化処理(異常系)' do
|
68
|
-
it "
|
69
|
+
it "sandboxパラメータのチェックでエラーが出ること" do
|
69
70
|
proc {
|
70
71
|
logger.outputters = Log4r::EvernoteOutputter.new(LOGGER_NAME, @params.merge(
|
71
72
|
:sandbox => "aaa"
|
@@ -89,35 +90,113 @@ describe Log4ever, 'が実行する処理' do
|
|
89
90
|
}.should raise_error(ArgumentError)
|
90
91
|
end
|
91
92
|
end
|
92
|
-
|
93
|
-
describe 'Log4ever
|
93
|
+
|
94
|
+
describe 'Log4everの内部の処理' do
|
94
95
|
it 'ノートブックが存在しない場合、ノートブックが新規作成されること' do
|
95
|
-
|
96
|
-
@evernote = Log4r::MyEvernote.new(@params[:env], @params[:auth_token])
|
96
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
97
97
|
notebook_name = Time.now.to_i.to_s
|
98
|
-
notebook = @evernote.
|
98
|
+
notebook = @evernote.notebook
|
99
99
|
obj = notebook.get(notebook_name, @params[:stack])
|
100
100
|
obj.name.should == notebook_name
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'ノートブックが存在しない場合、スタックが新規作成されること' do
|
104
|
-
|
105
|
-
@evernote = Log4r::MyEvernote.new(@params[:env], @params[:auth_token])
|
104
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
106
105
|
notebook_name = Time.now.to_i.to_s
|
107
|
-
notebook = @evernote.
|
106
|
+
notebook = @evernote.notebook
|
108
107
|
obj = notebook.get(notebook_name, @params[:stack])
|
109
108
|
obj.stack.should == @params[:stack]
|
110
109
|
end
|
110
|
+
|
111
|
+
it '指定したスタックオブジェクト(存在するスタック)を渡した場合、既存のスタックに属するノートブックが取得できること' do
|
112
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
113
|
+
@notebook = @evernote.notebook
|
114
|
+
notebook_obj = @notebook.get(@params[:notebook], @params[:stack])
|
115
|
+
notebook_obj.guid.should_not be_nil
|
116
|
+
end
|
117
|
+
|
118
|
+
it '指定したスタックオブジェクト(存在しないスタック)を渡した場合、スタックが新規作成されノートブックが取得できること' do
|
119
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
120
|
+
@notebook = @evernote.notebook
|
121
|
+
notebook_name = Time.now.to_i.to_s
|
122
|
+
stack_name = Time.now.to_i.to_s
|
123
|
+
notebook_obj = @notebook.get(notebook_name, stack_name)
|
124
|
+
notebook_obj.guid.should_not be_nil
|
125
|
+
end
|
126
|
+
|
127
|
+
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
|
132
|
+
end
|
133
|
+
|
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
|
140
|
+
end
|
141
|
+
end
|
111
142
|
|
143
|
+
describe 'Log4everの処理' do
|
112
144
|
it 'タグが存在しない場合、新規作成されること' do
|
113
145
|
@params[:tags] = [Time.now.to_i.to_s]
|
114
146
|
@params[:maxsize] = 1
|
115
147
|
logger.outputters = Log4r::EvernoteOutputter.new('evernote', @params)
|
116
148
|
logger.debug("test")
|
117
|
-
evernote =
|
118
|
-
notebook = evernote.
|
119
|
-
note = evernote.
|
120
|
-
note.
|
149
|
+
@evernote = Log4ever::Evernote.new(@params[:auth_token])
|
150
|
+
notebook = @evernote.notebook
|
151
|
+
note = @evernote.note(notebook.get(@params[:notebook], @params[:stack]))
|
152
|
+
note.get.tagGuids[0].should_not be_empty
|
153
|
+
end
|
154
|
+
|
155
|
+
it '更新対象のノートのタグが増えた場合、新規ノートが作成されること' do
|
156
|
+
logger = Log4r::Logger.new(LOGGER_NAME)
|
157
|
+
# タグ変更前
|
158
|
+
evernoteOutputter = Log4r::EvernoteOutputter.new('evernote', @params)
|
159
|
+
logger.outputters = evernoteOutputter
|
160
|
+
logger.info("test1")
|
161
|
+
evernote = Log4ever::Evernote.new(@params[:auth_token])
|
162
|
+
notebook = evernote.notebook
|
163
|
+
note = evernote.note(notebook.get(@params[:notebook], @params[:stack])).get
|
164
|
+
guid_before = note.guid
|
165
|
+
# タグ変更後
|
166
|
+
@params[:tags] << 'Log2'
|
167
|
+
evernoteOutputter = Log4r::EvernoteOutputter.new('evernote', @params)
|
168
|
+
logger.outputters = evernoteOutputter
|
169
|
+
logger.info("test1")
|
170
|
+
evernote = Log4ever::Evernote.new(@params[:auth_token])
|
171
|
+
notebook = evernote.notebook
|
172
|
+
note = evernote.note(notebook.get(@params[:notebook], @params[:stack])).get
|
173
|
+
guid_after = note.guid
|
174
|
+
|
175
|
+
guid_before.should_not == guid_after
|
176
|
+
end
|
177
|
+
|
178
|
+
it '更新対象のノートのタグが減った場合、新規ノートが作成されること' do
|
179
|
+
logger = Log4r::Logger.new(LOGGER_NAME)
|
180
|
+
# タグ変更前
|
181
|
+
@params[:tags] << 'Log2'
|
182
|
+
evernoteOutputter = Log4r::EvernoteOutputter.new('evernote', @params)
|
183
|
+
logger.outputters = evernoteOutputter
|
184
|
+
logger.info("test1")
|
185
|
+
evernote = Log4ever::Evernote.new(@params[:auth_token])
|
186
|
+
notebook = evernote.notebook
|
187
|
+
note = evernote.note(notebook.get(@params[:notebook], @params[:stack])).get
|
188
|
+
guid_before = note.guid
|
189
|
+
# タグ変更後
|
190
|
+
@params[:tags] = 'Log'
|
191
|
+
evernoteOutputter = Log4r::EvernoteOutputter.new('evernote', @params)
|
192
|
+
logger.outputters = evernoteOutputter
|
193
|
+
logger.info("test1")
|
194
|
+
evernote = Log4ever::Evernote.new(@params[:auth_token])
|
195
|
+
notebook = evernote.notebook
|
196
|
+
note = evernote.note(notebook.get(@params[:notebook], @params[:stack])).get
|
197
|
+
guid_after = note.guid
|
198
|
+
|
199
|
+
guid_before.should_not == guid_after
|
121
200
|
end
|
122
201
|
end
|
123
202
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log4ever
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- mapserver2007
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: log4r
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ! '>='
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ! '>='
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: active_support
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: i18n
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: evernote_oauth
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -97,27 +88,26 @@ files:
|
|
97
88
|
- spec/spec_helper.rb
|
98
89
|
homepage: https://github.com/mapserver2007/log4ever
|
99
90
|
licenses: []
|
91
|
+
metadata: {}
|
100
92
|
post_install_message:
|
101
93
|
rdoc_options: []
|
102
94
|
require_paths:
|
103
95
|
- lib
|
104
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
97
|
requirements:
|
107
98
|
- - ! '>='
|
108
99
|
- !ruby/object:Gem::Version
|
109
100
|
version: '0'
|
110
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
102
|
requirements:
|
113
103
|
- - ! '>='
|
114
104
|
- !ruby/object:Gem::Version
|
115
105
|
version: '0'
|
116
106
|
requirements: []
|
117
107
|
rubyforge_project:
|
118
|
-
rubygems_version:
|
108
|
+
rubygems_version: 2.0.5
|
119
109
|
signing_key:
|
120
|
-
specification_version:
|
110
|
+
specification_version: 4
|
121
111
|
summary: log4ever is simple logger for evernote.
|
122
112
|
test_files:
|
123
113
|
- spec/log4ever_spec.rb
|