evertils-common 0.3.2 → 0.3.3

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: 5373e916dd2c6812cf51d1fb29552c4a31e4e849
4
- data.tar.gz: 411679ae6c66dfc2f84ed56eae1195409409a5b5
3
+ metadata.gz: da7fb7a8194a9a61a880bd69f81560d0c9953fb0
4
+ data.tar.gz: 679cfc257b94ef09559aa88da2822783e1d62502
5
5
  SHA512:
6
- metadata.gz: 31a683b20d62bff159d805ecff5345b9dd1e2d78673b10859f2886af7ec724bdb97fc142fe7dcfbcc9b566097f6defa71e78e70c015523a9d596b04f31e9e7f7
7
- data.tar.gz: 98d9a69fedef985a87162eacdf63674fd771ac1bddd45e3ac5f04356c9c60100bfd5f25e13844e35d7c8bf1197291b66f97239910f0eb1bedb7707764b48a49d
6
+ metadata.gz: 52a08dee5ad59a1e937982b49e0ee0e5b5fdc51071fd2db3ce28e9a366c0eb133fa53be4b38cbda71ace5a1fddd8fd8ff09726bdc36aa97c3d00d62d164b03fa
7
+ data.tar.gz: d0fdf469724242135b11e9a2c9cdb607ca259058e097145c4499f2754b90d03b9ded0798f4003c45a77a3f1967172cf0430fab3af15dfbe2abb868934a75e9f1
@@ -134,7 +134,7 @@ module Evertils
134
134
  when 18
135
135
  message = 'Operation denied because access to the corresponding object is prohibited in response to a take-down notice'
136
136
  when 19
137
- minutes = (e.rateLimitDuration/60).to_i
137
+ minutes = (e.rateLimitDuration.to_i/60).to_i
138
138
  message = "You are rate limited! Wait #{minutes} minutes"
139
139
  end
140
140
 
@@ -0,0 +1,36 @@
1
+ module Evertils
2
+ module Common
3
+ class ENMLElement
4
+ #
5
+ # @since 0.3.3
6
+ def initialize
7
+ @enml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
8
+ @enml += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
9
+ end
10
+
11
+ #
12
+ # @since 0.3.3
13
+ def body=(content)
14
+ @enml += "<en-note>#{content}</en-note>"
15
+ end
16
+
17
+ #
18
+ # @since 0.3.3
19
+ def to_s
20
+ @enml.to_s.encode(Encoding::UTF_8)
21
+ end
22
+
23
+ # Required as part of the thrift data conversion
24
+ # @since 0.3.3
25
+ def encoding
26
+ Encoding::UTF_8
27
+ end
28
+
29
+ # Required as part of the thrift data conversion
30
+ # @since 0.3.3
31
+ def force_encoding(enc)
32
+ @enml.to_s.encode(enc)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -5,7 +5,7 @@ module Evertils
5
5
  #
6
6
  # @since 0.2.0
7
7
  def create_from_yml(full_path)
8
- return unless File.exist? full_path
8
+ raise "File not found: #{full_path}" unless File.exist? full_path
9
9
 
10
10
  begin
11
11
  conf = YAML::load(File.open(full_path))
@@ -23,72 +23,18 @@ module Evertils
23
23
 
24
24
  #
25
25
  # @since 0.2.0
26
- def create(title, body, parent_notebook = nil, file = nil, share_note = false, created_on = nil)
27
- @entity = nil
28
-
29
- # final output
30
- output = {}
31
-
32
- # Create note object
33
- our_note = ::Evernote::EDAM::Type::Note.new
34
- our_note.resources = []
35
- our_note.tagNames = []
36
-
37
- # a file was requested, lets prepare it for storage
38
- if file
39
- if file.is_a? Array
40
- file.each do |f|
41
- media_resource = ENML.new(f)
42
- body.concat(media_resource.embeddable_element)
43
- our_note.resources << media_resource.element
44
- end
45
- else
46
- media_resource = ENML.new(file)
47
- body.concat(media_resource.embeddable_element)
48
- our_note.resources << media_resource.element
49
- end
50
- end
51
-
52
- # only join when required
53
- body = body.join if body.is_a? Array
54
-
55
- n_body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
56
- n_body += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">"
57
- n_body += "<en-note>#{body}</en-note>"
58
-
59
- # setup note properties
60
- our_note.title = title
61
- our_note.content = n_body
62
- our_note.created = created_on if !created_on.is_a?(DateTime)
63
-
64
- if !parent_notebook.is_a? Evertils::Common::Entity::Notebook
65
- nb = Entity::Notebook.new
66
- parent_notebook = nb.find(parent_notebook)
67
- parent_notebook = nb.default if parent_notebook.nil?
68
- end
69
-
70
- # parent_notebook is optional; if omitted, default notebook is used
71
- our_note.notebookGuid = parent_notebook.to_s
26
+ def create(conf = {})
27
+ note = Evertils::Common::Model::Note.new(conf)
28
+ @entity = @evernote.call(:createNote, note.entity)
72
29
 
73
- # Attempt to create note in Evernote account
74
- begin
75
- @entity = @evernote.call(:createNote, our_note)
76
- share if share_note
77
- rescue ::Evernote::EDAM::Error::EDAMUserException => edue
78
- ## Something was wrong with the note data
79
- ## See EDAMErrorCode enumeration for error code explanation
80
- ## http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode
81
- Notify.error "EDAMUserException: #{edue}\nCode #{edue.errorCode}: #{edue.parameter}"
82
- rescue ::Evernote::EDAM::Error::EDAMNotFoundException
83
- ## Parent Notebook GUID doesn't correspond to an actual notebook
84
- Notify.error "EDAMNotFoundException: Invalid parent notebook GUID"
85
- rescue ArgumentError => e
86
- Notify.error e.backtrace
87
- end
30
+ return false unless @entity
88
31
 
89
- Notify.success("#{parent_notebook.prop(:stack)}/#{parent_notebook.prop(:name)}/#{our_note.title} created")
32
+ share if note.shareable
90
33
 
91
- self if @entity
34
+ # TODO: get metadata back so we can print stack/notebook info
35
+ # Notify.success("#{note.notebook.prop(:stack)}/#{note.notebook.prop(:name)}/#{note.entity.title} created")
36
+ Notify.success("#{note.entity.title} created")
37
+ self
92
38
  end
93
39
 
94
40
  #
@@ -120,7 +66,7 @@ module Evertils
120
66
  #
121
67
  # @since 0.2.9
122
68
  def move_to(notebook)
123
- nb = Evertils::Common::Manager::Notebook.new
69
+ nb = Evertils::Common::Manager::Notebook.instance
124
70
  target = nb.find(notebook)
125
71
 
126
72
  raise "Notebook not found: #{notebook}" if target.entity.nil?
@@ -172,6 +118,24 @@ module Evertils
172
118
 
173
119
  @evernote.call(:updateNote, @entity)
174
120
  end
121
+
122
+ #
123
+ # @since 0.3.3
124
+ def attach_file(file)
125
+ if file.is_a? Array
126
+ file.each do |f|
127
+ media_resource = ENML.new(f)
128
+ body.concat(media_resource.embeddable_element)
129
+ @entity.resources << media_resource.element
130
+ end
131
+ else
132
+ media_resource = ENML.new(file)
133
+ body.concat(media_resource.embeddable_element)
134
+ @entity.resources << media_resource.element
135
+ end
136
+
137
+ @evernote.call(:updateNote, @entity)
138
+ end
175
139
  end
176
140
  end
177
141
  end
@@ -11,24 +11,22 @@ module Evertils
11
11
  #
12
12
  # @since 0.1.0
13
13
  def create_from_yml(full_path)
14
+ raise "File not found: #{full_path}" unless File.exist? full_path
15
+
14
16
  begin
