runfile 1.0.0.rc1 → 1.0.0.rc2

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
  SHA256:
3
- metadata.gz: b399f5dddc730408a835c29507af0b23d80be1ce6452c90d0c26d0d0acc577e7
4
- data.tar.gz: 27211f7110e22ca49317d893952d7af82bdd774879782335185f0421e74f864b
3
+ metadata.gz: 5ae2a7aefd3a25703d232d70e6857aeafe467772582a96202d371bfca748e1f7
4
+ data.tar.gz: 32f39514ba7ffb8318c305278f55a397d2e686c7179cec0ff5899c5e6fd62871
5
5
  SHA512:
6
- metadata.gz: eaf0546be8eed23eeb6af18789a83e4b4eaa5514b044b41efb7a7a401da8465986a05bfcc5ec0930b0292edf4ea1830d2c78d0014808b59d5cf2f7c25fd3eb6d
7
- data.tar.gz: 7eb9ba751139e0a83106cf7a5c0ff933b51ebba6cdbd63ee32f7ddf34be249b9804f6fb007e303cb3e225cb3cedf04ed9418a7e6856cb94165208ee3e5e672c2
6
+ metadata.gz: 289c29cf9119ce944bc46c1c6067299454396b143721b5b5b0b6b03553bca3c805743656a13cb8f4757a77022e4294152254124d7f6dfea4803879ac4289690d
7
+ data.tar.gz: 61afd4733813f4f3082765eae107295af324a446da8ccc5bc70959504c81aba0a161e286fc25ff0095b2fbff0c50b3a9fb76a8a21f992c6f5c620b1abd15b111
data/README.md CHANGED
@@ -29,7 +29,8 @@ command line "toolbelt" for your projects, you can use it regardless.
29
29
  ## Pre-release Notice
30
30
 
31
31
  Note that this README describes the not yet released 1.0.0 version.
32
- See https://bashly.dannyb.co/ for the stable release documentation.
32
+ See [runfile.dannyb.co](https://runfile.dannyb.co/) for the stable release
33
+ documentation.
33
34
 
34
35
  During the pre-release phase, the `run` executable is called `runn` instead,
35
36
  to allow running both the stable and pre-release version side by side.
@@ -3,5 +3,6 @@ option '--continue, -c', 'Continue testing'
3
3
  option '--failed, -f', 'Retest failed specs'
4
4
  action do |args|
5
5
  say 'spec action'
6
+ p context
6
7
  p args
7
8
  end
@@ -2,7 +2,7 @@ title 'Importing other funfiles'
2
2
  summary 'Reference other runfiles to blend them seamlessly as one command line interface'
3
3
 
4
4
  import 'tasks/*'
5
- import 'more_tasks/spec'
5
+ import 'more_tasks/spec', anything: 'Context Values'
6
6
 
7
7
  usage 'say MESSAGE'
8
8
  action 'say' do |args|
@@ -1,6 +1,7 @@
1
1
  summary 'Server management commands'
2
2
 
3
3
  action 'start' do |_args|
4
+ say "Context: #{context[:anything]}"
4
5
  say 'g`Starting server`'
5
6
  end
6
7
 
@@ -10,12 +10,6 @@ module Runfile
10
10
  current_action.shortcut = shortcut if shortcut
11
11
  current_action.prefix = action_prefix if action_prefix
12
12
 
13
- # if default_action && name
14
- # raise SyntaxError, <<~ERROR
15
- # Cannot define action nub`#{name}` since a default action was already defined
16
- # ERROR
17
- # end
18
-
19
13
  actions[name || :default] = current_action
20
14
  @default_action = current_action unless name
21
15
  @current_action = nil
@@ -33,21 +27,15 @@ module Runfile
33
27
  current_action.help = message
34
28
  end
35
29
 
36
- def import(pathspec)
37
- imports.push pathspec
30
+ def import(pathspec, context = nil)
31
+ imports[pathspec] = context
38
32
  end
39
33
 
40
- def import_gem(gem_name, runfile_path, context = nil)
41
- if context && !context.is_a?(Hash)
42
- raise SyntaxError, <<~ERROR
43
- The third argument to nub`import_gem` must be a hash
44
- got rb`#{context.inspect}`
45
- ERROR
46
- end
47
-
48
- path = GemFinder.find gem_name, runfile_path
49
- imports.push path
50
- contexts[runfile_path] = context if context
34
+ def import_gem(pathspec, context = nil)
35
+ gem_name, glob = pathspec.split('/', 2)
36
+ glob ||= '*'
37
+ path = GemFinder.find gem_name, glob
38
+ imports[path] = context
51
39
  end
52
40
 
53
41
  def option(name, help)
@@ -95,10 +83,6 @@ module Runfile
95
83
  nil
96
84
  end
97
85
 
98
- def contexts
99
- @contexts ||= {}
100
- end
101
-
102
86
  def actions
103
87
  @actions ||= {}
104
88
  end
@@ -120,7 +104,7 @@ module Runfile
120
104
  end
121
105
 
122
106
  def imports
123
- @imports ||= []
107
+ @imports ||= {}
124
108
  end
125
109
 
126
110
  private
data/lib/runfile/meta.rb CHANGED
@@ -43,23 +43,23 @@ module Runfile
43
43
  @masterfile ||= Userfile.load_file masterfile_path
44
44
  end
45
45
 
46
- # def title
47
- # masterfile&.title
48
- # end
49
-
50
- # def summary
51
- # masterfile&.summary
52
- # end
53
-
54
46
  def globs
55
- @globs ||= (masterfile ? ['*'] + masterfile.imports : ['*'])
47
+ @globs ||= (masterfile ? ['*'] + masterfile.imports.keys : ['*'])
56
48
  end
57
49
 
58
50
  def external_files
59
- @external_files ||= globs
60
- .map { |glob| Dir["#{glob}.runfile"].sort }
61
- .flatten
62
- .to_h { |file| [File.basename(file, '.runfile'), Userfile.load_file(file)] }
51
+ @external_files ||= begin
52
+ result = []
53
+ globs.each do |glob|
54
+ Dir["#{glob}.runfile"].sort.each do |file|
55
+ userfile = Userfile.load_file(file)
56
+ userfile.context = masterfile.imports[glob] if masterfile
57
+ result.push userfile
58
+ end
59
+ end
60
+
61
+ result.to_h { |file| [file.name, file] }
62
+ end
63
63
  end
64
64
  end
65
65
  end
@@ -44,11 +44,11 @@ module Runfile
44
44
  end
45
45
 
46
46
  def inspectable
47
- { name: name, path: path }
47
+ { name: name, path: path, context: context }
48
48
  end
49
49
 
50
50
  def run(argv = [])
51
- found_delegate = delegate argv[0]
51
+ found_delegate = delegates[argv[0]]
52
52
  if found_delegate
53
53
  found_delegate.run argv
54
54
  else
@@ -92,14 +92,6 @@ module Runfile
92
92
  end
93
93
  end
94
94
 
95
- def delegate(name)
96
- return nil unless delegates.has_key? name
97
-
98
- result = delegates[name]
99
- result.context = contexts[name]
100
- result
101
- end
102
-
103
95
  def meta
104
96
  @meta ||= Meta.new
105
97
  end
@@ -1,3 +1,3 @@
1
1
  module Runfile
2
- VERSION = '1.0.0.rc1'
2
+ VERSION = '1.0.0.rc2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-25 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole