shufu 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 +7 -0
- data/.rspec +4 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +68 -0
- data/README.md +47 -0
- data/Rakefile +8 -0
- data/lib/shufu/item.rb +30 -0
- data/lib/shufu/line.rb +23 -0
- data/lib/shufu/schema.rb +15 -0
- data/lib/shufu/version.rb +5 -0
- data/lib/shufu.rb +6 -0
- data/shufu.gemspec +28 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12426f786a5f221e6dc2eb0f8e42ec570605ea72da92c37db6afa2e5149f012b
|
4
|
+
data.tar.gz: 8c347d6d7235ea550b13764aea9938c6537cd6a4cbcf97225c5fb519d718d0b4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 338e7cd729aeeb3a4cffc29b88efcc31fca565f3f99dad03ff2235e45791c07c73ff52ec218a50fa22c16ca1e41270af3879b1123004354ff12132222e256383
|
7
|
+
data.tar.gz: 44b768f08c3d30ff311ece22978683a6ef1c6dcfcf5564fcd4275d7c7b08d4e210e2b1eec6fc6955179133c23621fd00f69d53951a5d4a35bbf8c6f818442201
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
shufu (0.1.0)
|
5
|
+
dry-schema
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
concurrent-ruby (1.1.9)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
dry-configurable (0.14.0)
|
13
|
+
concurrent-ruby (~> 1.0)
|
14
|
+
dry-core (~> 0.6)
|
15
|
+
dry-container (0.9.0)
|
16
|
+
concurrent-ruby (~> 1.0)
|
17
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
18
|
+
dry-core (0.7.1)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
dry-inflector (0.2.1)
|
21
|
+
dry-initializer (3.1.0)
|
22
|
+
dry-logic (1.2.0)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
dry-core (~> 0.5, >= 0.5)
|
25
|
+
dry-schema (1.8.0)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
dry-configurable (~> 0.13, >= 0.13.0)
|
28
|
+
dry-core (~> 0.5, >= 0.5)
|
29
|
+
dry-initializer (~> 3.0)
|
30
|
+
dry-logic (~> 1.0)
|
31
|
+
dry-types (~> 1.5)
|
32
|
+
dry-types (1.5.1)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
dry-container (~> 0.3)
|
35
|
+
dry-core (~> 0.5, >= 0.5)
|
36
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
37
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
38
|
+
power_assert (1.1.7)
|
39
|
+
rake (13.0.6)
|
40
|
+
rspec (3.10.0)
|
41
|
+
rspec-core (~> 3.10.0)
|
42
|
+
rspec-expectations (~> 3.10.0)
|
43
|
+
rspec-mocks (~> 3.10.0)
|
44
|
+
rspec-core (3.10.1)
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-expectations (3.10.2)
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-mocks (3.10.2)
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-power_assert (1.1.0)
|
53
|
+
power_assert (~> 1.1.0)
|
54
|
+
rspec (>= 2.14)
|
55
|
+
rspec-support (3.10.3)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
x86_64-darwin-20
|
59
|
+
x86_64-linux
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
rake (~> 13.0)
|
63
|
+
rspec (~> 3.0)
|
64
|
+
rspec-power_assert
|
65
|
+
shufu!
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.2.32
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Shufu
|
2
|
+
|
3
|
+
Shufu is a simple command line generator.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'shufu'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install shufu
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require "shufu"
|
25
|
+
|
26
|
+
Shufu::Line.new(
|
27
|
+
"git commit",
|
28
|
+
{
|
29
|
+
schema: [
|
30
|
+
{ name: "amend", type: option, flag: true },
|
31
|
+
{ name: "author", type: option, equal: true }
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{
|
35
|
+
amend: true,
|
36
|
+
author: "cc-kawakami"
|
37
|
+
}
|
38
|
+
).to_s
|
39
|
+
|
40
|
+
# git commit --amend --author=cc-kawakami
|
41
|
+
```
|
42
|
+
|
43
|
+
## Development
|
44
|
+
|
45
|
+
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.
|
46
|
+
|
47
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
data/Rakefile
ADDED
data/lib/shufu/item.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Shufu
|
2
|
+
class Item
|
3
|
+
def initialize(all_schema, name, value)
|
4
|
+
@all_schema = all_schema
|
5
|
+
@name = name
|
6
|
+
@value = value
|
7
|
+
end
|
8
|
+
|
9
|
+
def schema
|
10
|
+
@all_schema[:schema].find { |s| s[:name] == @name.to_s }
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
if schema[:type] == "argument"
|
16
|
+
@value
|
17
|
+
else
|
18
|
+
if schema[:flag]
|
19
|
+
"--#{@name}"
|
20
|
+
else
|
21
|
+
if schema[:equal]
|
22
|
+
"--#{@name}=#{@value}"
|
23
|
+
else
|
24
|
+
"--#{@name} #{@value}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/shufu/line.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Shufu
|
2
|
+
class InvalidSchemaError < RuntimeError; end
|
3
|
+
|
4
|
+
class Line
|
5
|
+
def initialize(main, schema, values)
|
6
|
+
@main = main
|
7
|
+
schema = Shufu::Schema.call(schema)
|
8
|
+
if schema.failure?
|
9
|
+
raise Shufu::InvalidSchemaError, schema.errors(full: true).to_h
|
10
|
+
end
|
11
|
+
@schema = schema
|
12
|
+
@values = values
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
[@main, items].flatten.join(" ")
|
17
|
+
end
|
18
|
+
|
19
|
+
def items
|
20
|
+
@values.map { |k, v| Shufu::Item.new(@schema, k, v).to_s }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/shufu/schema.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'dry-schema'
|
2
|
+
|
3
|
+
module Shufu
|
4
|
+
Schema = Dry::Schema.Params do
|
5
|
+
required(:schema).filled(:array).each do
|
6
|
+
hash do
|
7
|
+
required(:name).filled(:string)
|
8
|
+
required(:type).filled(:string)
|
9
|
+
optional(:position).maybe(:integer)
|
10
|
+
optional(:flag).maybe(:bool)
|
11
|
+
optional(:equal).maybe(:bool)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/shufu.rb
ADDED
data/shufu.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/shufu/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "shufu"
|
7
|
+
spec.version = Shufu::VERSION
|
8
|
+
spec.authors = ["cc-kawakami"]
|
9
|
+
spec.email = ["kawakami-moeki@colorfulcompany.co.jp"]
|
10
|
+
|
11
|
+
spec.summary = "Shufu is a simple command line generator"
|
12
|
+
spec.description = "Shufu is a simple command line generator"
|
13
|
+
spec.homepage = "https://github.com/cc-kawakami/shufu"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/cc-kawakami/shufu"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/cc-kawakami/shufu"
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
22
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
23
|
+
end
|
24
|
+
end
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_dependency "dry-schema"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shufu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cc-kawakami
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dry-schema
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Shufu is a simple command line generator
|
28
|
+
email:
|
29
|
+
- kawakami-moeki@colorfulcompany.co.jp
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- README.md
|
38
|
+
- Rakefile
|
39
|
+
- lib/shufu.rb
|
40
|
+
- lib/shufu/item.rb
|
41
|
+
- lib/shufu/line.rb
|
42
|
+
- lib/shufu/schema.rb
|
43
|
+
- lib/shufu/version.rb
|
44
|
+
- shufu.gemspec
|
45
|
+
homepage: https://github.com/cc-kawakami/shufu
|
46
|
+
licenses: []
|
47
|
+
metadata:
|
48
|
+
homepage_uri: https://github.com/cc-kawakami/shufu
|
49
|
+
source_code_uri: https://github.com/cc-kawakami/shufu
|
50
|
+
changelog_uri: https://github.com/cc-kawakami/shufu
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 2.6.0
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.2.32
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Shufu is a simple command line generator
|
70
|
+
test_files: []
|