tldr 0.9.0 → 0.9.2

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: c9ae325a1d7b5c16b255bce28975b4e9c08bc23291932a02d91d02d46c247655
4
- data.tar.gz: 0e92807c78187999ea26dba8f3ff48aa8ec6442b8884def3b7fc6b58db4127f0
3
+ metadata.gz: cd834ada0b427dab9478141f188df34e88af9eb650f1869110d16067783ed667
4
+ data.tar.gz: 0f474dd49db30970150fa8202335baa8ad753cfe8ce5c6e5867bc2d892b9124b
5
5
  SHA512:
6
- metadata.gz: 79a8a3c45bc03731c80e5d7b00103d69efe4a1185c758fdecde1451864677af433126634a717dd912d7032556562cbe3894b1e7db75ab811412c1cc9097a457e
7
- data.tar.gz: f27b99c4502b3a803d9c0507a1a9888715e8d203e1fc97bcd3284baa34afed4d9f55f2c5c06424c49645526c92534a54b52946867606a89b738dcb9c481a4c5d
6
+ metadata.gz: 95ad516ad60583d95d64c24b4c0706d34eaa468d304eef91f9224c1b3bdf6a81f39524f6323e19e28267cc05f37c603e5cc98eb705edbeb80076837ec3dc37a4
7
+ data.tar.gz: 6d275b09c8d73533df1d9836f6c19bb0e424519da4474bb17ac1f2b104d2e2a8e49d63fb7c7e359f01ebc216a9c5ffbf8237e72629ff4d376d97fa4c1a0fb1d9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.9.2]
2
+
3
+ * Don't redundantly print out dotfile config values for re-run instructions
4
+
5
+ ## [0.9.1]
6
+
7
+ * Correctly clear the screen between runs
8
+
1
9
  ## [0.9.0]
2
10
 
3
11
  * Add a `--watch` option that will spawn fswatch | xargs and clear the screen
data/README.md CHANGED
@@ -170,6 +170,9 @@ of the configured load paths (`["test", "lib"]` by default) and then execute
170
170
  your tests each time a file is changed. To keep the output up-to-date and easy
171
171
  to scan, it will also clear your console before each run.
172
172
 
173
+ Note that this feature requires you have
174
+ [fswatch](https://github.com/emcrisostomo/fswatch) installed and on your `PATH`
175
+
173
176
  Here's what that might look like:
174
177
 
175
178
  ![tldr-watch](https://github.com/tendersearls/tldr/assets/79303/364f0e52-5596-49ce-a470-5eaeddd11f03)
@@ -121,7 +121,7 @@ class TLDR
121
121
  "#{index + 1}) #{describe(result.test, result.relevant_location)} #{result.failure? ? "failed" : "errored"}:",
122
122
  result.error.message.chomp,
123
123
  "\n Re-run this test:",
124
- " #{tldr_command} #{@config.to_single_path_args(result.test.location.locator)}",
124
+ " #{tldr_command} #{@config.to_single_path_args(result.test.location.locator, exclude_dotfile_matches: true)}\n",
125
125
  (TLDR.filter_backtrace(result.error.backtrace).join("\n") if @config.verbose)
126
126
  ].compact.reject(&:empty?).join("\n").strip
127
127
  end
@@ -160,7 +160,7 @@ class TLDR
160
160
  ].compact + failed_locators
161
161
  <<~MSG
162
162
  #{@icons.rock_on} Run the #{plural(unrun.size, "test")} that didn't finish:
163
- #{tldr_command} #{@config.to_full_args(exclude: [:paths])} #{suggested_locators.join(" \\\n ")}
163
+ #{tldr_command} #{@config.to_full_args(exclude: [:paths], exclude_dotfile_matches: true)} #{suggested_locators.join(" \\\n ")}
164
164
  MSG
165
165
  end
166
166
 
@@ -142,14 +142,14 @@ class TLDR
142
142
  }.compact
143
143
  end
144
144
 
145
- def to_full_args exclude: [], ensure_args: []
145
+ def to_full_args exclude: [], ensure_args: [], exclude_dotfile_matches: false
146
146
  argv = to_cli_argv(
147
- CONFLAGS.keys -
148
- exclude - [
147
+ CONFLAGS.keys - exclude - [
149
148
  (:seed unless seed_set_intentionally),
150
149
  :watch,
151
150
  :i_am_being_watched
152
- ]
151
+ ],
152
+ exclude_dotfile_matches:
153
153
  )
154
154
 
155
155
  ensure_args.each do |arg|
@@ -159,19 +159,20 @@ class TLDR
159
159
  argv.join(" ")
160
160
  end
161
161
 