15
17
  nb = Notebook.new
16
18
 
17
- if File.exists? full_path
18
- conf = YAML::load(File.open(full_path))
19
- required = %w(notebooks)
19
+ conf = YAML::load(File.open(full_path))
20
+ required = %w(notebooks)
20
21
 
21
- if has_required_fields(conf, required)
22
- if !conf["notebooks"].nil?
23
- conf["notebooks"].each do |name|
24
- nb.create(name)
25
- end
22
+ if has_required_fields(conf, required)
23
+ if !conf["notebooks"].nil?
24
+ conf["notebooks"].each do |name|
25
+ nb.create(name)
26
26
  end
27
- else
28
- raise ArgumentError, 'Configuration file is missing some required fields'
29
27
  end
30
28
  else
31
- raise ArgumentError, "File not found: #{full_path}"
29
+ raise ArgumentError, 'Configuration file is missing some required fields'
32
30
  end
33
31
  rescue ArgumentError => e
34
32
  puts e.message
@@ -3,24 +3,22 @@ module Evertils
3
3
  module Entity
4
4
  class Stack < Entity::Base
5
5
  def create_from_yml(full_path)
6
+ raise "File not found: #{full_path}" unless File.exist? full_path
7
+
6
8
  begin
7
9
  nb = Notebook.new
8
10
 
9
- if File.exist? full_path
10
- conf = YAML::load(File.open(full_path))
11
- required = %w(name children)
11
+ conf = YAML::load(File.open(full_path))
12
+ required = %w(name children)
12
13
 
13
- if has_required_fields(conf, required)
14
- if !conf["children"].nil?
15
- conf["children"].each do |name|
16
- nb.create(name, conf["name"])
17
- end
14
+ if has_required_fields(conf, required)
15
+ if !conf["children"].nil?
16
+ conf["children"].each do |name|
17
+ nb.create(name, conf["name"])
18
18
  end
19
- else
20
- raise ArgumentError, 'Configuration file is missing some required fields'
21
19
  end
22
20
  else
23
- raise ArgumentError, "File not found: #{full_path}"
21
+ raise ArgumentError, 'Configuration file is missing some required fields'
24
22
  end
25
23
  rescue ArgumentError => e
26
24
  puts e.message
@@ -2,7 +2,7 @@ module Evertils
2
2
  module Common
3
3
  module Entity
4
4
  class Base < Common::Generic
5
- attr_accessor :evernote, :entity
5
+ attr_accessor :entity
6
6
 
7
7
  def initialize
8
8
  @evernote = Authentication.instance
@@ -20,7 +20,23 @@ module Evertils
20
20
  def deprecation_notice(version, message)
21
21
  output = "Deprecated as of #{version}"
22
22
  output += "\nReason: #{message}" if message
23
- output
23
+ Notify.spit(output)
24
+ end
25
+
26
+ # Required as part of the thrift data conversion
27
+ # @since 0.3.3
28
+ def encoding
29
+ Encoding::UTF_8
30
+ end
31
+
32
+ # Required as part of the thrift data conversion
33
+ # @since 0.3.3
34
+ def force_encoding(enc)
35
+ end
36
+
37
+ # Required as part of the thrift data conversion
38
+ # @since 0.3.3
39
+ def bytesize(enc)
24
40
  end
25
41
  end
26
42
  end
@@ -2,4 +2,22 @@ class String
2
2
  def capitalize_first_char
3
3
  self.sub(/^(.)/) { $1.capitalize }
4
4
  end
5
+ end
6
+
7
+ # required for some reason, thrift is weird
8
+ class Hash
9
+ def encoding
10
+ end
11
+
12
+ def encode(arg)
13
+ end
14
+
15
+ def force_encoding(arg)
16
+ end
17
+ end
18
+
19
+ class NilClass
20
+ def bytesize
21
+ 0
22
+ end
5
23
  end
@@ -1,12 +1,16 @@
1
+ require "singleton"
2
+
1
3
  module Evertils
