zet 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0839a2349887f44ef2cd431b634152fe754c4f775cf1088bd218bdd5f4e5948e'
4
+ data.tar.gz: 29c45ac355aeeefd8a8d0c077249c26b7c0d311a4cdd08a5d12b17bb191c1ae3
5
+ SHA512:
6
+ metadata.gz: bddd85c7f58a703e194f4180a09c62df34d69d9f1b2058169d8ab9f504205852c259c672f4d241bf306f096ff5a105f26ca07ffc6e0463ea8db152798b10dd3b
7
+ data.tar.gz: 113f410ef3a74335be5cd6f032ef85f441d8fb9fc967ba6754d1f97775aa9112e3a8d82f4adf33c75da341bcf1a351e133ca365f6d43fec70906fd8df82b8fd3
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Anatoli Makarevich
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/bin/zet ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "zet"
4
+ require "zet/cli"
5
+
6
+ exit Zet::CLI.new.run(ARGV)
@@ -0,0 +1 @@
1
+ require "zet/version"
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ $LOAD_PATH << File.expand_path(__dir__)
6
+
7
+ module Zet
8
+ # CLI class is responsible for handling command-line arguments.
9
+ #
10
+ class CLI
11
+ # CLI is used when running zet from command line (check bin/zet) file.
12
+ #
13
+ def run(args = [])
14
+ if args.first == "note"
15
+ require "fileutils"
16
+
17
+ if Dir.exists?("notes")
18
+ note_name = args[1]
19
+
20
+ if note_name.nil?
21
+ puts "Provide a name of your note, please"
22
+ else
23
+ note_file = note_file(note_name)
24
+
25
+ if File.exists?(note_file)
26
+ puts "This file already exists: #{note_file}! 🙀"
27
+ else
28
+ FileUtils.open(note_file, "w") do |file|
29
+ template = File.read("note_teamplate.md")
30
+ template.gsub("# HEADLINE", note_name)
31
+
32
+ file.puts(template)
33
+ end
34
+ end
35
+ end
36
+ else
37
+ puts "Hm, I don't see the \"notes\" folder 🤔"
38
+ end
39
+
40
+ 0
41
+ else
42
+ puts "Hm, I don't know this command 🤔"
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ # This method is needed to unindent
49
+ # ["here document"](https://en.wikibooks.org/wiki/Ruby_Programming/Here_documents)
50
+ # help description.
51
+ #
52
+ def unindent(str)
53
+ str.gsub(/^#{str.scan(/^[ \t]+(?=\S)/).min}/, "")
54
+ end
55
+
56
+ def note_file(name)
57
+ slug = name.downcase.gsub(/\W/, "").split(" ").join("-")
58
+ timestamp = Time.now.strftime("%Y%m%d%H%M")
59
+
60
+ File.join("notes", "#{timestamp}-#{slug}.md")
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Module to keep the gem's version in. Make sure to bump it before release.
4
+ #
5
+ module Zet
6
+ VERSION = "0.1.0".freeze
7
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anatoli Makarevich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-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: 2.2.3
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.2.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: CLI tool to organize notes, inspired by Zettelkasten
70
+ email:
71
+ - makaroni4@gmail.com
72
+ executables:
73
+ - zet
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE.txt
78
+ - bin/zet
79
+ - lib/zet.rb
80
+ - lib/zet/cli.rb
81
+ - lib/zet/version.rb
82
+ homepage: https://github.com/makaroni4/zet
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.0.3
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: CLI tool to organize notes, inspired by Zettelkasten
105
+ test_files: []