last_hit 0.1.4 → 0.1.5

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: 6fb202dbeff4fd849cf1d94f2f9d298ba0ad4559
4
- data.tar.gz: 0f2a0b9000c6973a20c4306b3009e79723ac64db
3
+ metadata.gz: 59e13f4478d536cedf317b36f257068aaba8c22e
4
+ data.tar.gz: 8580199c5d7375d9e980a58f03c7a8295f9b5344
5
5
  SHA512:
6
- metadata.gz: 0764ecea1c9058952103ca62ff3e6e774d19e5f5cc2eb96974f1fed4e9051c0a3709db24bd7eb4cad4ed005d9b5245c508195d6ac6d5fd279c1561d6c40d8a5c
7
- data.tar.gz: 9e9ef47334106c61ec2a653525e79d26e58e49d505c79c8d7ec14552be5c9f8f1207fe48a150ff76527263c62792adc5790e4cdb8ca9a00fd89f11e8a4007d62
6
+ metadata.gz: 77df2778856cbb06f1ff8ff6c87667cefb38d3cde02c3ac3a8d6056a894cd5206e4f527da1d39bc80b71204756aed504988d740d5fd5f7cd30e9d62cc5bb5021
7
+ data.tar.gz: f7e2aa2bb764eaede58761de5f86cc53a2cf475c69126cd6b660d86303d61ce31e9c8f58a009ae5693fd74742de6cb648902852d020729b9467473be865796c6
data/README.md CHANGED
@@ -20,19 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Config
22
22
 
23
- Create the file `config/initializers/last_hit.rb` and put below code to config the gem:
24
-
25
- ```ruby
26
- require 'last_hit'
27
-
28
- LastHit.configure do |config|
29
- # The command that run the tests
30
- config.test_command = 'spring rspec'
31
-
32
- # The base branch to which your current branch will be compared
33
- config.default_base_branch = 'develop'
34
- end
35
- ```
23
+ Run the command `last_hit init` to generate the config file for the gem. By default, the config file is `~/last_hit.yml`. You can set the path to the config file by attaching `-p [path]` to the command. For more information, please run `last_hit --help`.
36
24
 
37
25
  ## Usage
38
26
 
@@ -51,6 +39,10 @@ last_hit modified_tests
51
39
 
52
40
  #### Run all modified tests of your current branch compared to the base branch
53
41
 
42
+ Options for command:
43
+ * `-b [base_branch]` specify the base branch, optional.
44
+ * `-C [config_file_path]` specify the file path of the config, optional, default is `~/last_hit.yml`.
45
+
54
46
  ```ruby
55
47
  last_hit all_tests -b develop
56
48
 
data/lib/last_hit/cli.rb CHANGED
@@ -1,9 +1,33 @@
1
1
  require 'thor'
2
+ require 'yaml'
2
3
 
3
4
  class LastHit
5
+ class FileNotFound < StandardError; end
6
+
4
7
  class Cli < Thor
8
+ CONFIG_PATH = '~/last_hit.yml'
9
+
5
10
  include Thor::Actions
6
11
 
12
+ class << self
13
+ def load_config(path)
14
+ fail(FileNotFound, 'Config file not found')
15
+ config = YAML.load_file(File.expand_path(path))
16
+ Configure.set(config)
17
+ rescue FileNotFound => e
18
+ $stdout.puts(e.message)
19
+ end
20
+ end
21
+
22
+ desc 'init', 'Create config file for last_hit'
23
+ method_option :path, aliases: '-p', desc: 'Path of the config', type: :string, default: CONFIG_PATH
24
+ def init
25
+ create_file options[:path], <<-CONTENT
26
+ base_branch: 'development'
27
+ test_command: 'bundle exec rspec'
28
+ CONTENT
29
+ end
30
+
7
31
  desc 'modified_tests', 'Run tests which are currently modified'
8
32
  def modified_tests
9
33
  LastHit.new.modified_tests
@@ -11,7 +35,9 @@ class LastHit
11
35
 
12
36
  desc 'all_tests', 'Run all tests which have been modified in the current branch'
13
37
  method_option :base, aliases: '-b', desc: 'Base branch for compare', type: :string
38
+ method_option :config, aliases: '-C', desc: 'Path to the config file', type: :string, default: CONFIG_PATH
14
39
  def all_tests
40
+ Cli.load_config(options[:config])
15
41
  LastHit.new.all_tests(options[:base])
16
42
  end
17
43
  end
@@ -5,10 +5,15 @@ class LastHit
5
5
 
6
6
  class Configure
7
7
  @test_command = "bundle exec rspec"
8
- @default_base_branch = "development"
8
+ @base_branch = "development"
9
9
 
10
10
  class << self
11
11
  attr_accessor :test_command, :default_base_branch
12
+
13
+ def set(config)
14
+ @test_command = config['test_command'] if config['test_command'].present?
15
+ @base_branch = config['base_branch'] if config['base_branch'].present?
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -1,3 +1,3 @@
1
1
  class LastHit
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/last_hit.rb CHANGED
@@ -14,7 +14,8 @@ class LastHit
14
14
  process(files)
15
15
  end
16
16
 
17
- def all_tests(base_branch = Configure.default_base_branch)
17
+ def all_tests(base_branch)
18
+ base_branch = Configure.base_branch if base_branch.blank?
18
19
  files = RcAdapter::Git.current_branch_files(base_branch)
19
20
  process(files)
20
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: last_hit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duc Le
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-09 00:00:00.000000000 Z
11
+ date: 2016-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler