dayone_to_quiver 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b874cb6f06ad80490aa01cdd4af94b9b814c2c40
4
+ data.tar.gz: 124334d0fc2dad907901401e8081574a94a74c48
5
+ SHA512:
6
+ metadata.gz: f1dcc3e68e61d174c5731af30d237f86f4b7216287523e66c8811ecee0c47970f9798a4571f5229580b7dbd9355be6975131029cc14de803292af3c681646e33
7
+ data.tar.gz: e5c53098814b75c7a75e48209c779cf2e4be44141036b997feb448370f26297d480d999d0fd1e8dce8521578463155bac7e5deaa920a87be1a8fd24db46c6a5a
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dayone_to_quiver.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Masato INOUE (masainox@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # DayoneToQuiver
2
+
3
+ DayoneToQuiver is converter for Day One classic to Quiver.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'dayone_to_quiver'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install dayone_to_quiver
20
+
21
+ ## Usage
22
+
23
+ $ dayone-to-quiver entry DAYONE_ENTRY_FILE --output=./tmp/
24
+ ./tmp/DD950ADE-4D9B-4FFD-8874-8FF825D50C99.qvnote
25
+
26
+ $ dayone-to-quiver journal DAYONE_JOURNALFILE --output=./tmp/ --name=import-notebook
27
+ ./tmp/b2a046a3-cc69-4e74-983b-f0de894fc4db.qvnotebook/A5380A52-F613-4A29-B1F6-A63921B46378.qvnote
28
+ ./tmp/b2a046a3-cc69-4e74-983b-f0de894fc4db.qvnotebook/DD950ADE-4D9B-4FFD-8874-8FF825D50C99.qvnote
29
+ ./tmp/b2a046a3-cc69-4e74-983b-f0de894fc4db.qvnotebook/21304A22-FD87-4C29-AC37-9AA317A18BC9.qvnote
30
+ ./tmp/b2a046a3-cc69-4e74-983b-f0de894fc4db.qvnotebook/9B25343B-397E-492C-B674-AC2D5290AD9B.qvnote
31
+
32
+ See also
33
+
34
+ $ dayone-to-quiver help
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/masainox/dayone_to_quiver.
45
+
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
50
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dayone_to_quiver"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dayone_to_quiver/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dayone_to_quiver"
8
+ spec.version = DayoneToQuiver::VERSION
9
+ spec.authors = ["masainox"]
10
+ spec.email = ["masainox@gmail.com"]
11
+
12
+ spec.summary = %q{DayoneToQuiver is converter for Day One classic to Quiver.}
13
+ spec.description = %q{DayoneToQuiver is converter for Day One classic to Quiver.}
14
+ spec.homepage = "https://github.com/masainox/dayone_to_quiver"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ #spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.12"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_development_dependency "simplecov", "~> 0.14.1"
34
+ spec.add_development_dependency "timecop", "~> 0.9.1"
35
+
36
+ spec.add_dependency "thor", "~> 0.19.4"
37
+ spec.add_dependency "dayone_toolbox", "~> 0.1.0"
38
+ spec.add_dependency "quiver_toolbox", "~> 0.1.0"
39
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dayone_to_quiver"
5
+
6
+ DayoneToQuiver::CLI.start(ARGV)
@@ -0,0 +1,45 @@
1
+
2
+ module DayoneToQuiver::API
3
+ end
4
+
5
+
6
+ class DayoneToQuiver::API::DayoneEntryToQuiverNote
7
+ attr_reader :result
8
+ def initialize(dayone_file, output_path)
9
+ @input_file = dayone_file
10
+ @output_path = output_path
11
+ end
12
+
13
+ def exec
14
+ @entry = ::DayoneToQuiver::DayoneEntry.new(@input_file)
15
+ @note = ::QuiverToolbox::Note.new(@entry.to_quiver_hash)
16
+ @note.notebook_path = @output_path
17
+ @result = @note.file_name_with_path if @note.store
18
+ self
19
+ end
20
+ end
21
+
22
+
23
+ class DayoneToQuiver::API::DayoneJournalToQuiverNotebook
24
+
25
+ attr_reader :result
26
+ def initialize(journal_file, options)
27
+ @input_file = journal_file
28
+ @journal = ::DayoneToolbox::Journal.new(journal_file)
29
+ @notebook = QuiverToolbox::Notebook.new do |n|
30
+ n.name = options[:name]
31
+ n.store_path = options[:output]
32
+ end
33
+ @result = ''
34
+ end
35
+
36
+
37
+ def exec
38
+ @notebook.store
39
+ @journal.entries.each do |entry|
40
+ note = @notebook.build_note(::DayoneToQuiver::DayoneEntry.new(entry).to_quiver_hash)
41
+ @result << "#{note.file_name_with_path}\n" if note.store
42
+ end
43
+ self
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+
2
+ require 'thor'
3
+
4
+ class DayoneToQuiver::CLI < Thor
5
+ class << self
6
+ def exit_on_failure?
7
+ true
8
+ end
9
+ end
10
+
11
+ attr_reader :api
12
+
13
+ desc "entry DAYONE_ENTRY_FILE [OPTIONS]", "Convert Day one entry file to Quiver note file"
14
+ option :output, :default => './', :aliases => :o
15
+ def entry(input)
16
+ @api = ::DayoneToQuiver::API::DayoneEntryToQuiverNote.new(input, options[:output])
17
+ @api.exec
18
+ puts @api.result
19
+ self
20
+ end
21
+
22
+
23
+ desc "journal DAYONE_JOURNAL_FILE [OPTIONS]", "Convert Day one journal file to Quiver notebook file"
24
+ option :output, :default => './', :aliases => :o
25
+ option :name, :default => 'dayone-to-quiver', :aliases => :n
26
+ def journal(input)
27
+ @api = ::DayoneToQuiver::API::DayoneJournalToQuiverNotebook.new(input, options)
28
+ @api.exec
29
+ puts @api.result
30
+ self
31
+ end
32
+ end
@@ -0,0 +1,65 @@
1
+
2
+ class DayoneToQuiver::DayoneEntry < DayoneToolbox::Entry
3
+
4
+ def self.to_quiver_uuid(entry_uuid)
5
+ new_uuid = entry_uuid.dup
6
+ new_uuid.insert(-25, '-').insert(-21, '-').insert(-17, '-').insert(-13, '-')
7
+ new_uuid
8
+ end
9
+
10
+
11
+ def self.to_quiver_title(entry_text)
12
+ entry_text.each_line {|l| return l.chomp }
13
+ end
14
+
15
+
16
+ def self.to_quiver_unixtime(time)
17
+ Time.parse("#{time}").to_i
18
+ end
19
+
20
+
21
+ def q_tags
22
+ tags
23
+ end
24
+
25
+
26
+ def q_title
27
+ self.class.to_quiver_title(entry_text)
28
+ end
29
+
30
+
31
+ def q_uuid
32
+ self.class.to_quiver_uuid(uuid)
33
+ end
34
+
35
+
36
+ def q_created_at
37
+ self.class.to_quiver_unixtime(creation_date)
38
+ end
39
+
40
+
41
+ def q_updated_at
42
+ q_created_at
43
+ end
44
+
45
+
46
+ def q_cells(type='markdown')
47
+ [{
48
+ 'type' => type,
49
+ 'data' => entry_text
50
+ }]
51
+ end
52
+
53
+
54
+ def to_quiver_hash
55
+ {
56
+ ::QuiverToolbox::Note::KEY_CREATED_AT => q_created_at,
57
+ ::QuiverToolbox::Note::KEY_TAGS => q_tags,
58
+ ::QuiverToolbox::Note::KEY_TITLE => q_title,
59
+ ::QuiverToolbox::Note::KEY_UPDATED_AT => q_updated_at,
60
+ ::QuiverToolbox::Note::KEY_UUID => q_uuid,
61
+ ::QuiverToolbox::Note::KEY_CELLS => q_cells
62
+ }
63
+ end
64
+
65
+ end
@@ -0,0 +1,3 @@
1
+ module DayoneToQuiver
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,12 @@
1
+
2
+ module DayoneToQuiver
3
+ end
4
+
5
+ require 'time'
6
+ require "dayone_toolbox"
7
+ require "quiver_toolbox"
8
+
9
+ require "dayone_to_quiver/version"
10
+ require "dayone_to_quiver/api"
11
+ require "dayone_to_quiver/cli"
12
+ require "dayone_to_quiver/dayone_entry"
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dayone_to_quiver
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - masainox
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: timecop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.19.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.19.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: dayone_toolbox
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.1.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.1.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: quiver_toolbox
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.0
125
+ description: DayoneToQuiver is converter for Day One classic to Quiver.
126
+ email:
127
+ - masainox@gmail.com
128
+ executables:
129
+ - dayone-to-quiver
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - dayone_to_quiver.gemspec
143
+ - exe/dayone-to-quiver
144
+ - lib/dayone_to_quiver.rb
145
+ - lib/dayone_to_quiver/api.rb
146
+ - lib/dayone_to_quiver/cli.rb
147
+ - lib/dayone_to_quiver/dayone_entry.rb
148
+ - lib/dayone_to_quiver/version.rb
149
+ homepage: https://github.com/masainox/dayone_to_quiver
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.6.4
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: DayoneToQuiver is converter for Day One classic to Quiver.
173
+ test_files: []