quiver_toolbox 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/quiver_toolbox/note.rb +33 -0
- data/lib/quiver_toolbox/util.rb +6 -0
- data/lib/quiver_toolbox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 293aed5ec3a8aa72a8c247ab51a6c038a0ffd85f
|
4
|
+
data.tar.gz: e7c0f43099fd25fa66abc61dee6320722aba4b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 302383c3c248b2602e2e189eb70c65aed9d1f4e1b4263a5b705781bef91740b70c6b79cdb7de5294b4084a0111e9f07a4c416c5b2ba6c2892978792e06c13cdf
|
7
|
+
data.tar.gz: febc9c90f08bce166805f7b52cd3740ef01c8ad693c347e1d292bac89e147945a00319bb3230b24b489632bf8d9f60217daef6cec7db1b800a40370b5a801fd7
|
data/lib/quiver_toolbox/note.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
class QuiverToolbox::Note
|
3
3
|
EXTENSION = 'qvnote'
|
4
|
+
RESOURCES_DIR = 'resources/'
|
4
5
|
META_JSON_FILE_NAME = 'meta.json'
|
5
6
|
CONTENT_JSON_FILE_NAME = 'content.json'
|
6
7
|
|
@@ -29,6 +30,11 @@ class QuiverToolbox::Note
|
|
29
30
|
meta_json_file = File.join(dir, 'meta.json')
|
30
31
|
meta_json = JSON.load(File.open(meta_json_file).read)
|
31
32
|
|
33
|
+
notebook_path = nil
|
34
|
+
Pathname.new(dir).ascend do |v|
|
35
|
+
notebook_path = v.expand_path.to_s if v.basename.to_s.match('.qvnotebook')
|
36
|
+
end
|
37
|
+
|
32
38
|
QuiverToolbox::Note.new do |n|
|
33
39
|
n.created_at = meta_json['created_at']
|
34
40
|
n.tags = meta_json['tags']
|
@@ -36,12 +42,14 @@ class QuiverToolbox::Note
|
|
36
42
|
n.updated_at = meta_json['updated_at']
|
37
43
|
n.uuid = meta_json['uuid']
|
38
44
|
n.cells = content_json['cells']
|
45
|
+
n.notebook_path = notebook_path
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
42
49
|
|
43
50
|
JSON_KEYS.each {|key| attr_accessor key.to_sym }
|
44
51
|
attr_accessor :file, :notebook_path
|
52
|
+
attr_reader :resources
|
45
53
|
def initialize(attributes = nil)
|
46
54
|
attributes.each do |k, v|
|
47
55
|
send("#{k.to_s}=", v) if respond_to?("#{k.to_s}=")
|
@@ -65,6 +73,20 @@ class QuiverToolbox::Note
|
|
65
73
|
end
|
66
74
|
|
67
75
|
|
76
|
+
def resources_dir
|
77
|
+
File.join(file_name_with_path, RESOURCES_DIR)
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
def src_resources=(src_files)
|
82
|
+
@resources = []
|
83
|
+
src_files.each do |src_file|
|
84
|
+
dist_file = File.join(resources_dir, "#{QuiverToolbox::Util.rename_to_uuid_file(src_file)}")
|
85
|
+
@resources << {'src' => src_file, 'dist' => dist_file}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
|
68
90
|
def meta_json_file
|
69
91
|
File.join(file_name_with_path, META_JSON_FILE_NAME)
|
70
92
|
end
|
@@ -107,6 +129,17 @@ class QuiverToolbox::Note
|
|
107
129
|
def store
|
108
130
|
store_meta_json
|
109
131
|
store_content_json
|
132
|
+
store_resources if @resources
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
def store_resources
|
138
|
+
FileUtils.mkdir_p(resources_dir)
|
139
|
+
@resources.each do |hash|
|
140
|
+
FileUtils.cp(hash['src'], hash['dist'])
|
141
|
+
end
|
142
|
+
self
|
110
143
|
end
|
111
144
|
|
112
145
|
|
data/lib/quiver_toolbox/util.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quiver_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- masainox
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|