zoi 0.1.3 → 0.1.4
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 +4 -4
- data/.github/workflows/test.yml +2 -0
- data/.rubocop.yml +2 -0
- data/CHANGELOG.adoc +17 -0
- data/Gemfile +6 -5
- data/README.adoc +18 -1
- data/Rakefile +2 -2
- data/exe/zoi +2 -2
- data/lib/zoi/cli.rb +37 -16
- data/lib/zoi/version.rb +1 -1
- data/lib/zoi.rb +2 -2
- data/zoi.gemspec +14 -14
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc7a5b36e248634f14b08f1253f8805a0031adeb4a1fc8de3204f2c5fb5ead75
|
4
|
+
data.tar.gz: 570d172ae486c9804f395daca114b5c5d9287ea29770550ff4e392a4aa1c359a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43de2e301a4abd44d9e490c3b6285e45ba63cc2bd778e8020172519cc9ec99cdaa94855346435394af8d86ab562c9ab9287805e2118735e05cbca997b2a19cc
|
7
|
+
data.tar.gz: 259ab4bf3026b5f9b7161d51c26f75eb4c9c4f1559860a6a7d68c008a81adf3bf1afaf606a9c54b3ebb2d86bfb4229493685eb4660a2ebee64ee007f5cd86de5
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
ADDED
data/CHANGELOG.adoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
== 0.1.4 (January 6, 2022)
|
2
|
+
|
3
|
+
=== Enhancements
|
4
|
+
* Add a configuration file, __~/.zoirc.json__ https://github.com/9sako6/zoi/pull/17[#17]
|
5
|
+
** You can optionally save the settings used by zoi to a configuration file, __~/.zoirc.json__. +
|
6
|
+
The type of editor used by zoi can be specified in the __~/.zoirc.json__ file. +
|
7
|
+
The following is the example of the __~/.zoirc.json__ file.
|
8
|
+
+
|
9
|
+
[source,json]
|
10
|
+
----
|
11
|
+
{
|
12
|
+
"editor": "code"
|
13
|
+
}
|
14
|
+
----
|
15
|
+
+
|
16
|
+
In that case, there is no need to pass the `EDITOR` environment variable at runtime.
|
17
|
+
|
1
18
|
== 0.1.3 (September 15, 2021)
|
2
19
|
|
3
20
|
=== Enhancements
|
data/Gemfile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gemspec
|
6
6
|
|
7
|
-
gem
|
7
|
+
gem "thor"
|
8
8
|
|
9
9
|
group :development do
|
10
|
-
gem
|
10
|
+
gem "rake", "~> 12.0"
|
11
|
+
gem "rubocop-shopify", require: false
|
11
12
|
end
|
12
13
|
|
13
14
|
group :test do
|
14
|
-
gem
|
15
|
-
gem
|
15
|
+
gem "mocha"
|
16
|
+
gem "timecop"
|
16
17
|
end
|
data/README.adoc
CHANGED
@@ -41,7 +41,7 @@ memo::
|
|
41
41
|
Create today's memo file and open the file with the editor specified by `$EDITOR`. +
|
42
42
|
The file name is `YYYY-MM-DD.md` +
|
43
43
|
For example: `EDITOR=code zoi open memo/20210101.md` +
|
44
|
-
If it's September 9th in 2021, a new file ~/zoi/2021-09-09.md is created and is opend
|
44
|
+
If it's September 9th in 2021, a new file ~/zoi/2021-09-09.md is created and is opend with the VSCode editor.
|
45
45
|
|
46
46
|
root::
|
47
47
|
Print zoi root directory.
|
@@ -53,6 +53,23 @@ help::
|
|
53
53
|
|
54
54
|
gem install zoi
|
55
55
|
|
56
|
+
== CONFIGURATION
|
57
|
+
|
58
|
+
You can optionally save the settings used by zoi to a configuration file, __~/.zoirc.json__.
|
59
|
+
|
60
|
+
The type of editor used by zoi can be specified in the __~/.zoirc.json__ file.
|
61
|
+
|
62
|
+
The following is the example of the __~/.zoirc.json__ file.
|
63
|
+
|
64
|
+
[source,json]
|
65
|
+
----
|
66
|
+
{
|
67
|
+
"editor": "code"
|
68
|
+
}
|
69
|
+
----
|
70
|
+
|
71
|
+
In that case, there is no need to pass the `EDITOR` environment variable at runtime.
|
72
|
+
|
56
73
|
== EXAMPLES
|
57
74
|
|
58
75
|
* Change directories
|
data/Rakefile
CHANGED
data/exe/zoi
CHANGED
data/lib/zoi/cli.rb
CHANGED
@@ -1,24 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "date"
|
4
|
+
require "fileutils"
|
5
|
+
require "find"
|
6
|
+
require "json"
|
7
|
+
require "open3"
|
8
|
+
require "pathname"
|
9
|
+
require "thor"
|
9
10
|
|
10
11
|
module Zoi
|
11
|
-
ROOT_DIR_NAME =
|
12
|
+
ROOT_DIR_NAME = "zoi"
|
13
|
+
CONFIG_FILE_NAME = ".zoirc.json"
|
12
14
|
|
13
15
|
class CLI < Thor
|
14
|
-
desc
|
16
|
+
desc "create <filepath>", "Create a new file under zoi root directory."
|
15
17
|
def create(file_path)
|
16
18
|
return if file_path.nil?
|
17
19
|
|
18
20
|
puts create_file(file_path)
|
19
21
|
end
|
20
22
|
|
21
|
-
desc
|
23
|
+
desc "open <filepath>", <<~DESCRIPTION
|
24
|
+
Execute `create` command and open the file with the editor specified by $EDITOR.
|
25
|
+
For example: `EDITOR=code zoi open foobar.rb`
|
26
|
+
DESCRIPTION
|
22
27
|
def open(file_path)
|
23
28
|
return if editor.nil? || file_path.nil?
|
24
29
|
|
@@ -29,15 +34,15 @@ module Zoi
|
|
29
34
|
open_file(created_file_path)
|
30
35
|
end
|
31
36
|
|
32
|
-
desc
|
33
|
-
option
|
37
|
+
desc "list [-d]", "List all files under zoi root directory."
|
38
|
+
option "d", type: :boolean
|
34
39
|
def list
|
35
|
-
only_directory = options[
|
40
|
+
only_directory = options["d"]
|
36
41
|
|
37
42
|
puts(Find.find(root_path).select { |path| only_directory ? File.directory?(path) : File.file?(path) })
|
38
43
|
end
|
39
44
|
|
40
|
-
desc
|
45
|
+
desc "memo", "Create today's memo file and open the file with the editor specified by `$EDITOR`."
|
41
46
|
def memo
|
42
47
|
return if editor.nil?
|
43
48
|
|
@@ -48,18 +53,22 @@ module Zoi
|
|
48
53
|
open_file(created_file_path)
|
49
54
|
end
|
50
55
|
|
51
|
-
desc
|
56
|
+
desc "root", "Print zoi root directory."
|
52
57
|
def root_command
|
53
58
|
puts root_path
|
54
59
|
end
|
55
60
|
|
56
61
|
# NOTE: Resolve the following error.
|
57
62
|
# `"root" is a Thor reserved word and cannot be defined as command`
|
58
|
-
map
|
63
|
+
map "root" => "root_command"
|
59
64
|
|
60
65
|
no_tasks do
|
61
66
|
def editor
|
62
|
-
|
67
|
+
if File.exist?(config_file_path)
|
68
|
+
load_envs_from_config_file
|
69
|
+
end
|
70
|
+
|
71
|
+
ENV["EDITOR"]
|
63
72
|
end
|
64
73
|
|
65
74
|
def create_file(file_path)
|
@@ -81,6 +90,18 @@ module Zoi
|
|
81
90
|
def root_path
|
82
91
|
@root_path ||= Pathname(Dir.home).join(ROOT_DIR_NAME).to_s
|
83
92
|
end
|
93
|
+
|
94
|
+
def config_file_path
|
95
|
+
@config_file_path ||= Pathname(Dir.home).join(CONFIG_FILE_NAME).to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
def config_json
|
99
|
+
@config_json ||= JSON.parse(File.open(config_file_path, "r", &:read))
|
100
|
+
end
|
101
|
+
|
102
|
+
def load_envs_from_config_file
|
103
|
+
ENV["EDITOR"] = config_json["editor"] unless ENV["EDITOR"]
|
104
|
+
end
|
84
105
|
end
|
85
106
|
end
|
86
107
|
end
|
data/lib/zoi/version.rb
CHANGED
data/lib/zoi.rb
CHANGED
data/zoi.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "lib/zoi/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = "zoi"
|
7
7
|
spec.version = Zoi::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ["9sako6"]
|
9
|
+
spec.email = ["31821663+9sako6@users.noreply.github.com"]
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
11
|
+
spec.summary = "management snippets"
|
12
|
+
spec.description = "management snippets"
|
13
|
+
spec.homepage = "https://github.com/9sako6/zoi"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
15
15
|
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/9sako6/zoi"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/9sako6/zoi"
|
19
19
|
|
20
20
|
# Specify which files should be added to the gem when it is released.
|
21
21
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
22
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
-
|
23
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
24
|
end
|
25
|
-
spec.bindir =
|
25
|
+
spec.bindir = "exe"
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
|
-
spec.require_paths = [
|
27
|
+
spec.require_paths = ["lib"]
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 9sako6
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: management snippets
|
14
14
|
email:
|
@@ -20,6 +20,7 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- ".github/workflows/test.yml"
|
22
22
|
- ".gitignore"
|
23
|
+
- ".rubocop.yml"
|
23
24
|
- CHANGELOG.adoc
|
24
25
|
- Gemfile
|
25
26
|
- LICENSE
|