yinx 0.1.5 → 0.1.6

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: 6010d01c5bb3a399c0b20032756fc9f3bf71d4ae
4
- data.tar.gz: 5fd766dbb2cdb25743be78163a102bd193d6d575
3
+ metadata.gz: 3fd66ccaa0654d53f1efc187f7b21e140bab2c8a
4
+ data.tar.gz: 20a4c800c0adca5b13e9464539187c3f3aa8be50
5
5
  SHA512:
6
- metadata.gz: 52525dfca89aec744d21fc5094cfe43054ed32728c482818c69da552ed282d5381cded9b6396d4e26043b668f6d4eac3f4d7960b57a525eb066944468c1683b4
7
- data.tar.gz: c3343c36f65bb6fd6172f6e98a3d95a9577388f7060027d9cefee135c1805ff7297713570cfbfe4e9441a2f4704a8fa4dd2d3e06a7965e6ffd08b98fb08cde4f
6
+ metadata.gz: 56c323674093cd55c88f093c5b574de48ac7e8a0c2ec0e2d6ecc88e19ba51750b3e1dd67c34aa7b6665321bb2f3d22adabb4c8e7705e5c5b5e78a44dee549fc1
7
+ data.tar.gz: c5924b1a5ee4a25d8419822344dc4c7e14f674f8e47689f6c28df6feac8c3d3fe8c69d0102a3d31ce0dcb90b1e3643e3801d8dab9fc60d2010d4da078ba8ebcf
@@ -15,7 +15,8 @@ module Yinx
15
15
 
16
16
  %w{book stack tag word}.each do |condition|
17
17
  define_method "wanted_#{condition}s" do
18
- instance_variable_get("@wanted_#{condition}s") || []
18
+ iv_name = "@wanted_#{condition}s"
19
+ instance_variable_defined?(iv_name) ? instance_variable_get(iv_name) : []
19
20
  end
20
21
 
21
22
  define_method "want_#{condition}?" do |name|
@@ -1,10 +1,12 @@
1
1
  require 'evernote-thrift'
2
- require 'yinx/hash'
3
- require 'yinx/array'
4
2
 
5
3
  class Yinx::NoteMeta
6
4
 
7
- [:updated, :created, :title, :notebookGuid, :guid, :contentLength, :tagGuids].each do |method|
5
+ OfficialApi = [:updated, :created, :title, :notebookGuid, :guid, :contentLength, :tagGuids]
6
+
7
+ FullApi = OfficialApi + [:tags, :book, :stack]
8
+
9
+ OfficialApi.each do |method|
8
10
  define_method method do
9
11
  iv_name = "@#{method}"
10
12
  unless instance_variable_defined? iv_name
@@ -41,7 +43,7 @@ class Yinx::NoteMeta
41
43
  end
42
44
 
43
45
  def to_h
44
- @h = attr_methods.each_with_object({}) do |method, hash|
46
+ @h = FullApi.each_with_object({}) do |method, hash|
45
47
  hash[method] = send method
46
48
  end
47
49
  end
@@ -62,10 +64,29 @@ class Yinx::NoteMeta
62
64
  end
63
65
  end
64
66
 
67
+ NoTagGuid, NoTag = 'NoTagGuid', 'NoTag'
68
+
69
+ def unwind_tags
70
+ if tags.empty?
71
+ [_unwind_tags(NoTagGuid, NoTag)]
72
+ else
73
+ tagGuids.zip(tags).map do |tag_id, tag_name|
74
+ _unwind_tags tag_id, tag_name
75
+ end
76
+ end
77
+ end
78
+
79
+ protected
80
+
81
+ attr_writer :tagGuids, :tags
82
+
65
83
  private
66
84
 
67
- def attr_methods
68
- self.class.instance_methods(false) - [:to_h, :marshal_dump, :marshal_load]
85
+ def _unwind_tags tag_id, tag_name
86
+ uw = self.dup
87
+ uw.tagGuids = tag_id
88
+ uw.tags = tag_name
89
+ uw
69
90
  end
70
91
 
71
92
  end
@@ -1,3 +1,3 @@
1
1
  module Yinx
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2017-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,9 +82,7 @@ files:
82
82
  - bin/console
83
83
  - bin/setup
84
84
  - lib/yinx.rb
85
- - lib/yinx/array.rb
86
85
  - lib/yinx/down_config.rb
87
- - lib/yinx/hash.rb
88
86
  - lib/yinx/note_meta.rb
89
87
  - lib/yinx/note_store.rb
90
88
  - lib/yinx/user_store.rb
@@ -110,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
108
  version: '0'
111
109
  requirements: []
112
110
  rubyforge_project:
113
- rubygems_version: 2.5.2
111
+ rubygems_version: 2.6.8
114
112
  signing_key:
115
113
  specification_version: 4
116
114
  summary: Get my evernote metadata
@@ -1,5 +0,0 @@
1
- class Array
2
- def to_yinx
3
- map &:to_yinx
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class Hash
2
- def to_yinx
3
- raw = Yinx::NoteMeta.raw
4
- raise TypeError, "can not convert #{self} to Yinx::NoteMeta" unless raw.send(:attr_methods).all?{|m| self.has_key?(m) or self.has_key?(m.to_s)}
5
- raw.marshal_load self
6
- raw
7
- end
8
-
9
- end