atli 0.1.12 → 0.1.13

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
  SHA1:
3
- metadata.gz: 58210dece21bb6f5e41acd1ad1ace1230b856687
4
- data.tar.gz: 600873fc0d393528eeca7ecac5ad9359a2b88af6
3
+ metadata.gz: 4928dae505429de7588e87a1f608f66855382062
4
+ data.tar.gz: d23dccf0b6733881d72ac7cf18e7159b675e9c78
5
5
  SHA512:
6
- metadata.gz: 641a5a3c2283c1c70e68b71291bfebb1e118bba9bf3c0678aaffcd74606c604dd052aa6ff79b393cfdea606a4a8312013d629a04039a1dd9db9d8c93b5855f9a
7
- data.tar.gz: 7c21174463863a9463dcfb1bb945c76866cbc3576c85a7b5c9d6389ec56a255117b196fccf75e449d705aee84e00076bdd5887427ec220d97596609dbb645e37
6
+ metadata.gz: dc179bc04faef26be94ee778f158d5369fa4eb94b6b8de1da7676a8df8d8b42eddb63a2a68b00aa6c570c125dbd0b7835720e5206559625e0e42c88d5cb30376
7
+ data.tar.gz: 3a5dd46711a174e6d13294c18d1a3fd47c983633c49bc50b1a9ddc115757f3b91ef2807a7472bf36224704cf815e7048fb94b1842f38165bae9070df4308e1a5
@@ -4,7 +4,6 @@ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
4
4
  require "thor/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.add_development_dependency "bundler", "~> 1.0"
8
7
  spec.authors = ["Neil Souza (Atli)", "Yehuda Katz (Thor)", "José Valim (Thor)"]
9
8
  spec.description = "Atli is a fork of Thor that's better or worse."
10
9
  spec.email = "neil@atli.nrser.com"
@@ -33,7 +32,7 @@ Gem::Specification.new do |spec|
33
32
  # ============================================================================
34
33
 
35
34
  # My guns
36
- spec.add_dependency "nrser", '~> 0.3.9'
35
+ spec.add_dependency "nrser", '~> 0.3.12'
37
36
 
38
37
 
39
38
  # Development Dependencies
@@ -42,6 +41,8 @@ Gem::Specification.new do |spec|
42
41
  # NOTE Development dependencies that came from Thor are in `//Gemfile`
43
42
  #
44
43
 
44
+ spec.add_development_dependency "bundler", ">= 1.0"
45
+
45
46
  ### Yard
46
47
  #
47
48
  # I'm not used to dealing with RDoc docstrings, and want to still write doc
@@ -828,24 +828,6 @@ class Thor
828
828
 
829
829
  singleton_class.send :alias_method, :subtask_help, :subcommand_help
830
830
 
831
-
832
- # Atli Protected Class Methods
833
- # ======================================================================
834
-
835
- # Build a Thor::SharedOption and add it to Thor.shared_method_options.
836
- #
837
- # The Thor::SharedOption is returned.
838
- #
839
- # ==== Parameters
840
- # name<Symbol>:: The name of the argument.
841
- # options<Hash>:: Described in both class_option and method_option,
842
- # with the additional `:groups` shared option keyword.
843
- def self.build_shared_option(name, options)
844
- shared_method_options[name] = Thor::SharedOption.new(
845
- name,
846
- options.merge(:check_default_type => check_default_type?)
847
- )
848
- end # .build_shared_option
849
831
 
850
832
  public # END protected Class Methods ***************************************
851
833
 
@@ -868,9 +850,16 @@ class Thor
868
850
 
869
851
  # Add groups (if any)
870
852
  if groups
871
- self.class.find_shared_options( groups: groups ).each do |name, option|
872
- name_set << name.to_s
873
- end
853
+ groups = Array( groups )
854
+
855
+ self.class.
856
+ shared_defs.
857
+ select { |shared_def|
858
+ groups.any? { |group| shared_def[ :groups].include? group }
859
+ }.
860
+ each do |shared|
861
+ name_set << shared[:name].to_s
862
+ end
874
863
  end
875
864
 
876
865
  options.slice( *name_set ).sym_keys
@@ -21,7 +21,6 @@ require "thor/util"
21
21
  require 'thor/execution'
22
22
  require 'thor/base/class_methods'
23
23
  require 'thor/base/arguments_concern'
