splot 0.5.3 → 0.5.4

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: 31c16e62c494cad56ecfc7d04a123fd1fc645d81
4
- data.tar.gz: b688a73a2d6d5cb4bf27f5011ed22c47ec841d25
3
+ metadata.gz: a02e6293df35f85f64deee512f9cf1578ed9ff5e
4
+ data.tar.gz: 4d6a6370d513eae9ba1f8d90ef298490132cffdc
5
5
  SHA512:
6
- metadata.gz: 15a2855e04e9d1fe34404b18c8ec3bab1347d10401a45ca356d554266e9c03a27e2c3edc4d3ea9f1ced4b751e669b2afaa595a195d1895f240e6b84191b0afce
7
- data.tar.gz: db4ef9333518ce6fc72c174f6c9498e5213031563cd4dd6fd25b6ff56b5735499cca0f1cd202fa3dd4693d5bf394a15680a8b4ba00256c2111eff2103c8d51d1
6
+ metadata.gz: f46537a99393fe4abe1cbd8463269e0507e94f820a807017de0d1b97c2154d4c8e1e1e912387260907403a067aabbfa770eef5b8c052405144c0f564e9c7ed8a
7
+ data.tar.gz: 6b8bb95b26328f36a6ac07adbb1866484714a3add2681831477fab6687258b7d9180adefc42da91ac5a54053b6c7041ef0221aa92effa98bcd9c18b9cbc344ed
data/README.md CHANGED
@@ -54,6 +54,12 @@ I'm a huge fan of vim dispatch. Here's my `.vimrc` entries that bind `<F5>` to "
54
54
  :map <f5> :w <cr> :execute "Dispatch splot -p spring -f % -l " . ( line(".") + 1 )<cr>
55
55
  :map <f6> :w <cr> :Dispatch splot -p spring -f %<cr>
56
56
 
57
+ ## Project configuration
58
+
59
+ If you have some specific project configuration, you can store arguments to `splot` as key value pairs (parsed by YAML) in a file called `.splotrc` in your project root. For example, if you want to tell `splot` to use `zeus` when running tests in this project:
60
+
61
+ echo "preloader: zeus" > .splotrc
62
+
57
63
  ## Notes and planned features
58
64
 
59
65
  1. When invoking a `Test::Unit` test, `splot` defaults to using the `rake test`. This is to be compatible with preloaders like `spring` or `zeus`.
@@ -61,8 +67,8 @@ I'm a huge fan of vim dispatch. Here's my `.vimrc` entries that bind `<F5>` to "
61
67
  3. I'm planning on adding git integration. Think "auto stage my changes if the tests pass."
62
68
  4. `vim-dispatch` seems to be unaware of when a test run passes, causing the "quickfix window" to stick around, even when there isn't a failure. I can potentially work around it in `splot`.
63
69
  5. I may write a small vim plugin to simplify the above dispatch mappings. It doesn't seem super necessary at this point, and I like to keep my plugin list small.
64
- 6. I'd like to implement project level configuration. That way, you can store the information necessary to teach `splot` how to run your tests inside your project, kind of like how a `ruby-version` file configures the version of ruby you use.
65
70
  7. More context specific handlers. For example, running `splot` on a `.gemspec` file should build the gem (if the tests all pass). Ideally, this would be extensible and not bundled in this gem.
71
+ 8. Auto detect preloaders (zeus/spring/etc).
66
72
 
67
73
  ## Contributing
68
74
 
data/bin/splot CHANGED
@@ -7,4 +7,4 @@ rescue LoadError
7
7
  require "splot"
8
8
  end
9
9
 
10
- Kernel.exec Splot.build_command_from_argv
10
+ Splot.exec_command_from_argv
@@ -5,6 +5,7 @@ require "splot/version"
5
5
 
6
6
  module Splot
7
7
  autoload :Command, "splot/command"
8
+ autoload :Config, "splot/config"
8
9
  autoload :CorrespondingFile, "splot/corresponding_file"
9
10
  autoload :Runner, "splot/runner"
10
11
 
@@ -16,11 +17,13 @@ module Splot
16
17
  params[:file] = new_file
17
18
  params.delete(:line)
18
19
  end
