unofficial-quiver-export 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -5
- data/lib/unofficial/quiver/export/cli.rb +20 -11
- data/lib/unofficial/quiver/export/logger.rb +41 -0
- data/lib/unofficial/quiver/export/note_writer.rb +28 -8
- data/lib/unofficial/quiver/export/version.rb +1 -1
- data/lib/unofficial/quiver/export.rb +1 -0
- data/unofficial-quiver-export.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59128619caeb86130d636282cf5d39567d2c51e2
|
4
|
+
data.tar.gz: ceaca628cc647f80401d9c4e83aa8889daeb5fa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e53439cd3f42062ec81b744d283f0fcfb62a712ef4f8d1f368b8204b7b11efd19af1cb7430da6986d1c5eeb16ee2689f1c43a56e6ba9117de23b8a2f9bb533ca
|
7
|
+
data.tar.gz: a0e907ccf35227a63464c762413587a50bae03bdb5597907101eae56f710b3a4812725a293c720fcbdf376cdc491ce06b017902b410981f45f4f27024296b40e
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Unofficial Quiver Export
|
2
2
|
|
3
|
-
This is the un-official gem for [Quiver](http://happenapps.com/#quiver). It exports
|
3
|
+
This is the un-official gem for [Quiver](http://happenapps.com/#quiver). It exports Quiver notes to text files.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -8,12 +8,26 @@ This is the un-official gem for [Quiver](http://happenapps.com/#quiver). It expo
|
|
8
8
|
gem 'unofficial-quiver-export'
|
9
9
|
```
|
10
10
|
|
11
|
-
##
|
11
|
+
## Usage
|
12
12
|
|
13
|
-
|
13
|
+
```bash
|
14
|
+
quiver-export --in ~/Dropbox/Apps/Quiver/Quiver.qvlibrary --out ~/Dropbox/Apps/Quiver/Quiver.export
|
15
|
+
```
|
14
16
|
|
15
|
-
##
|
17
|
+
## Scheduled task
|
18
|
+
|
19
|
+
In order to execute scheduled task, you should use `crontab -e`.
|
20
|
+
|
21
|
+
Example of a setting:
|
22
|
+
|
23
|
+
```cron
|
24
|
+
LC_CTYPE=en_US.UTF-8
|
25
|
+
*/5 * * * * $HOME/.rbenv/shims/quiver-export --in $HOME/Dropbox/Apps/Quiver/Quiver.qvlibrary --out $HOME/Dropbox/Apps/Quiver/Quiver.export > $HOME/.quiver-export/quiver-export.log 2>&1
|
26
|
+
```
|
27
|
+
|
28
|
+
## For more information
|
16
29
|
|
17
30
|
```bash
|
18
|
-
quiver-export
|
31
|
+
quiver-export help exec
|
19
32
|
```
|
33
|
+
|
@@ -5,31 +5,40 @@ module Unofficial
|
|
5
5
|
module Quiver
|
6
6
|
module Export
|
7
7
|
class CLI < Thor
|
8
|
-
|
9
|
-
|
10
|
-
option :
|
11
|
-
option :
|
12
|
-
option :
|
8
|
+
desc "exec", "Exports Quiver notes."
|
9
|
+
option :in, required: true, desc: 'Quiver working directory.'
|
10
|
+
option :out, required: true, desc: 'Directory to export.'
|
11
|
+
option :ext, required: false, default: '.txt', desc: 'Extention to export file.'
|
12
|
+
option :db, required: false, type: :boolean, default: File.expand_path("~/.quiver-export"), desc: 'DB file path.'
|
13
|
+
option :log, required: false, bunner: '<PATH>', desc: 'Log file path. If it is not specified, the default is stdout.'
|
14
|
+
option :clean, required: false, type: :boolean, default: false, desc: 'Removes --out directory before execute.'
|
15
|
+
option :debug, required: false, type: :boolean, default: false, desc: 'Prints debug logs.'
|
13
16
|
default_task :exec
|
14
17
|
|
15
18
|
def exec
|
16
|
-
|
19
|
+
init
|
20
|
+
|
21
|
+
Logger.debug("options: #{options}")
|
17
22
|
|
18
|
-
clean
|
19
23
|
scan_content do |content_file|
|
20
24
|
writer = NoteWriter.new(content_file, options)
|
21
25
|
writer.write
|
22
26
|
end
|
23
27
|
|
24
|
-
|
28
|
+
Logger.info('Export complete!!')
|
25
29
|
end
|
26
30
|
|
27
31
|
private
|
28
32
|
|
33
|
+
def init
|
34
|
+
Logger.configure(options[:log], debug: options[:debug])
|
35
|
+
clean if options[:clean]
|
36
|
+
end
|
37
|
+
|
29
38
|
def clean
|
30
|
-
|
31
|
-
|
32
|
-
FileUtils.rm_r(
|
39
|
+
Logger.info('Clean --out and --db option directories.')
|
40
|
+
FileUtils.rm_r(options[:out]) if File.exists?(options[:out])
|
41
|
+
FileUtils.rm_r(options[:db]) if File.exists?(options[:db])
|
33
42
|
end
|
34
43
|
|
35
44
|
def scan_content
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Unofficial
|
4
|
+
module Quiver
|
5
|
+
module Export
|
6
|
+
class Logger
|
7
|
+
def self.configure(out, debug: false)
|
8
|
+
init_instance(out)
|
9
|
+
|
10
|
+
@logger.level = ::Logger::INFO unless debug
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.debug(msg)
|
14
|
+
@logger.debug(msg)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.info(msg)
|
18
|
+
@logger.info(msg)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.warn(msg)
|
22
|
+
@logger.warn(msg)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.error(msg)
|
26
|
+
@logger.error(msg)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def self.init_instance(out)
|
32
|
+
if out.nil?
|
33
|
+
@logger = ::Logger.new(STDOUT)
|
34
|
+
else
|
35
|
+
@logger = ::Logger.new(out)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,35 +1,55 @@
|
|
1
|
+
require 'moneta'
|
2
|
+
|
1
3
|
module Unofficial
|
2
4
|
module Quiver
|
3
5
|
module Export
|
4
6
|
class NoteWriter
|
5
7
|
def initialize(content_file, options)
|
6
|
-
@content_file = content_file
|
8
|
+
@content_file = File.new(content_file)
|
7
9
|
@content = JSON.parse(open(content_file).read)
|
8
10
|
@options = options
|
11
|
+
|
12
|
+
@store = Moneta.new(:HashFile, dir: @options[:db])
|
9
13
|
end
|
10
14
|
|
11
15
|
def write
|
16
|
+
return unless updated?
|
17
|
+
|
12
18
|
open(output_note_file, 'w') do |f|
|
13
|
-
|
19
|
+
Logger.debug(f.path)
|
14
20
|
@content['cells'].each do |cell|
|
15
21
|
f.puts cell['data']
|
16
22
|
end
|
17
23
|
end
|
24
|
+
|
25
|
+
save_last_updated_time
|
18
26
|
end
|
19
27
|
|
20
28
|
private
|
21
29
|
|
22
|
-
def
|
23
|
-
|
30
|
+
def updated?
|
31
|
+
wrote_time = @store[meta['uuid']]
|
32
|
+
return true unless wrote_time
|
33
|
+
|
34
|
+
wrote_time < @content_file.mtime
|
35
|
+
end
|
36
|
+
|
37
|
+
def save_last_updated_time
|
38
|
+
@store[meta['uuid']] = @content_file.mtime
|
39
|
+
end
|
40
|
+
|
41
|
+
def meta
|
42
|
+
f = File.join(File.dirname(@content_file), 'meta.json')
|
43
|
+
@meta = JSON.parse(open(f).read)
|
24
44
|
end
|
25
45
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
46
|
+
def notebook_meta
|
47
|
+
f = File.join(File.dirname(@content_file), '../meta.json')
|
48
|
+
@notebook_meta = JSON.parse(open(f).read)
|
29
49
|
end
|
30
50
|
|
31
51
|
def output_note_file
|
32
|
-
f = File.join(@options[:out],
|
52
|
+
f = File.join(@options[:out], notebook_meta['name'], @content['title'].gsub('/', '') + @options[:ext])
|
33
53
|
FileUtils.mkdir_p(File.dirname(f))
|
34
54
|
f
|
35
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unofficial-quiver-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Norimitsu YAMASHITA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: moneta
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,6 +92,7 @@ files:
|
|
78
92
|
- ".gitignore"
|
79
93
|
- ".rspec"
|
80
94
|
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
81
96
|
- Gemfile
|
82
97
|
- README.md
|
83
98
|
- Rakefile
|
@@ -86,6 +101,7 @@ files:
|
|
86
101
|
- exe/quiver-export
|
87
102
|
- lib/unofficial/quiver/export.rb
|
88
103
|
- lib/unofficial/quiver/export/cli.rb
|
104
|
+
- lib/unofficial/quiver/export/logger.rb
|
89
105
|
- lib/unofficial/quiver/export/note_writer.rb
|
90
106
|
- lib/unofficial/quiver/export/version.rb
|
91
107
|
- unofficial-quiver-export.gemspec
|