2
4
  module Common
3
5
  module Manager
4
6
  class Note < Manager::Base
7
+ include Singleton
8
+
5
9
  #
6
10
  # @since 0.3.0
7
11
  def create(config)
8
12
  entity = Evertils::Common::Entity::Note.new
9
- entity.create(config[:name], config[:body], config[:notebook], config[:files], config[:shared], config[:created_on])
13
+ entity.create(config)
10
14
  entity
11
15
  end
12
16
 
@@ -1,7 +1,11 @@
1
+ require "singleton"
2
+
1
3
  module Evertils
2
4
  module Common
3
5
  module Manager
4
6
  class Notebook < Manager::Base
7
+ include Singleton
8
+
5
9
  #
6
10
  # @since 0.3.0
7
11
  def create(name, stack = nil)
@@ -1,7 +1,11 @@
1
+ require "singleton"
2
+
1
3
  module Evertils
2
4
  module Common
3
5
  module Manager
4
6
  class Sync < Manager::Base
7
+ include Singleton
8
+
5
9
  #
6
10
  # @since 0.3.0
7
11
  def state
@@ -1,7 +1,11 @@
1
+ require "singleton"
2
+
1
3
  module Evertils
2
4
  module Common
3
5
  module Manager
4
6
  class Tag < Manager::Base
7
+ include Singleton
8
+
5
9
  #
6
10
  # @since 0.3.0
7
11
  def create(name)
@@ -0,0 +1,118 @@
1
+ require 'evertils/common/enmlelement'
2
+ require 'evertils/common/enml'
3
+
4
+ module Evertils
5
+ module Common
6
+ module Model
7
+ class Note
8
+ attr_accessor :shareable, :updated
9
+
10
+ #
11
+ # @since 0.3.3
12
+ def initialize(conf = {})
13
+ raise "Title (title) is a required field" unless conf[:title]
14
+ raise "Body (body) is a required field" unless conf[:body]
15
+
16
+ @note = ::Evernote::EDAM::Type::Note.new
17
+
18
+ # data which maps directly to the Type::Note object
19
+ self.body = conf[:body]
20
+ self.created = conf[:created_on] || DateTime.now
21
+
22
+ @note.title = conf[:title]
23
+ @note.tagNames = conf[:tags] || []
24
+ @note.resources = []
25
+
26
+ # data that must be processed first
27
+ @notebook = conf[:parent_notebook] || Entity::Notebook.new.default.to_s
28
+ @resources = conf[:file] || []
29
+ @shareable = conf[:share_note] || false
30
+ @updated = conf[:updated_on] || nil
31
+
32
+ attach_resources
33
+ attach_notebook
34
+ end
35
+
36
+ # Accessor for the title property
37
+ # @since 0.3.3
38
+ def title
39
+ @note.title
40
+ end
41
+
42
+ # Accessor for the body/content property
43
+ # @since 0.3.3
44
+ def body
45
+ @note.content
46
+ end
47
+ alias content body
48
+
49
+ # Accessor for the notebook property
50
+ # @since 0.3.3
51
+ def notebook
52
+ @note.notebookGuid
53
+ end
54
+
55
+ # Accessor for the tagNames property
56
+ # @since 0.3.3
57
+ def tags
58
+ @note.tagNames
59
+ end
60
+
61
+ # Accessor for the created_on property
62
+ # @since 0.3.3
63
+ def created
64
+ @note.created
65
+ end
66
+
67
+ # The whole note
68
+ # @since 0.3.3
69
+ def entity
70
+ @note
71
+ end
72
+
73
+ protected
74
+
75
+ # Body content must be valid ENML so we create that here
76
+ # @since 0.3.3
77
+ def body=(content)
78
+ note_body = ENMLElement.new
79
+ note_body.body = content
80
+
81
+ @note.content = note_body.to_s
82
+ end
83
+
84
+ #
85
+ # @since 0.3.3
86
+ def created=(date)
87
+ date = DateTime.now unless date
88
+ created_on = (date.to_time.to_i.to_s + "000").to_i
89
+
90
+ @note.created = created_on
91
+ end
92
+
93
+ private
94
+
95
+ def attach_resources
96
+ if @resources.is_a? Array
97
+ @resources.each do |f|
98
+ media_resource = ENML.new(f)
99
+ content.concat(media_resource.embeddable_element)
100
+ @note.resources << media_resource.element
101
+ end
102
+ else
103
+ media_resource = ENML.new(@resources)
104
+ content.concat(media_resource.embeddable_element)
105
+ @note.resources << media_resource.element
106
+ end
107
+ end
108
+
109
+ def attach_notebook
110
+ nb = Manager::Notebook.instance
111
+ query = nb.find(@notebook.to_s)
112
+ notebook = query.entity
113
+ @note.notebookGuid = notebook if query
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,8 @@
1
+ module Evertils
2
+ module Common
3
+ module Model
4
+ class Notebook
5
+ end
6
+ end
7
+ end
8
+ end
@@ -17,7 +17,7 @@ module Evertils
17
17
  nb = nb_entity.create(backup_notebook_name)
