how2 0.0.1

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
+ SHA256:
3
+ metadata.gz: f2490b72d583461997e26840063512ed57781be00fb3c1059a95bf452a1e5e31
4
+ data.tar.gz: b88a422bedd75ce21a0449739cc351a7bc9f6109e3bd50f8a3b6d677aa0cbf6d
5
+ SHA512:
6
+ metadata.gz: 654c8912bd244c10fe8d5ea66b59bae82ceb368907beddc123bdf171845fb55d1ad5f6b2cb2907ad2e1f642f1c76c6443425f07bded230c41c21ee6817dff4ac
7
+ data.tar.gz: c001d5bd6be174a4515753abb17ff12f73adf696b8043124f8a85440c1224d249d488ece19e23f99794824bf096161227f06ef68b57392e002c31c5dc74a5457
data/LICENSE.txt ADDED
@@ -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/how2 ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "howto"
4
+ require "howto/cli"
5
+
6
+ exit Howto::CLI.new.run(ARGV)
data/lib/howto.rb ADDED
@@ -0,0 +1 @@
1
+ require "howto/version"
data/lib/howto/cli.rb ADDED
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+
5
+ $LOAD_PATH << File.expand_path(__dir__)
6
+
7
+ module Howto
8
+ # CLI class is responsible for handling command-line arguments.
9
+ #
10
+ class CLI
11
+ # CLI is used when running howto from command line (check bin/howto) 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
+ File.open(note_file, "w") do |file|
29
+ template = File.read(File.join(Dir.pwd, "note_template.md"))
30
+ template.gsub!("# HEADLINE", "# #{note_name}")
31
+
32
+ file.puts(template)
33
+ end
34
+
35
+ system `code .`
36
+ system `code #{note_file}`
37
+ end
38
+ end
39
+ else
40
+ puts "Hm, I don't see the \"notes\" folder 🤔"
41
+ end
42
+
43
+ 0
44
+ else
45
+ puts "Hm, I don't know this command 🤔"
46
+ end
47
+ end
48
+
49
+ private
50
+
51
+ # This method is needed to unindent
52
+ # ["here document"](https://en.wikibooks.org/wiki/Ruby_Programming/Here_documents)
53
+ # help description.
54
+ #
55
+ def unindent(str)
56
+ str.gsub(/^#{str.scan(/^[ \t]+(?=\S)/).min}/, "")
57
+ end
58
+
59
+ def note_file(name)
60
+ slug = name.downcase.split(" ").map { |w| w.gsub(/\W/, "") }.join("-")
61
+ timestamp = Time.now.strftime("%Y%m%d%H%M")
62
+
63
+ File.join(Dir.pwd, "notes", "#{timestamp}-#{slug}.md")
64
+ end
65
+ end
66
+ 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 Howto
6
+ VERSION = "0.0.1".freeze
7
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: how2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Anatoli Makarevich
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-03-20 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.1.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.4
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 How To notes
70
+ email:
71
+ - makaroni4@gmail.com
72
+ executables:
73
+ - how2
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - LICENSE.txt
78
+ - bin/how2
79
+ - lib/howto.rb
80
+ - lib/howto/cli.rb
81
+ - lib/howto/version.rb
82
+ homepage: https://github.com/makaroni4/howto
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 How To notes
105
+ test_files: []