24
- require 'thor/base/shared_options_concern'
25
24
  require 'thor/base/shared_concern'
26
25
 
27
26
 
@@ -69,7 +68,6 @@ class Thor
69
68
  base.send :include, Invocation
70
69
  base.send :include, Shell
71
70
  base.send :include, ArgumentsConcern
72
- base.send :include, SharedOptionsConcern
73
71
  base.send :include, SharedConcern
74
72
 
75
73
  base.no_commands {
@@ -40,6 +40,11 @@ module Thor::Base::CommonClassOptions
40
40
  type: :boolean
41
41
 
42
42
 
43
+ define :color,
44
+ desc: "Use color output",
45
+ type: :boolean
46
+
47
+
43
48
  def common_class_options *names
44
49
  messages = Hamster::Hash.new @@messages
45
50
 
@@ -34,83 +34,61 @@ module SharedConcern
34
34
 
35
35
  class_methods do
36
36
  # ==========================================================================
37
+
38
+
39
+ protected
40
+ # ========================================================================
41
+
42
+ def this_class_shared_defs_ref
43
+ @shared_defs ||= []
44
+ end
45
+
46
+
47
+ def copy_shared_defs_to array, inherited: true
48
+ array.push *this_class_shared_defs_ref
49
+
50
+ if inherited &&
51
+ superclass &&
52
+ superclass.respond_to?( :copy_shared_defs_to, true )
53
+ superclass.copy_shared_defs_to array
54
+ end
55
+
56
+ array
57
+ end
58
+
59
+ public # end protected ***************************************************
60
+
37
61
 
38
- def shared_defs
39
- @shared_defs ||= []
62
+ def shared_defs inherited: true
63
+ [].tap do |array|
64
+ copy_shared_defs_to array, inherited: inherited
65
+ end
40
66
  end
41
67
 
42
68
 
43
- # def normalize_kind input
44
- # {
45
- # 'arg' => 'argument',
46
-
47
- # }
48
- # end
49
-
50
-
51
69
  def def_shared kind, name:, groups: nil, **options
52
- shared_defs << {
53
- name: name.to_s,
54
- kind: kind,
55
- groups: Set[*groups],
56
- options: options,
57
- }
70
+ this_class_shared_defs_ref << {
71
+ name: name.to_sym,
72
+ kind: kind.to_sym,
73
+ groups: Set[*groups].freeze,
74
+ options: options.freeze,
75
+ }.freeze
58
76
  end
59
77
 
60
78
 
61
- def include_shared *names, kinds: nil, groups: nil, **overrides
62
- find_shared( *names, kinds: kinds, groups: groups ).
63
- each do |name:, kind:, groups:, options:|
64
- send kind, name, **options.merge( overrides )
65
- end
66
- end
67
-
68
-
69
- # Find shared options given names and groups.
70
- #
71
- # @param [*<Symbol>] names
72
- # Individual shared option names to include.
73
- #
74
- # @param [nil | Symbol | Enumerable<Symbol>] groups:
75
- # Single or list of shared option groups to include.
76
- #
77
- # @return [Hash<Symbol, Thor::SharedOption>]
78
- # Hash mapping option names (as {Symbol}) to instances.
79
- #
80
- def find_shared *names, kinds: nil, groups: nil
81
- groups_set = Set[*groups]
82
- kinds_set = Set[*kinds]
83
- names.map! &:to_s
84
-
85
- results = []
79
+ def include_shared selector, **overrides
80
+ defs = shared_defs.select &selector
86
81
 
87
- shared_defs.each do |name:, kind:, groups:, options:|
88
- match = {}
89
-
90
- if names.include? name
91
- match[:name] = true
92
- end
93
-
94
- match_groups = groups & groups_set
95
-
96
- unless match_groups.empty?
97
- match[:groups] = match_groups
98
- end
99
-
100
- if kinds_set.include? kind
101
- match[:kind] = true
102
- end
103
-
104
- unless match.empty?
105
- results << {
106
- name: name,
107
- kind: kind,
108
- groups: groups,
109
- options: options,
110
- }
111
- end
82
+ if defs.empty?
83
+ logger.warn "No shared parameters found",
84
+ selector: selector,
85
+ class: self
112
86
  end
113
- end # #find_shared
87
+
88
+ defs.each do |name:, kind:, groups:, options:|
89
+ send kind, name, **options.merge( overrides )
90
+ end
91
+ end
114
92
 
115
93
  end # class_methods ********************************************************
116
94
 
@@ -9,6 +9,7 @@
9
9
 
10
10
  require 'nrser'
11
11
  require 'nrser/labs/i8'
12
+ require 'nrser/labs/i8/struct'
12
13
 
13
14
 
14
15
  # Refinements
@@ -1,5 +1,4 @@
1
1
  require "thor/parser/argument"
2
2
  require "thor/parser/arguments"
3
3
  require "thor/parser/option"
4
- require "thor/parser/shared_option"
5
4
  require "thor/parser/options"
@@ -14,7 +14,7 @@ class Thor
14
14
  #
15
15
  # @return [String]
16
16
  #
17
- VERSION = '0.1.12'
17
+ VERSION = '0.1.13'
18
18
 
19
19
 
20
20
  # The version of Thor that Atli is up to date with.
@@ -27,7 +27,7 @@ class Thor
27
27
  #
28
28
  # @return [String]
29
29
  #
30
- THOR_VERSION = '0.1.12'
30
+ THOR_VERSION = '0.1.13'
31
31
 
32
32
 
33
33
  # Are we running from the source code (vesus from a Gem install)?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Souza (Atli)
@@ -10,36 +10,36 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-07-20 00:00:00.000000000 Z
13
+ date: 2019-04-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: bundler
16
+ name: nrser
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
19
  - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.0'
22
- type: :development
21
+ version: 0.3.12
22
+ type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.0'
28
+ version: 0.3.12
29
29
  - !ruby/object:Gem::Dependency
30
- name: nrser
30
+ name: bundler
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - "~>"
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 0.3.9
36
- type: :runtime
35
+ version: '1.0'
36
+ type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - "~>"
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 0.3.9
42
+ version: '1.0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: yard
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,6 @@ files:
109
109
  - lib/thor/base/class_methods.rb
110
110
  - lib/thor/base/common_class_options.rb
111
111
  - lib/thor/base/shared_concern.rb
112
- - lib/thor/base/shared_options_concern.rb
113
112
  - lib/thor/command.rb
114
113
  - lib/thor/completion/bash.rb
115
114
  - lib/thor/completion/bash/argument_mixin.rb
@@ -132,7 +131,6 @@ files:
132
131
  - lib/thor/parser/arguments.rb
133
132
  - lib/thor/parser/option.rb
134
133
  - lib/thor/parser/options.rb
135
- - lib/thor/parser/shared_option.rb
136
134
  - lib/thor/rake_compat.rb
137
135
  - lib/thor/runner.rb
138
136
  - lib/thor/shell.rb
@@ -162,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
160
  version: 1.3.5
163
161
  requirements: []
164
162
  rubyforge_project:
165
- rubygems_version: 2.5.2.2
163
+ rubygems_version: 2.5.2.3
166
164
  signing_key:
167
165
  specification_version: 4
168
166
  summary: Atli is a fork of Thor that's better or worse.
@@ -1,235 +0,0 @@
1
- # encoding: UTF-8
2
- # frozen_string_literal: true
3
-
4
-
5
- # Requirements
6
- # =======================================================================
7
-
8
- # Deps
9
- # -----------------------------------------------------------------------
10
-
11
- require 'active_support/concern'
12
-
13
-
14
- # Refinements
15
- # =======================================================================
16
-
17
- require 'nrser/refinements/types'
18
- using NRSER::Types
19
-
20
- # Namespace
21
- # =======================================================================
22
-
23
- class Thor
24
- module Base
25
-
26
-
27
- # Definitions
28
- # =======================================================================
29
-
30
- # Support for sharing {Thor::Option} declarations among many
31
- # {Thor::Command} (methods). All class methods.
32
- #
33
- module SharedOptionsConcern
34
-
35
- # Mixins
36
- # ========================================================================
37
-
38
- # Get concerned
39
- extend ActiveSupport::Concern
40
-
41
-
42
- class_methods do
43
- # ==========================================================================
44
-
45
- # Declare a shared method option with an optional groups that can then
46
- # be added by name or group to commands.
47
- #
48
- # The shared options can then be added to methods individually by name and
49
- # collectively as groups with {Thor.include_method_options}.
50
- #
51
- # @example
52
- # class MyCLI < Thor
53
- #
54
- # # Declare a shared option:
55
- # shared_option :force,
56
- # groups: :write,
57
- # desc: "Force the operation",
58
- # type: :boolean
59
- #
60
- # # ...
61
- #
62
- # desc "write [OPTIONS] path",
63
- # "Write to a path"
64
- #
65
- # # Add the shared options to the method:
66
- # include_options groups: :write
67
- #
68
- # def write path
69
- #
70
- # # Get a slice of `#options` with any of the `:write` group options
71
- # # that were provided and use it in a method call:
72
- # MyModule.write path, **option_kwds( groups: :write )
73
- #
74
- # end
75
- # end
76
- #
77
- # @param [Symbol] name
78
- # The name of the option.
79
- #
80
- # @param [**<Symbol, V>] options
81
- # Keyword args used to initialize the {Thor::SharedOption}.
82
- #
83
- # All +**options+ are optional.
84
- #
85
- # @option options [Symbol | Array<Symbol>] :groups
86
- # One or more _shared_ _option_ _group_ that the new option will belong
87
- # to.
88
- #
89
- # Examples:
90
- # groups: :read
91
- # groups: [:read, :write]
92
- #
93
- # *NOTE* The keyword is +groups+ with an +s+! {Thor::Option} already has
94
- # a +group+ string attribute that, as far as I can tell, is only
95
- #
96
- # @option options [String] :desc
97
- # Description for the option for help and feedback.
98
- #
99
- # @option options [Boolean] :required
100
- # If the option is required or not.
101
- #
102
- # @option options [Object] :default
103
- # Default value for this argument.
104
- #
105
- # It cannot be +required+ and have default values.
106
- #
107
- # @option options [String | Array<String>] :aliases
108
- # Aliases for this option.
109
- #
110
- # Examples:
111
- # aliases: '-s'
112
- # aliases: '--other-name'
113
- # aliases: ['-s', '--other-name']
114
- #
115
- # @option options [:string | :hash | :array | :numeric | :boolean] :type
116
- # Type of acceptable values, see
117
- # {types for method options}[https://github.com/erikhuda/thor/wiki/Method-Options#types-for-method_options]
118
- # in the Thor wiki.
119
- #
120
- # @option options [String] :banner
121
- # String to show on usage notes.
122
- #
123
- # @option options [Boolean] :hide
124
- # If you want to hide this option from the help.
125
- #
126
- # @return (see .build_shared_option)
127
- #
128
- def shared_method_option name, **options
129
- # Don't think the `:for` option makes sense... that would just be a
130
- # regular method option, right? I guess `:for` could be an array and
131
- # apply the option to each command, but it seems like that would just
132
- # be better as an extension to the {.method_option} behavior.
133
- #
134
- # So, we raise if we see it
135
- if options.key? :for
136
- raise ArgumentError,
137
- ".shared_method_option does not accept the `:for` option"
138
- end
139
-
140
- build_shared_option(name, options)
141
- end # #shared_method_option
142
-
143
- alias_method :shared_option, :shared_method_option
144
-
145
-
146
- # @return [Hash<Symbol, Thor::SharedOption]
147
- # Get all shared options
148
- #
149
- def shared_method_options(options = nil)
150
- @shared_method_options ||= begin
151
- # Reach up the inheritance chain, if there's anyone there
152
- if superclass.respond_to? __method__
153
- superclass.send( __method__ ).dup
154
- else
155
- # Or just default to empty
156
- {}
157
- end
158
- end
159
-
160
- if options
161
- # We don't support this (yet at least)
162
- raise NotImplementedError,
163
- "Bulk set not supported, use .shared_method_option"
164
- # build_shared_options(options, @shared_method_options)
165
- end
166
- @shared_method_options
167
- end
168
-
169
- alias_method :shared_options, :shared_method_options
170
-
171
-
172
- # Find shared options given names and groups.
173
- #
174
- # @param [*<Symbol>] names
175
- # Individual shared option names to include.
176
- #
177
- # @param [nil | Symbol | Enumerable<Symbol>] groups:
178
- # Single or list of shared option groups to include.
179
- #
180
- # @return [Hash<Symbol, Thor::SharedOption>]
181
- # Hash mapping option names (as {Symbol}) to instances.
182
- #
183
- def find_shared_method_options *names, groups: nil
184
- groups_set = Set[*groups]
185
-
186
- shared_method_options.each_with_object( {} ) do |(name, option), results|
187
- match = {}
188
-
189
- if names.include? name
190
- match[:name] = true
191
- end
192
-
193
- match_groups = option.groups & groups_set
194
-
195
- unless match_groups.empty?
196
- match[:groups] = match_groups
197
- end
198
-
199
- unless match.empty?
200
- results[name] = {
201
- option: option,
202
- match: match,
203
- }
204
- end
205
- end
206
- end # #find_shared_method_options
207
-
208
- alias_method :find_shared_options, :find_shared_method_options
209
-
210
-
211
- # Add the {Thor::SharedOption} instances with +names+ and in +groups+ to
212
- # the next defined command method.
213
- #
214
- # @param (see .find_shared_method_options)
215
- # @return (see .find_shared_method_options)
216
- #
217
- def include_method_options *names, groups: nil
218
- find_shared_method_options( *names, groups: groups ).
219
- each do |name, result|
220
- method_options[name] = Thor::IncludedOption.new **result
221
- end
222
- end
223
-
224
- alias_method :include_options, :include_method_options
225
-
226
- end # class_methods ********************************************************
227
-
228
- end # module SharedOptionsConcern
229
-
230
-
231
- # /Namespace
232
- # =======================================================================
233
-
234
- end # module Base
235
- end # class Thor
@@ -1,117 +0,0 @@
1
- # encoding: UTF-8
2
- # frozen_string_literal: true
3
-
4
- # Requirements
5
- # ========================================================================
6
-
7
- # Stdlib
8
- # ------------------------------------------------------------------------
9
- require 'set'
10
-
11
- # Deps
12
- # ------------------------------------------------------------------------
13
-
14
- # Need {String#titleize}
15
- require 'active_support/core_ext/string/inflections'
16
-
17
- # Need {NRSER::LazyAttr}
18
- require 'nrser/meta/lazy_attr'
19
-
20
- # Project / Package
21
- # ------------------------------------------------------------------------
22
-
23
- require_relative './option'
24
-
25
-
26
- class Thor
27
- # A {Thor::Option} that has an additional {#groups} attribute storing a
28
- # set of group symbols that the option is a part of.
29
- #
30
- class SharedOption < Option
31
-
32
- # Shared option groups this option belongs to.
33
- #
34
- # @return [Set<Symbol>]
35
- #
36
- attr_reader :groups
37
-
38
- #
39
- #
40
- def initialize name, **options
41
- @groups = Set.new [*options[:groups]].map( &:to_sym )
42
-
43
- # # If
44
- # if options[:group].nil? && groups.count == 1
45
- # options[:group] = groups.first.to_s.titleize
46
- # end
47
-
48
- super name, options
49
- end
50
-
51
-
52
- def initialize_options
53
- {
54
- # {Thor::Argument} options
55
- desc: :@description,
56
- required: :@required,
57
- type: :@type,
58
- default: :@default,
59
- banner: :@banner,
60
- eunm: :@enum,
61
-
62
- # {Thor::Option} options
63
- check_default_type: :@check_default_type,
64
- lazy_default: :@lazy_default,
65
- group: :@group,
66
- aliases: :@aliases,
67
- hide: :@hide,
68
-
69
- # {Thor::SharedOption} options
70
- groups: :@groups,
71
- }.transform_values &method( :instance_variable_get )
72
- end
73
-
74
- end
75
-
76
-
77
- class IncludedOption < SharedOption
78
-
79
- # The match that resulted in this option getting included.
80
- #
81
- # @return [Hash]
82
- #
83
- attr_reader :match
84
-
85
-
86
- def initialize option:, match:
87
- super option.name, **option.initialize_options
88
- @match = match
89
- end
90
-
91
-
92
- +NRSER::LazyAttr
93
- def group
94
- case @group
95
- when false
96
- nil
97
- when String
98
- @group
99
- when nil
100
- default_group
101
- else
102
- logger.warn "Bad {Option#group}: #{ @group.inspect }",
103
- option: self
104
- nil
105
- end
106
- end
107
-
108
-
109
- +NRSER::LazyAttr
110
- def default_group
111
- return nil unless match[:groups]
112
-
113
- match[:groups].map { |group| group.to_s.titleize }.join ' / '
114
- end
115
-
116
- end
117
- end