18
18
  end
19
19
 
20
- @entity = nm.create("Backup: #{date}", "", nb, files)
20
+ @entity = nm.create(title: "Backup: #{date}", body: "", parent_notebook: nb, files: files)
21
21
  end
22
22
 
23
23
  #
@@ -17,66 +17,66 @@ module Evertils
17
17
  #
18
18
  # @since 0.2.0
19
19
  def notes_by_notebook(name)
20
- entity = Manager::Notebook.new
20
+ entity = Manager::Notebook.instance
21
21
  nb = entity.find(name)
22
22
  nb.notes
23
23
  end
24
24
 
25
25
  #
26
26
  # @since 0.2.0
27
- def create_stack_from(full_path)
27
+ def create_stack_from_yml(full_path)
28
28
  stack = Entity::Stack.new
29
29
  stack.create_from_yml(full_path)
30
30
  end
31
31
 
32
32
  #
33
33
  # @since 0.2.0
34
- def create_note_from(full_path)
34
+ def create_note_from_yml(full_path)
35
35
  entity = Entity::Note.new
36
- note = entity.create_from_yml(full_path)
36
+ entity.create_from_yml(full_path)
37
37
  end
38
38
 
39
39
  #
40
40
  # @since 0.2.0
41
- def create_notebooks_from(full_path)
41
+ def create_notebooks_from_yml(full_path)
42
42
  entity = Entity::Notebooks.new
43
- nb = entity.create_from_yml(full_path)
43
+ entity.create_from_yml(full_path)
44
44
  end
45
45
 
46
46
  #
47
47
  # @since 0.2.0
48
48
  def create_notebook(name, stack = nil)
49
49
  entity = Entity::Notebook.new
50
- nb = entity.create(name, stack)
50
+ entity.create(name, stack)
51
51
  end
52
52
 
53
53
  #
54
54
  # @since 0.3.1
55
55
  def create_tag(name)
56
- entity = Manager::Tag.new
57
- tag = entity.create(name)
56
+ entity = Manager::Tag.instance
57
+ entity.create(name)
58
58
  end
59
59
 
60
60
  #
61
- # @since 0.2.0
62
- def create_note(title, body, p_notebook_name = nil, file = nil, share_note = false, created_on = nil)
63
- entity = Manager::Note.new
64
- conf = { name: title, body: body, notebook: p_notebook_name, files: file, shared: share_note, created_on: created_on }
65
- note = entity.create(conf)
61
+ # @since 0.3.3
62
+ def create_note_from_hash(conf)
63
+ entity = Manager::Note.instance
64
+ entity.create(conf)
66
65
  end
66
+ alias create_note create_note_from_hash
67
67
 
68
68
  #
69
69
  # @since 0.2.0
70
70
  def find_note(name)
