geny 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/geny/actions/geny.rb +34 -0
- data/lib/geny/command.rb +6 -1
- data/lib/geny/context/invoke.rb +6 -0
- data/lib/geny/registry.rb +6 -2
- data/lib/geny/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46e41ae2c77c16d67afc70f779435a8698e742b1
|
4
|
+
data.tar.gz: a8388419c14c4af33934deb9c60ea9628e447579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99d2a29982aeaf49a8630893e912441fafccfc279514235da13ab5d431075db6087fc7ad75c7e7eeaea774a31aadd0d52428c77a6ea33af4d559b70d1cbadf5b
|
7
|
+
data.tar.gz: 61d5ca7ae6f8efe681f0046da27523e1a4dc6f3dcfd99d36a2e7635297c5ccabeeb877c6e2f58278e42299cff59dba4e21570a60bec1f14034bd7b8c95b93a71
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Geny
|
2
|
+
module Actions
|
3
|
+
# Run Geny commands from within a Geny invocation. Whoa, meta.
|
4
|
+
class Geny
|
5
|
+
# Create a new Geny
|
6
|
+
# @param registry [Registry]
|
7
|
+
def initialize(registry:)
|
8
|
+
@registry = registry
|
9
|
+
end
|
10
|
+
|
11
|
+
# Run a command with arguments
|
12
|
+
# @param name [String] name of the command
|
13
|
+
# @param argv [Array<String>] command-line arguments
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# geny.run "rails:model", "--name", "User"
|
17
|
+
def run(name, *argv)
|
18
|
+
command = @registry.find!(name)
|
19
|
+
command.run(argv)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Run a command with options
|
23
|
+
# @param name [String] name of the command
|
24
|
+
# @param options [Hash{Symbol => Object}] options for the command
|
25
|
+
#
|
26
|
+
# @example
|
27
|
+
# geny.invoke "rails:model", name: "User"
|
28
|
+
def invoke(name, **options)
|
29
|
+
command = @registry.find!(name)
|
30
|
+
command.invoke(options)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/geny/command.rb
CHANGED
@@ -18,9 +18,10 @@ module Geny
|
|
18
18
|
attr_reader :root
|
19
19
|
|
20
20
|
# Create a new command
|
21
|
+
# @param registry [Registry] registry used to find this command
|
21
22
|
# @param name [String] name of the command
|
22
23
|
# @param root [String] name of the command
|
23
|
-
def initialize(name:, root:)
|
24
|
+
def initialize(name:, root:, registry:)
|
24
25
|
@name = name
|
25
26
|
@root = root
|
26
27
|
end
|
@@ -57,6 +58,9 @@ module Geny
|
|
57
58
|
|
58
59
|
# Parse command-line options
|
59
60
|
# @param argv [Array<String>]
|
61
|
+
# @raise [Argy::ParseError] when the arguments are invalid
|
62
|
+
# @raise [Argy::CoersionError] when the arguments cannot be coerced
|
63
|
+
# @raise [Argy::ValidationError] when required arguments are missing
|
60
64
|
# @return [Argy::Options]
|
61
65
|
def parse(argv)
|
62
66
|
parser.parse(argv)
|
@@ -70,6 +74,7 @@ module Geny
|
|
70
74
|
end
|
71
75
|
|
72
76
|
# Invoke a command with options
|
77
|
+
# @raise [Argy::ValidationError] when required arguments are missing
|
73
78
|
# @param options [Hash{Symbol => Object}]
|
74
79
|
def invoke(**options)
|
75
80
|
options = parser.default_values.merge(options)
|
data/lib/geny/context/invoke.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "pastel"
|
2
2
|
require "geny/context/base"
|
3
3
|
require "geny/actions/ui"
|
4
|
+
require "geny/actions/geny"
|
4
5
|
require "geny/actions/git"
|
5
6
|
require "geny/actions/shell"
|
6
7
|
require "geny/actions/files"
|
@@ -51,6 +52,11 @@ module Geny
|
|
51
52
|
view: View.new(command: command, locals: locals)
|
52
53
|
)
|
53
54
|
end
|
55
|
+
|
56
|
+
# A utility for invoking other generators
|
57
|
+
def geny
|
58
|
+
Actions::Geny.new(registry: command.registry)
|
59
|
+
end
|
54
60
|
end
|
55
61
|
end
|
56
62
|
end
|
data/lib/geny/registry.rb
CHANGED
@@ -34,7 +34,7 @@ module Geny
|
|
34
34
|
root = file.dirname
|
35
35
|
name = root.relative_path_from(path)
|
36
36
|
name = name.to_s.tr(File::SEPARATOR, ":")
|
37
|
-
|
37
|
+
build(name, root.to_s)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -48,7 +48,7 @@ module Geny
|
|
48
48
|
load_path.each do |path|
|
49
49
|
file = File.join(path, *name.split(":"), Command::FILENAME)
|
50
50
|
root = File.dirname(file)
|
51
|
-
return
|
51
|
+
return build(name, root) if File.exist?(file)
|
52
52
|
end
|
53
53
|
|
54
54
|
nil
|
@@ -64,6 +64,10 @@ module Geny
|
|
64
64
|
|
65
65
|
private
|
66
66
|
|
67
|
+
def build(name, root)
|
68
|
+
Command.new(name: name, root: root, registry: self)
|
69
|
+
end
|
70
|
+
|
67
71
|
def command_not_found!(name)
|
68
72
|
raise NotFoundError, "There doesn't appear to be a generator named '#{name}'"
|
69
73
|
end
|
data/lib/geny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Zane
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: argy
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/generators/new/templates/generator.rb.erb
|
149
149
|
- lib/geny.rb
|
150
150
|
- lib/geny/actions/files.rb
|
151
|
+
- lib/geny/actions/geny.rb
|
151
152
|
- lib/geny/actions/git.rb
|
152
153
|
- lib/geny/actions/shell.rb
|
153
154
|
- lib/geny/actions/templates.rb
|