162
- def to_single_path_args path
162
+ def to_single_path_args path, exclude_dotfile_matches: false
163
163
  argv = to_cli_argv(CONFLAGS.keys - [
164
164
  :seed, :parallel, :names, :fail_fast, :paths, :prepend_paths,
165
165
  :no_prepend, :exclude_paths, :watch, :i_am_being_watched
166
- ])
166
+ ], exclude_dotfile_matches:)
167
167
 
168
168
  (argv + [stringify(:paths, path)]).join(" ")
169
169
  end
170
170
 
171
171
  private
172
172
 
173
- def to_cli_argv options = CONFLAGS.keys
173
+ def to_cli_argv options = CONFLAGS.keys, exclude_dotfile_matches:
174
174
  defaults = Config.build_defaults(cli_defaults: true)
175
+ defaults = defaults.merge(dotfile_args) if exclude_dotfile_matches
175
176
  options.map { |key|
176
177
  flag = CONFLAGS[key]
177
178
 
@@ -239,23 +240,28 @@ class TLDR
239
240
  end
240
241
 
241
242
  def merge_dotfile_args args
242
- return args if args[:no_dotfile] || !File.exist?(".tldr.yml")
243
- require "yaml"
244
-
245
- dotfile_args = YAML.load_file(".tldr.yml").transform_keys { |k| k.to_sym }
246
- # Since we don't have shell expansion, we have to glob any paths ourselves
247
- if dotfile_args.key?(:paths)
248
- dotfile_args[:paths] = dotfile_args[:paths].flat_map { |path| Dir[path] }
249
- end
250
- # The argv parser normally does this:
251
- if dotfile_args.key?(:reporter)
252
- dotfile_args[:reporter] = Kernel.const_get(dotfile_args[:reporter])
253
- end
254
- if (invalid_args = dotfile_args.except(*CONFIG_ATTRIBUTES)).any?
255
- raise Error, "Invalid keys in .tldr.yml file: #{invalid_args.keys.join(", ")}"
256
- end
243
+ return args if args[:no_dotfile]
257
244
 
258
245
  dotfile_args.merge(args)
259
246
  end
247
+
248
+ def dotfile_args
249
+ return {} unless File.exist?(".tldr.yml")
250
+
251
+ require "yaml"
252
+ @dotfile_args ||= YAML.load_file(".tldr.yml").transform_keys { |k| k.to_sym }.tap do |dotfile_args|
253
+ # Since we don't have shell expansion, we have to glob any paths ourselves
254
+ if dotfile_args.key?(:paths)
255
+ dotfile_args[:paths] = dotfile_args[:paths].flat_map { |path| Dir[path] }
256
+ end
257
+ # The argv parser normally does this:
258
+ if dotfile_args.key?(:reporter)
259
+ dotfile_args[:reporter] = Kernel.const_get(dotfile_args[:reporter])
260
+ end
261
+ if (invalid_args = dotfile_args.except(*CONFIG_ATTRIBUTES)).any?
262
+ raise Error, "Invalid keys in .tldr.yml file: #{invalid_args.keys.join(", ")}"
263
+ end
264
+ end
265
+ end
260
266
  end
261
267
  end
data/lib/tldr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class TLDR
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.2"
3
3
  end
data/lib/tldr/watcher.rb CHANGED
@@ -2,10 +2,17 @@ class TLDR
2
2
  class Watcher
3
3
  def watch config
4
4
  require_fs_watch!
5
- command = "fswatch -o #{config.load_paths.reverse.join(" ")} | xargs -n1 -I{} #{tldr_command} #{config.to_full_args}"
5
+ tldr_command = "#{"bundle exec " if defined?(Bundler)}tldr #{config.to_full_args(ensure_args: ["--i-am-being-watched"])}"
6
+ command = "fswatch -o #{config.load_paths.reverse.join(" ")} | xargs -n1 -I{} #{tldr_command}"
6
7
 
7
- puts <<~MSG
8
- Watching #{config.load_paths.map(&:inspect).join(", ")} for changes...
8
+ print <<~MSG.chomp
9
+ Waiting for changes in --load-path directories: #{config.load_paths.map(&:inspect).join(", ")}
10
+
11
+ When a file changes, TLDR will run this command:
12
+
13
+ $ #{tldr_command}
14
+
15
+ Watching...
9
16
  MSG
10
17
 
11
18
  exec command
@@ -24,9 +31,5 @@ class TLDR
24
31
  MSG
25
32
  exit 1
26
33
  end
27
-
28
- def tldr_command
29
- "#{"bundle exec " if defined?(Bundler)}tldr"
30
- end
31
34
  end
32
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tldr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls