zoi 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d23241852fcfd819a4d44dd63b6880aeef2ec93ba9ed7f8dcf47bb65e16d30f7
4
- data.tar.gz: 781a1cb431cba40751192af7ff44516a03882f266272043c74606f5c7c2f5c32
3
+ metadata.gz: dc7a5b36e248634f14b08f1253f8805a0031adeb4a1fc8de3204f2c5fb5ead75
4
+ data.tar.gz: 570d172ae486c9804f395daca114b5c5d9287ea29770550ff4e392a4aa1c359a
5
5
  SHA512:
6
- metadata.gz: 62fae3694797624b563eef4eda673a6de6f667f713c94b45c44316bbe3a2e9283eca30047e7c6623d1c2a394edd4aae66ce5556c515a2459fef90d204f0a1259
7
- data.tar.gz: 89cdc3fbf4b3930370a66eff38df225adaa9cc9f1ffa6ebebf64474071ea37af7dcd90f68c10680c3eb0fc8860018447f6c7736be7e08dfa9ee6b21b1b842e37
6
+ metadata.gz: c43de2e301a4abd44d9e490c3b6285e45ba63cc2bd778e8020172519cc9ec99cdaa94855346435394af8d86ab562c9ab9287805e2118735e05cbca997b2a19cc
7
+ data.tar.gz: 259ab4bf3026b5f9b7161d51c26f75eb4c9c4f1559860a6a7d68c008a81adf3bf1afaf606a9c54b3ebb2d86bfb4229493685eb4660a2ebee64ee007f5cd86de5
@@ -17,5 +17,7 @@ jobs:
17
17
  ruby-version: ${{ matrix.ruby }}
18
18
  - name: Install dependencies
19
19
  run: bundle install
20
+ - name: RuboCop
21
+ run: bundle exec rubocop
20
22
  - name: Run tests
21
23
  run: ruby test/*.rb
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
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 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'thor'
7
+ gem "thor"
8
8
 
9
9
  group :development do
10
- gem 'rake', '~> 12.0'
10
+ gem "rake", "~> 12.0"
11
+ gem "rubocop-shopify", require: false
11
12
  end
12
13
 
13
14
  group :test do
14
- gem 'mocha'
15
- gem 'timecop'
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 in VSCode.
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
data/exe/zoi CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'zoi'
4
+ require "zoi"
5
5
 
6
- args = File.pipe?(STDIN) ? ARGV + STDIN.gets.chomp.split : ARGV
6
+ args = File.pipe?($stdin) ? ARGV + $stdin.gets.chomp.split : ARGV
7
7
 
8
8
  Zoi::CLI.start(args)
data/lib/zoi/cli.rb CHANGED
@@ -1,24 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'date'
4
- require 'fileutils'
5
- require 'find'
6
- require 'open3'
7
- require 'pathname'
8
- require 'thor'
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 = 'zoi'
12
+ ROOT_DIR_NAME = "zoi"
13
+ CONFIG_FILE_NAME = ".zoirc.json"
12
14
 
13
15
  class CLI < Thor
14
- desc 'create <filepath>', 'Create a new file under zoi root directory.'
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 'open <filepath>', 'Execute `create` command and open the file with the editor specified by $EDITOR. For example: `EDITOR=code zoi open foobar.rb`'
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 'list [-d]', 'List all files under zoi root directory.'
33
- option 'd', type: :boolean
37
+ desc "list [-d]", "List all files under zoi root directory."
38
+ option "d", type: :boolean
34
39
  def list
35
- only_directory = options['d']
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 'memo', "Create today's memo file and open the file with the editor specified by `$EDITOR`."
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 'root', 'Print zoi root directory.'
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 'root' => 'root_command'
63
+ map "root" => "root_command"
59
64
 
60
65
  no_tasks do
61
66
  def editor
62
- @editor ||= ENV['EDITOR']
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zoi
4
- VERSION = '0.1.3'
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/zoi.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'zoi/version'
4
- require_relative 'zoi/cli.rb'
3
+ require_relative "zoi/version"
4
+ require_relative "zoi/cli"
5
5
 
6
6
  module Zoi; end
data/zoi.gemspec CHANGED
@@ -1,28 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/zoi/version'
3
+ require_relative "lib/zoi/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'zoi'
6
+ spec.name = "zoi"
7
7
  spec.version = Zoi::VERSION
8
- spec.authors = ['9sako6']
9
- spec.email = ['31821663+9sako6@users.noreply.github.com']
8
+ spec.authors = ["9sako6"]
9
+ spec.email = ["31821663+9sako6@users.noreply.github.com"]
10
10
 
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')
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['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'
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
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
24
  end
25
- spec.bindir = 'exe'
25
+ spec.bindir = "exe"
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ['lib']
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.3
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: 2021-09-15 00:00:00.000000000 Z
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