zoi 0.0.1 → 0.1.0
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 +21 -0
- data/.gitignore +1 -0
- data/CHANGELOG.adoc +4 -0
- data/Gemfile +8 -0
- data/README.adoc +58 -0
- data/Rakefile +2 -0
- data/exe/zoi +4 -9
- data/lib/zoi.rb +4 -41
- data/lib/zoi/cli.rb +64 -0
- data/lib/zoi/version.rb +3 -1
- metadata +6 -6
- data/CHANGELOG.md +0 -0
- data/README.md +0 -35
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcf9ada58a6c4d261304bf85581a811ca84745c1820e7f08e1141cb11f1605d8
|
4
|
+
data.tar.gz: e3edf9ec712d10b3edc73b299d5144c1d6befd3e1d25810467ef5cffaf26577f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 572cf635f41310c624aa38ae43dbe1b34cdf10830bcadc7367334eb463806ffc2783e847f60a5929d5014d2f7ccba895f99c37ffc751e5b676213b5b2c630e9e
|
7
|
+
data.tar.gz: ca5cfb874c5e37f3028b114b5d6c77141d9a0de891f833dca34db903df10d6d10915849a49e413e2d662d9be14427e3c9bb45200fa5a61e395027483ae834f89
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
strategy:
|
8
|
+
matrix:
|
9
|
+
os: [macos-latest, ubuntu-latest]
|
10
|
+
ruby: [2.7, 3.0]
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: ${{ matrix.ruby }}
|
18
|
+
- name: Install dependencies
|
19
|
+
run: bundle install
|
20
|
+
- name: Run tests
|
21
|
+
run: ruby test/*.rb
|
data/.gitignore
CHANGED
data/CHANGELOG.adoc
ADDED
data/Gemfile
CHANGED
data/README.adoc
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
= zoi(1)
|
2
|
+
|
3
|
+
== NAME
|
4
|
+
|
5
|
+
zoi - Manage snippets
|
6
|
+
|
7
|
+
== DESCRIPTION
|
8
|
+
|
9
|
+
Manage snippets.
|
10
|
+
|
11
|
+
[verse]
|
12
|
+
zoi c ruby/foo.rb
|
13
|
+
# ~/zoi/ruby/foo.rb is created.
|
14
|
+
|
15
|
+
== SYNOPSIS
|
16
|
+
|
17
|
+
[verse]
|
18
|
+
zoi create <filepath>
|
19
|
+
zoi open <filepath>
|
20
|
+
zoi list [-d]
|
21
|
+
zoi root
|
22
|
+
zoi help
|
23
|
+
|
24
|
+
== COMMANDS
|
25
|
+
|
26
|
+
create::
|
27
|
+
Create a new file under zoi root directory. If the file already exists, the file isn't created. +
|
28
|
+
In all cases, the full path of the file is printed to stdout.
|
29
|
+
|
30
|
+
open::
|
31
|
+
Execute `create` command and open the file with the editor specified by `$EDITOR`. For example: `EDITOR=code zoi open foobar.rb`
|
32
|
+
|
33
|
+
list::
|
34
|
+
List all files under zoi root directory. +
|
35
|
+
With '-d' option, list all directories under zoi root directory.
|
36
|
+
|
37
|
+
root::
|
38
|
+
Print zoi root directory.
|
39
|
+
|
40
|
+
help::
|
41
|
+
Print a brief help message.
|
42
|
+
|
43
|
+
== INSTALLATION
|
44
|
+
|
45
|
+
gem install zoi
|
46
|
+
|
47
|
+
== EXAMPLES
|
48
|
+
|
49
|
+
Open today's memo file in VSCode.
|
50
|
+
|
51
|
+
[verse]
|
52
|
+
code $(date "+%Y%m%d.adoc" | zoi c)
|
53
|
+
|
54
|
+
A new file ~/zoi/20210727.adoc is created and is opend in VSCode.
|
55
|
+
|
56
|
+
== AUTHOR
|
57
|
+
|
58
|
+
https://github.com/9sako6[9sako6]
|
data/Rakefile
CHANGED
data/exe/zoi
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require 'zoi'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
when '-t', '--today'
|
9
|
-
puts Zoi.today_file
|
10
|
-
when nil
|
11
|
-
new_file_path = Zoi.create
|
12
|
-
new_file_path.nil? ? nil : (puts new_file_path)
|
13
|
-
end
|
6
|
+
args = File.pipe?(STDIN) ? ARGV + STDIN.gets.chomp.split : ARGV
|
7
|
+
|
8
|
+
Zoi::CLI.start(args)
|
data/lib/zoi.rb
CHANGED
@@ -1,43 +1,6 @@
|
|
1
|
-
|
2
|
-
require 'fileutils'
|
3
|
-
require_relative 'zoi/version'
|
4
|
-
|
5
|
-
module Zoi
|
6
|
-
class Error < StandardError; end
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def create
|
10
|
-
FileUtils.mkdir_p(root_path)
|
11
|
-
|
12
|
-
return if File.exist?(today_file)
|
13
|
-
|
14
|
-
File.open(today_file, 'w') do |f|
|
15
|
-
f.puts "# #{today}"
|
16
|
-
end
|
17
|
-
|
18
|
-
today_file
|
19
|
-
end
|
1
|
+
# frozen_string_literal: true
|
20
2
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def today_file
|
26
|
-
File.join(root_path, file_name)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def file_name
|
32
|
-
"#{today}.md"
|
33
|
-
end
|
34
|
-
|
35
|
-
def today
|
36
|
-
Date.today.strftime('%Y%m%d')
|
37
|
-
end
|
3
|
+
require_relative 'zoi/version'
|
4
|
+
require_relative 'zoi/cli.rb'
|
38
5
|
|
39
|
-
|
40
|
-
File.join(Dir.home, name.downcase)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
6
|
+
module Zoi; end
|
data/lib/zoi/cli.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
require 'find'
|
5
|
+
require 'open3'
|
6
|
+
require 'thor'
|
7
|
+
|
8
|
+
module Zoi
|
9
|
+
ROOT_DIR_NAME = 'zoi'
|
10
|
+
|
11
|
+
class CLI < Thor
|
12
|
+
desc 'create <filepath>', 'Create a new file under zoi root directory.'
|
13
|
+
def create(file_path)
|
14
|
+
return if file_path.nil?
|
15
|
+
|
16
|
+
puts create_file(file_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'open <filepath>', 'Execute `create` command and open the file with the editor specified by $EDITOR. For example: `EDITOR=code zoi open foobar.rb`'
|
20
|
+
def open(file_path)
|
21
|
+
return if editor.nil? || file_path.nil?
|
22
|
+
|
23
|
+
created_file_path = create_file(file_path)
|
24
|
+
|
25
|
+
puts created_file_path
|
26
|
+
|
27
|
+
open_file(created_file_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'list [-d]', 'List all files under zoi root directory.'
|
31
|
+
option 'd', type: :boolean
|
32
|
+
def list
|
33
|
+
only_directory = options['d']
|
34
|
+
|
35
|
+
puts(Find.find(root_path).select { |path| only_directory ? File.directory?(path) : File.file?(path) })
|
36
|
+
end
|
37
|
+
|
38
|
+
no_tasks do
|
39
|
+
def editor
|
40
|
+
@editor ||= ENV['EDITOR']
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_file(file_path)
|
44
|
+
file_full_path = File.join(root_path, file_path)
|
45
|
+
|
46
|
+
return file_full_path if File.exist?(file_full_path)
|
47
|
+
|
48
|
+
dir_path = File.join(root_path, File.dirname(file_path))
|
49
|
+
|
50
|
+
FileUtils.mkdir_p(dir_path)
|
51
|
+
FileUtils.touch(file_full_path)
|
52
|
+
file_full_path
|
53
|
+
end
|
54
|
+
|
55
|
+
def open_file(file_path)
|
56
|
+
system(editor, file_path)
|
57
|
+
end
|
58
|
+
|
59
|
+
def root_path
|
60
|
+
@root_path ||= Pathname(Dir.home).join(ROOT_DIR_NAME).to_s
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/lib/zoi/version.rb
CHANGED
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 9sako6
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: management snippets
|
14
14
|
email:
|
@@ -18,16 +18,16 @@ executables:
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- ".github/workflows/test.yml"
|
21
22
|
- ".gitignore"
|
22
|
-
- CHANGELOG.
|
23
|
+
- CHANGELOG.adoc
|
23
24
|
- Gemfile
|
24
25
|
- LICENSE
|
25
|
-
- README.
|
26
|
+
- README.adoc
|
26
27
|
- Rakefile
|
27
|
-
- bin/console
|
28
|
-
- bin/setup
|
29
28
|
- exe/zoi
|
30
29
|
- lib/zoi.rb
|
30
|
+
- lib/zoi/cli.rb
|
31
31
|
- lib/zoi/version.rb
|
32
32
|
- zoi.gemspec
|
33
33
|
homepage: https://github.com/9sako6/zoi
|
data/CHANGELOG.md
DELETED
File without changes
|
data/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Zoi
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/zoi`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'zoi'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install zoi
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/zoi.
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'zoi'
|
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(__FILE__)
|