shufu 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12426f786a5f221e6dc2eb0f8e42ec570605ea72da92c37db6afa2e5149f012b
4
- data.tar.gz: 8c347d6d7235ea550b13764aea9938c6537cd6a4cbcf97225c5fb519d718d0b4
3
+ metadata.gz: cb8875c20791059866fce8a4ffca83b5e6e072561200bd585b89a0124ebd7373
4
+ data.tar.gz: 583e2f2195d76d16144c2aa49d9914f2a6bd2557a7638114b67e2ef08ef1c267
5
5
  SHA512:
6
- metadata.gz: 338e7cd729aeeb3a4cffc29b88efcc31fca565f3f99dad03ff2235e45791c07c73ff52ec218a50fa22c16ca1e41270af3879b1123004354ff12132222e256383
7
- data.tar.gz: 44b768f08c3d30ff311ece22978683a6ef1c6dcfcf5564fcd4275d7c7b08d4e210e2b1eec6fc6955179133c23621fd00f69d53951a5d4a35bbf8c6f818442201
6
+ metadata.gz: cd87095644fce9a66bd244ea53835313134528c3ac68a97a6516a8991abd26c5c2a4b26651cd3d4c5baa72ca78ceb7e1262a2c799e816c36e7f37bc81b2ae35f
7
+ data.tar.gz: 13fa0f03aaaf03a8b3313224eede86df53c6b05d1ccbf534d66d47e506d8d7fb10fe11c36ac2f746c4853a2707bc65162928b16afb26febc9f605dfffbd909ad
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shufu (0.1.0)
4
+ shufu (0.1.1)
5
5
  dry-schema
6
6
 
7
7
  GEM
@@ -18,7 +18,7 @@ GEM
18
18
  dry-core (0.7.1)
19
19
  concurrent-ruby (~> 1.0)
20
20
  dry-inflector (0.2.1)
21
- dry-initializer (3.1.0)
21
+ dry-initializer (3.1.1)
22
22
  dry-logic (1.2.0)
23
23
  concurrent-ruby (~> 1.0)
24
24
  dry-core (~> 0.5, >= 0.5)
data/README.md CHANGED
@@ -23,19 +23,16 @@ Or install it yourself as:
23
23
  ```ruby
24
24
  require "shufu"
25
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
26
+ schema = {
27
+ schema: [
28
+ { name: "amend", type: option, flag: true },
29
+ { name: "author", type: option, equal: true }
30
+ ]
31
+ }
32
+
33
+ command = Shufu::Command.new("git commit", schema)
34
+
35
+ p command.line({ amend: true, author: "cc-kawakami" })
39
36
 
40
37
  # git commit --amend --author=cc-kawakami
41
38
  ```
@@ -0,0 +1,18 @@
1
+ module Shufu
2
+ class InvalidSchemaError < RuntimeError; end
3
+
4
+ class Command
5
+ def initialize(base, schema)
6
+ @base = base
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
+ end
13
+
14
+ def line(values)
15
+ Line.new(@base, @schema, values).to_s
16
+ end
17
+ end
18
+ end
data/lib/shufu/line.rb CHANGED
@@ -1,19 +1,13 @@
1
1
  module Shufu
2
- class InvalidSchemaError < RuntimeError; end
3
-
4
2
  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
3
+ def initialize(base, schema, values)
4
+ @base = base
11
5
  @schema = schema
12
6
  @values = values
13
7
  end
14
8
 
15
9
  def to_s
16
- [@main, items].flatten.join(" ")
10
+ [@base, items].flatten.join(" ")
17
11
  end
18
12
 
19
13
  def items
data/lib/shufu/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shufu
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shufu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cc-kawakami
@@ -37,6 +37,7 @@ files:
37
37
  - README.md
38
38
  - Rakefile
39
39
  - lib/shufu.rb
40
+ - lib/shufu/command.rb
40
41
  - lib/shufu/item.rb
41
42
  - lib/shufu/line.rb
42
43
  - lib/shufu/schema.rb