20
+ params.update Config.read_config params.delete(:config_file)
19
21
  Command.for(params[:file]).new(params).command
20
22
  end
21
23
 
22
- def self.build_command_from_argv
23
- Runner.new.tap(&:parse).command
24
+ def self.exec_command_from_argv
25
+ command = Runner.new.tap(&:parse).command
26
+ Kernel.exec command
24
27
  rescue RunnerNotFoundError => e
25
28
  warn "Warning: #{e}; will not run any test"
26
29
  exit 2
@@ -0,0 +1,19 @@
1
+ require 'yaml'
2
+
3
+ module Splot
4
+ module Config
5
+ extend self
6
+
7
+ def read_config(config_path)
8
+ return {} unless File.size? String(config_path)
9
+ symbolize_keys YAML.load File.read config_path
10
+ end
11
+
12
+ def symbolize_keys(hash)
13
+ hash.keys.each do |k|
14
+ hash[k.to_sym] = hash.delete k if k.is_a?(String)
15
+ end
16
+ hash
17
+ end
18
+ end
19
+ end
@@ -11,6 +11,11 @@ module Splot
11
11
  end
12
12
 
13
13
  def parse
14
+ parse_splotrc
15
+ parse_command_line_arguments
16
+ end
17
+
18
+ def parse_command_line_arguments
14
19
  OptionParser.new do |opts|
15
20
  opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [options]"
16
21
 
@@ -35,5 +40,15 @@ module Splot
35
40
  end
36
41
  end.parse!
37
42
  end
43
+
44
+ def parse_splotrc
45
+ params[:config_file] = splotrc if File.size? splotrc
46
+ end
47
+
48
+ private
49
+
50
+ def splotrc
51
+ ".splotrc"
52
+ end
38
53
  end
39
54
  end
@@ -1,3 +1,3 @@
1
1
  module Splot
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
@@ -0,0 +1 @@
1
+ preloader: spring
@@ -83,6 +83,19 @@ class SplotTest < Minitest::Test
83
83
  Splot.command(file: "lib/splot.rb", line: 5)
84
84
  end
85
85
 
86
+ def test_config_file_can_set_params
87
+ assert_equal "spring rspec path/to/my_spec.rb",
88
+ Splot.command(file: "path/to/my_spec.rb", config_file: "test/fixtures/config_example_rc")
89
+ end
90
+
91
+ def test_auto_loads_dot_splotrc
92
+ splotrc = File.expand_path('../../.splotrc', __FILE__)
93
+ File.write splotrc, "include_path: test/fixtures"
94
+ assert_equal 0, run_binary(runner: "ruby", file: "test/fixtures/test_unit_example_test.rb", line: 5)
95
+ ensure
96
+ File.unlink splotrc if File.exist? splotrc
97
+ end
98
+
86
99
  private
87
100
 
88
101
  def run_binary(params = {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: splot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ntl
@@ -112,16 +112,19 @@ files:
112
112
  - bin/splot
113
113
  - lib/splot.rb
114
114
  - lib/splot/command.rb
115
+ - lib/splot/config.rb
115
116
  - lib/splot/corresponding_file.rb
116
117
  - lib/splot/runner.rb
117
118
  - lib/splot/version.rb
118
119
  - splot.gemspec
119
120
  - test/corresponding_file_test.rb
120
121
  - test/fixtures/activesupport_example_test.rb
122
+ - test/fixtures/config_example_rc
121
123
  - test/fixtures/fake_test_helper.rb
122
124
  - test/fixtures/test_unit_example_test.rb
123
125
  - test/splot_test.rb
124
126
  - test/test_helper.rb
127
+ - tmp/.gitkeep
125
128
  homepage: https://github.com/ntl/splot
126
129
  licenses:
127
130
  - MIT
@@ -149,6 +152,7 @@ summary: Run any test from any file from any project :)
149
152
  test_files:
150
153
  - test/corresponding_file_test.rb
151
154
  - test/fixtures/activesupport_example_test.rb
155
+ - test/fixtures/config_example_rc
152
156
  - test/fixtures/fake_test_helper.rb
153
157
  - test/fixtures/test_unit_example_test.rb
154
158
  - test/splot_test.rb