71
- entity = Manager::Note.new
72
- note = entity.find(name)
71
+ entity = Manager::Note.instance
72
+ entity.find(name)
73
73
  end
74
74
 
75
75
  #
76
76
  # @since 0.3.1
77
77
  def find_notebook(name)
78
- entity = Manager::Notebook.new
79
- nb = entity.find(name)
78
+ entity = Manager::Notebook.instance
79
+ entity.find(name)
80
80
  end
81
81
 
82
82
  #
@@ -85,14 +85,14 @@ module Evertils
85
85
  def notebook_by_name(name)
86
86
  deprecation_notice('0.3.1', 'Replaced by #find_notebook method. Will be removed in 0.4.0')
87
87
 
88
- entity = Manager::Notebook.new
89
- nb = entity.find(name)
88
+ entity = Manager::Notebook.instance
89
+ entity.find(name)
90
90
  end
91
91
 
92
92
  #
93
93
  # @since 0.2.0
94
94
  def note_exists(name)
95
- entity = Manager::Note.new
95
+ entity = Manager::Note.instance
96
96
  note = entity.find(name)
97
97
  note.exists?
98
98
  end
@@ -100,7 +100,7 @@ module Evertils
100
100
  #
101
101
  # @since 0.2.0
102
102
  def destroy_note(name)
103
- entity = Manager::Note.new
103
+ entity = Manager::Note.instance
104
104
  note = entity.find(name)
105
105
  note.expunge!
106
106
  end
@@ -108,14 +108,8 @@ module Evertils
108
108
  #
109
109
  # @since 0.2.0
110
110
  def poll
111
- begin
112
- sync = Entity::Sync.new
113
- sync.state
114
- rescue Evernote::EDAM::Error::EDAMSystemException => e
115
- if e.errorCode == 19
116
- puts "You're rate limited, wait #{e.rateLimitDuration}s"
117
- end
118
- end
111
+ sync = Entity::Sync.new
112
+ sync.state
119
113
  end
120
114
  end
121
115
  end
@@ -1,5 +1,5 @@
1
1
  module Evertils
2
2
  module Common
3
- VERSION = "0.3.2".freeze
3
+ VERSION = "0.3.3".freeze
4
4
  end
5
5
  end
@@ -4,24 +4,31 @@ require 'yaml'
4
4
  require 'mime/types'
5
5
  require 'date'
6
6
 
7
+ # core files
7
8
  require 'evertils/common/kernel'
8
9
  require 'evertils/common/generic'
9
- require 'evertils/common/enml'
10
10
  require 'evertils/common/entity'
11
11
  require 'evertils/common/query'
12
12
  require 'evertils/common/converter'
13
13
  require 'evertils/common/manager'
14
14
  require 'evertils/common/version'
15
15
 
16
+ # models represent Evernote's Data types
17
+ # https://dev.evernote.com/doc/reference/Types.html#Struct_Note
18
+ require 'evertils/common/model/note'
19
+
20
+ # wrappers to perform common queries on your EN data
16
21
  require 'evertils/common/query/simple'
17
22
  require 'evertils/common/query/time'
18
23
  require 'evertils/common/query/backup'
19
24
 
25
+ # simple wrappers for the often complex entity objects
20
26
  require 'evertils/common/manager/note'
21
27
  require 'evertils/common/manager/notebook'
22
28
  require 'evertils/common/manager/sync'
23
29
  require 'evertils/common/manager/tag'
24
30
 
31
+ # do stuff with your EN data
25
32
  require 'evertils/common/entity/notebook'
26
33
  require 'evertils/common/entity/notebooks'
27
34
  require 'evertils/common/entity/notes'
@@ -31,6 +38,7 @@ require 'evertils/common/entity/tags'
31
38
  require 'evertils/common/entity/sync'
32
39
  require 'evertils/common/entity/stack'
33
40
 
41
+ # convert from ENML (Evernote Markup Language) to another data type
34
42
  require 'evertils/common/converter/yaml_to_enml'
