zettel_outline 0.1.1
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 +7 -0
- data/.gitignore +36 -0
- data/.rspec +2 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +39 -0
- data/LICENSE +21 -0
- data/README.md +85 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/test +17 -0
- data/exe/zettel_outline +70 -0
- data/lib/zettel_outline.rb +27 -0
- data/lib/zettel_outline/archive.rb +30 -0
- data/lib/zettel_outline/outline.rb +27 -0
- data/lib/zettel_outline/outline_item.rb +19 -0
- data/lib/zettel_outline/outline_parser.rb +18 -0
- data/lib/zettel_outline/version.rb +4 -0
- data/lib/zettel_outline/zettel.rb +28 -0
- data/lib/zettel_outline/zettel_info.rb +33 -0
- data/lib/zettel_outline/zettel_renderer.rb +12 -0
- data/zettel_outline.gemspec +27 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e6d4d09a164ac3febd013bbaa07c3ab5be5897e
|
4
|
+
data.tar.gz: 8c4de1018c06c70ce3f8ff340d85d903a963df9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1165635cfcbea62fe5741bfc0ad9c49f1aefab371652bdeb66ad038a9b0b32a1cab420102cfec7fe478b9a1b27c1e18469752c1be3a9566b3af79676c1f19b02
|
7
|
+
data.tar.gz: d93af4f2a5b2d061402047fea8ddeb0e09a136f8e992aa5fd8b45b33638ce28878dd7503e7b23ef8d44e85f041faf7e1a1fdc705e5815cb01d226c54098ee71f
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
.ruby-version
|
33
|
+
.ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at christian.tietze@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zettel_outline (0.1.1)
|
5
|
+
colorize (~> 0.7)
|
6
|
+
slop (~> 4.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
colorize (0.7.7)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
rake (10.5.0)
|
14
|
+
rspec (3.4.0)
|
15
|
+
rspec-core (~> 3.4.0)
|
16
|
+
rspec-expectations (~> 3.4.0)
|
17
|
+
rspec-mocks (~> 3.4.0)
|
18
|
+
rspec-core (3.4.1)
|
19
|
+
rspec-support (~> 3.4.0)
|
20
|
+
rspec-expectations (3.4.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.4.0)
|
23
|
+
rspec-mocks (3.4.1)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.4.0)
|
26
|
+
rspec-support (3.4.1)
|
27
|
+
slop (4.2.1)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
bundler (~> 1.11)
|
34
|
+
rake (~> 10.0)
|
35
|
+
rspec (~> 3.0)
|
36
|
+
zettel_outline!
|
37
|
+
|
38
|
+
BUNDLED WITH
|
39
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Christian Tietze
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# ZettelOutline Rendering
|
2
|
+
|
3
|
+
Assemble a first draft from your [Zettelkasten](http://zettelkasten.de) notes and an outline file. **Markdown** aware, allowing you to write arbitrarily nested lists as outlines.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Install the ruby gem yourself from the command line:
|
9
|
+
|
10
|
+
$ gem install zettel_outline
|
11
|
+
|
12
|
+
## Usage of the program
|
13
|
+
|
14
|
+
From the command line, run `zettel_outline` with the required parameters as the help indicates:
|
15
|
+
|
16
|
+
$ zettel_outline
|
17
|
+
usage: zettel_outline -f <OUTLINE FILE> -a <ARCHIVE PATH> -o <DRAFT FILE>
|
18
|
+
|
19
|
+
Required options:
|
20
|
+
-f, --file an outline file
|
21
|
+
-a, --archive path to your Zettel notes
|
22
|
+
-o, --output file to write results to
|
23
|
+
|
24
|
+
Also available:
|
25
|
+
-h, --help prints this help
|
26
|
+
-v, --verbose verbose output
|
27
|
+
--version
|
28
|
+
|
29
|
+
For example:
|
30
|
+
|
31
|
+
$ zettel_outline -f outline.txt -a /path/to/notes/ -o draft.txt
|
32
|
+
|
33
|
+
This will read the `outline.txt` from the current directory. It will resolve every Zettel reference using the Zettel note archive (`/path/to/notes/`) and concatenate the notes's contents into `draft.txt`.
|
34
|
+
|
35
|
+
A sample outline can look like this:
|
36
|
+
|
37
|
+
* 201407030825 Why baking is so important for life. I really love baking
|
38
|
+
* 201601231448 Banana cake. The very best cake ever
|
39
|
+
* 201601222058 Nutritional value of bananas
|
40
|
+
* 201601222035 Nutritional value of eggs
|
41
|
+
|
42
|
+
The nested list of Zettel references will be split into:
|
43
|
+
|
44
|
+
1. The Zettel ID, used to find the note in your archive; e.g. "201407030825"
|
45
|
+
2. The note title, used for the draft's output; e.g. "Why baking is so important for life"
|
46
|
+
3. The comment, which is everything after the first period in the line; e.g. "I really love baking"
|
47
|
+
|
48
|
+
Zettel note contents will be separated using Markdown-enabled HTML comments, which are surrounded with `<!--` and `-->`. So the resulting `draft.txt` will look similar to this:
|
49
|
+
|
50
|
+
<!-- §201407030825 Why baking is so important for life -->
|
51
|
+
<!-- I really love baking -->
|
52
|
+
|
53
|
+
Baking is one of the oldest and definitely one of the
|
54
|
+
most delicious ways to prepare food.
|
55
|
+
|
56
|
+
...
|
57
|
+
|
58
|
+
|
59
|
+
## Usage of the library
|
60
|
+
|
61
|
+
The higher-level interface of the gem is very simple. Wrapping every parameter into a `compile` function can look like this:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
def compile(outline_path, notes_path, draft_path)
|
65
|
+
content = File.read(outline_path)
|
66
|
+
result = ZettelOutline::compile(content, notes_path)
|
67
|
+
File.open(draft_path, "w") do |f|
|
68
|
+
f.write(ZettelOutline::render(result))
|
69
|
+
end
|
70
|
+
end
|
71
|
+
```
|
72
|
+
|
73
|
+
* `ZettelOutline::compile` takes the outline as a string and the path to resolve note references.
|
74
|
+
* `ZettelOutline::render` is just a wrapper to concatenate the result and return a simple string.
|
75
|
+
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/DivineDominion/zettel-outline-rendering>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
80
|
+
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
85
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zettel_outline/zettel_outline"
|
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
data/bin/test
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zettel_outline"
|
5
|
+
|
6
|
+
PATH = File.expand_path("~/Archiv/")
|
7
|
+
|
8
|
+
testoutline = <<EOF
|
9
|
+
* 201509250830 Wie man mit Ausnahmen bei guten Habits umgeht. the comment
|
10
|
+
* 201510101029 Bilderquellen im Internet. another comment
|
11
|
+
* 201509281235 Serial Queues
|
12
|
+
* 201509011226 Freie Funktionen über
|
13
|
+
EOF
|
14
|
+
|
15
|
+
zettel = ZettelOutline::compile(testoutline, PATH)
|
16
|
+
puts ZettelOutline::render(zettel)
|
17
|
+
|
data/exe/zettel_outline
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "zettel_outline"
|
4
|
+
require "slop"
|
5
|
+
require "colorize"
|
6
|
+
|
7
|
+
opts = Slop.parse(ARGV, suppress_errors: true) do |o|
|
8
|
+
o.banner = "usage: #$PROGRAM_NAME -f <OUTLINE FILE> -a <ARCHIVE PATH> -o <DRAFT FILE>"
|
9
|
+
|
10
|
+
o.separator ""
|
11
|
+
o.separator "Required options:"
|
12
|
+
o.string '-f', '--file', 'an outline file'
|
13
|
+
o.string '-a', '--archive', 'path to your Zettel notes'
|
14
|
+
o.string '-o', '--output', 'file to write results to'
|
15
|
+
|
16
|
+
o.separator ""
|
17
|
+
o.separator "Also available:"
|
18
|
+
o.null '-h', '--help', 'prints this help'
|
19
|
+
o.bool '-v', '--verbose', 'verbose output', default: false, :argument => :optional
|
20
|
+
o.on "--version", :argument => :optional do
|
21
|
+
puts "zettel_outline #{ZettelOutline::VERSION} (#{ZettelOutline::DATE})"
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if ARGV.include?('-h') || ARGV.include?('--help')
|
27
|
+
puts opts
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
class Command
|
32
|
+
attr_accessor :file, :archive, :output, :verbose
|
33
|
+
|
34
|
+
def initialize(opts)
|
35
|
+
abort("--file required") if opts[:file].nil?
|
36
|
+
abort("--archive required") if opts[:archive].nil?
|
37
|
+
abort("--output required") if opts[:output].nil?
|
38
|
+
|
39
|
+
opts.to_hash.each do |k, v| send("#{k}=", v) end
|
40
|
+
end
|
41
|
+
|
42
|
+
def check_permissions!
|
43
|
+
abort("Could not open file '#{@file}'.".red) unless File.readable?(@file)
|
44
|
+
abort("Could not write to file '#{@output}'.") if File.directory?(@output)
|
45
|
+
abort("Zettel archive does not exist at '#{@archive}'.".red) unless File.directory?(@archive)
|
46
|
+
end
|
47
|
+
|
48
|
+
def execute
|
49
|
+
check_permissions!
|
50
|
+
|
51
|
+
in_path = File.expand_path(@file)
|
52
|
+
log("Reading in outline from #{in_path} ...")
|
53
|
+
content = File.read(@file)
|
54
|
+
|
55
|
+
log("Compiling draft from Zettel ...")
|
56
|
+
result = ZettelOutline::compile(content, @archive)
|
57
|
+
|
58
|
+
out_path = File.expand_path(@output)
|
59
|
+
log("Writing to #{out_path} ...")
|
60
|
+
File.open(out_path, "w") do |f|
|
61
|
+
f.write(ZettelOutline::render(result))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def log(msg)
|
66
|
+
puts msg.green if @verbose
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
Command.new(opts).execute
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "zettel_outline/version"
|
2
|
+
require 'zettel_outline/outline'
|
3
|
+
require 'zettel_outline/outline_item'
|
4
|
+
require 'zettel_outline/archive'
|
5
|
+
require 'zettel_outline/zettel_info'
|
6
|
+
require 'zettel_outline/zettel_renderer'
|
7
|
+
require 'zettel_outline/zettel'
|
8
|
+
|
9
|
+
module ZettelOutline
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def compile(outline_content, folder)
|
14
|
+
outline = Outline.new(outline_content)
|
15
|
+
all_items = outline.map_files { |f| ZettelInfo.new(f) }
|
16
|
+
.map { |info| OutlineItem.new(info) }
|
17
|
+
renderer = ZettelRenderer.new()
|
18
|
+
archive = Archive.new(folder)
|
19
|
+
|
20
|
+
all_items.map { |z| z.render(renderer, archive) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def render(outline)
|
24
|
+
outline.join("")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'zettel_outline/zettel'
|
2
|
+
|
3
|
+
module ZettelOutline
|
4
|
+
|
5
|
+
class Finder
|
6
|
+
def file_path(folder, id)
|
7
|
+
Dir.glob(File.join(folder, "#{id}*")).first
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Archive
|
12
|
+
def initialize(folder)
|
13
|
+
@folder = folder
|
14
|
+
end
|
15
|
+
|
16
|
+
def zettel(id, finder = Finder.new)
|
17
|
+
create_zettel(path(id, finder))
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_zettel(path)
|
21
|
+
return NullZettel.new if path.nil?
|
22
|
+
|
23
|
+
Zettel.new(path)
|
24
|
+
end
|
25
|
+
|
26
|
+
def path(id, finder = Finder.new)
|
27
|
+
finder.file_path(@folder, id)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "zettel_outline/outline_parser"
|
2
|
+
|
3
|
+
module ZettelOutline
|
4
|
+
class Outline
|
5
|
+
attr_reader :content
|
6
|
+
attr_reader :files
|
7
|
+
|
8
|
+
def initialize(content)
|
9
|
+
@content = content || ""
|
10
|
+
end
|
11
|
+
|
12
|
+
def files(parser = OutlineParser.new)
|
13
|
+
return [] if @content.empty?
|
14
|
+
|
15
|
+
@files = parser.parse(content) if @files.nil?
|
16
|
+
@files
|
17
|
+
end
|
18
|
+
|
19
|
+
def map_files(parser = OutlineParser.new, &block)
|
20
|
+
if block_given?
|
21
|
+
files(parser).map { |f| yield f }
|
22
|
+
else
|
23
|
+
to_enum(:map_files, parser)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ZettelOutline
|
2
|
+
class OutlineItem
|
3
|
+
|
4
|
+
def initialize(zettel_info)
|
5
|
+
@zettel_info = zettel_info
|
6
|
+
end
|
7
|
+
|
8
|
+
def render(renderer, archive)
|
9
|
+
renderer.render(zettel(archive), @zettel_info)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def zettel(archive)
|
15
|
+
id = @zettel_info.id
|
16
|
+
archive.zettel(id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ZettelOutline
|
2
|
+
class OutlineParser
|
3
|
+
def parse(content)
|
4
|
+
content.each_line
|
5
|
+
.map { |l| l.strip }
|
6
|
+
.select { |l| !l.empty? }
|
7
|
+
.map { |l| cleanup(l) }
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def cleanup(line)
|
13
|
+
raise "empty line" if line.nil? || line.empty?
|
14
|
+
|
15
|
+
line[/^[\* ]*(.+)$/, 1]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ZettelOutline
|
2
|
+
class Zettel
|
3
|
+
def initialize(path)
|
4
|
+
raise "file path needed" if path.nil?
|
5
|
+
raise "file expected at path" unless File.file?(path)
|
6
|
+
|
7
|
+
@path = path
|
8
|
+
end
|
9
|
+
|
10
|
+
def render
|
11
|
+
remove_header(file_contents).join("")
|
12
|
+
end
|
13
|
+
|
14
|
+
def file_contents
|
15
|
+
File.readlines(@path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def remove_header(text)
|
19
|
+
text
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class NullZettel
|
24
|
+
def render
|
25
|
+
""
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ZettelOutline
|
2
|
+
class ZettelInfo
|
3
|
+
|
4
|
+
def initialize(line)
|
5
|
+
@line = line
|
6
|
+
end
|
7
|
+
|
8
|
+
def id
|
9
|
+
@line[/[0-9]+/]
|
10
|
+
end
|
11
|
+
|
12
|
+
def title
|
13
|
+
@line[/[0-9]+ ([\d\w_\- ]+?)(?:\..*)?$/, 1]
|
14
|
+
end
|
15
|
+
|
16
|
+
def comment
|
17
|
+
@line[/[0-9]+ [\d\w_\- ]+\.[ ]*(.*)$/, 1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def info
|
21
|
+
{ id: id, title: title, comment: comment }
|
22
|
+
end
|
23
|
+
|
24
|
+
def render
|
25
|
+
"".tap do |output|
|
26
|
+
output << "\n"
|
27
|
+
output << %Q{<!-- §#{id} #{title}-->\n}
|
28
|
+
output << %Q{<!-- #{comment}-->\n} unless comment.nil?
|
29
|
+
output << "\n"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'zettel_outline/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "zettel_outline"
|
8
|
+
spec.version = ZettelOutline::VERSION
|
9
|
+
spec.authors = ["Christian Tietze"]
|
10
|
+
spec.email = ["christian.tietze@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Converts a plain text/Markdown outline of Zettel note references into a document.}
|
13
|
+
spec.description = %q{Using outlines to plan writing projects is great, but assembling a first draft is still tiresome work. Adhere to this gem's outline convention and assemble first drafts in no time.}
|
14
|
+
spec.homepage = "http://zettelkasten.de/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_runtime_dependency "slop", "~> 4.2"
|
26
|
+
spec.add_runtime_dependency "colorize", "~> 0.7"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zettel_outline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Tietze
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-26 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: slop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: colorize
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.7'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.7'
|
83
|
+
description: Using outlines to plan writing projects is great, but assembling a first
|
84
|
+
draft is still tiresome work. Adhere to this gem's outline convention and assemble
|
85
|
+
first drafts in no time.
|
86
|
+
email:
|
87
|
+
- christian.tietze@gmail.com
|
88
|
+
executables:
|
89
|
+
- zettel_outline
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- LICENSE
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/setup
|
103
|
+
- bin/test
|
104
|
+
- exe/zettel_outline
|
105
|
+
- lib/zettel_outline.rb
|
106
|
+
- lib/zettel_outline/archive.rb
|
107
|
+
- lib/zettel_outline/outline.rb
|
108
|
+
- lib/zettel_outline/outline_item.rb
|
109
|
+
- lib/zettel_outline/outline_parser.rb
|
110
|
+
- lib/zettel_outline/version.rb
|
111
|
+
- lib/zettel_outline/zettel.rb
|
112
|
+
- lib/zettel_outline/zettel_info.rb
|
113
|
+
- lib/zettel_outline/zettel_renderer.rb
|
114
|
+
- zettel_outline.gemspec
|
115
|
+
homepage: http://zettelkasten.de/
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.4.5
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: Converts a plain text/Markdown outline of Zettel note references into a document.
|
139
|
+
test_files: []
|