35
43
 
36
44
  module Evertils
@@ -3,7 +3,6 @@ require 'minitest/autorun'
3
3
  module Evertils
4
4
  module Test
5
5
  class Base < Minitest::Test
6
-
7
6
  # Run before all tests (check the Rakefile for specifics)
8
7
  # @since 0.3.0
9
8
  def self.before
@@ -32,14 +31,11 @@ module Evertils
32
31
  #
33
32
  # @since 0.3.0
34
33
  def setup
35
- entity = Evertils::Common::Manager::Sync.new
34
+ entity = Evertils::Common::Manager::Sync.instance
36
35
 
37
- @@test_time = Time.now.to_i
36
+ Notify.error('Could not determine connection to the Evernote API, exiting') unless entity.state.is_a?(Evernote::EDAM::NoteStore::SyncState)
38
37
 
39
- if !entity.state.is_a?(Evernote::EDAM::NoteStore::SyncState)
40
- puts 'Could not determine connection to the Evernote API, exiting'
41
- exit(1)
42
- end
38
+ @@test_time = Time.now.to_i
43
39
  end
44
40
 
45
41
  #
@@ -58,15 +54,15 @@ module Evertils
58
54
  conf.each do |stack_name|
59
55
  stack_name.last.each_pair do |key, arr|
60
56
  puts "Creating: #{stack_name.first}/#{key}-#{@@test_time}..."
61
- ch_nb = nb.create("#{key}-#{@@test_time}", stack_name.first)
57
+ ch_nb = nb.create({ title: "#{key}-#{@@test_time}" }, stack_name.first)
62
58
 
63
59
  arr.each do |child_note|
64
60
  child_note.each_pair do |name, options|
65
61
  puts "Creating: #{stack_name.first}/#{key}/#{name}.note..."
66
62
  parsed = DateTime.parse(options['created_on'])
67
63
 
68
- created_on = (parsed.to_time.to_i.to_s + "000").to_i
69
- note.create(name, "Body for test note", ch_nb, nil, false, created_on)
64
+ # created_on = (parsed.to_time.to_i.to_s + "000").to_i
65
+ note.create(title: name, body: "Body for test note", parent_notebook: ch_nb, created_on: parsed)
70
66
  end
71
67
  end
72
68
  end
@@ -82,7 +78,7 @@ module Evertils
82
78
  # @since 0.3.0
83
79
  def clean
84
80
  nb = Evertils::Common::Entity::Notebooks.new
85
- nbm = Evertils::Common::Manager::Notebook.new
81
+ nbm = Evertils::Common::Manager::Notebook.instance
86
82
  notes = Evertils::Common::Entity::Notes.new
87
83
  auth = Evertils::Common::Authentication.instance
88
84
  tm = Evertils::Common::Entity::Tags.new
@@ -119,7 +115,6 @@ module Evertils
119
115
 
120
116
  puts "Sample data deleted"
121
117
  end
122
-
123
118
  end
124
119
  end
125
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evertils-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Priebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -105,6 +105,7 @@ files:
105
105
  - lib/evertils/common/converter.rb
106
106
  - lib/evertils/common/converter/yaml_to_enml.rb
107
107
  - lib/evertils/common/enml.rb
108
+ - lib/evertils/common/enmlelement.rb
108
109
  - lib/evertils/common/entity.rb
109
110
  - lib/evertils/common/entity/note.rb
110
111
  - lib/evertils/common/entity/notebook.rb
@@ -121,6 +122,8 @@ files:
121
122
  - lib/evertils/common/manager/notebook.rb
122
123
  - lib/evertils/common/manager/sync.rb
123
124
  - lib/evertils/common/manager/tag.rb
125
+ - lib/evertils/common/model/note.rb
126
+ - lib/evertils/common/model/notebook.rb
124
127
  - lib/evertils/common/query.rb
125
128
  - lib/evertils/common/query/backup.rb
126
129
  - lib/evertils/common/query/simple.rb