danger-pronto 0.2.1 → 0.3.0

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: 9c201403b85079c065dd58b9514d4262c4559edf
4
- data.tar.gz: 48525464ca0dc64b56be1d2d6aa98d560caf09d9
3
+ metadata.gz: de661477eafe79f51a9b06ec0ad7b89337624606
4
+ data.tar.gz: d69d88f8bc211fba154640b07378a93af78fd5b1
5
5
  SHA512:
6
- metadata.gz: 5a9c3822570e1ff41ace9383284d63fe54fa2fa20dc35f11d1570113f531d98b0c699af5c63e53e90ddec5597990158cd83b8dd8c758fc3ea561ee1ac103ec5f
7
- data.tar.gz: 3ffe16907a2c808ed534c7f06ce187eb97c4bcab794ed316b48234f6a4355cecd6893abf3c74bc642d23804732dbd7723cf49b39f4411333e78766b264134598
6
+ metadata.gz: 88c82a97f3e5db4a5bc4a73deaf7b6df9e54eefda73ada373cb46b86f81c6478774932339bb6ff74c7a1f7a3c1f9361b3cb08de5d86d7667394be69d5cea82c3
7
+ data.tar.gz: 857269cbfce5421a0c3e36711f6d4b5b14e558c33e617160dbc8f9aeda6f13dfab1cd08d4fe3652d70d0a97c89688b828f5f435f3645f5812e1c79542edbe461
data/README.md CHANGED
@@ -25,7 +25,7 @@ gem 'pronto-scss'
25
25
 
26
26
  ## Usage
27
27
 
28
- Run Files through Pronto.
28
+ Pronto runs the checks on a diff between the current HEAD and the provided commit-ish (default is master).
29
29
  Results are passed out as a table in markdown.
30
30
 
31
31
 
@@ -34,18 +34,17 @@ Specifying custom config file.
34
34
  pronto.lint
35
35
  ```
36
36
 
37
- Lint specific files in a folder, when they change
37
+ Run checks on a diff between the current HEAD and a specified commit
38
38
  ```ruby
39
- public_files = (modified_files + added_files).select { |path| path.include?("/public/") }
40
- pronto.lint public_files
39
+ pronto.lint("e757913")
41
40
  ```
42
41
 
43
42
  #### Methods
44
43
 
45
44
 
46
- `lint(files: String)`
45
+ `lint(commit: String)`
47
46
 
48
- Runs files through Pronto. Generates a `markdown` list of warnings.
47
+ Runs checks on a diff between the current HEAD and the provided commit-ish (default is master). Generates a `markdown` list of warnings.
49
48
 
50
49
 
51
50
 
@@ -1,3 +1,3 @@
1
1
  module Pronto
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -14,41 +14,26 @@ module Danger
14
14
  class DangerPronto < Plugin
15
15
 
16
16
  # Runs files through Pronto. Generates a `markdown` list of warnings.
17
- #
18
- # @param [String] files
19
- # A globbed string which should return the files that you want to
20
- # run though, defaults to nil. If nil, modified and added files from
21
- # the diff will be used.
22
- # @return [void]
23
- #
24
- def lint(files = nil)
25
- files_to_lint = fetch_files_to_lint(files)
17
+ def lint(commit = nil)
18
+ files = pronto(commit)
19
+ return if files.empty?
26
20
 
27
- return if offending_files.empty?
28
-
29
- markdown offenses_message(offending_files)
30
- end
31
-
32
- # Gets the offending files from pronto
33
- # @return [Array<Object>] Array of pronto warnings
34
- def offending_files(files = nil)
35
- files_to_lint = fetch_files_to_lint(files)
36
- pronto(files_to_lint)
21
+ markdown offenses_message(files)
37
22
  end
38
23
 
39
24
  private
40
25
 
41
26
  # Executes pronto command
42
- #
43
- # @param [Array<String>] files_to_lint
27
+ # @param commit [String] hash/branch/tag
44
28
  # @return [Hash] Converted hash from pronto json output
45
- #
46
- def pronto(files_to_lint)
47
- pronto_output = `#{'bundle exec ' if File.exists?('Gemfile')}pronto run -f json`
29
+ def pronto(specified_commit = nil)
30
+ commit = "origin/master"
31
+ commit = specified_commit if specified_commit.present?
32
+ pronto_output = `#{'bundle exec ' if File.exists?('Gemfile')}pronto run -f json -c #{commit}`
48
33
  JSON.parse(pronto_output)
49
34
  end
50
35
 
51
- # Builds the t
36
+ # Builds the message
52
37
  def offenses_message(offending_files)
53
38
  require 'terminal-table'
54
39
 
@@ -62,14 +47,5 @@ module Danger
62
47
  ).to_s
63
48
  message + table.split("\n")[1..-2].join("\n")
64
49
  end
65
-
66
- # Sets default files to modified and added files per commit
67
- # @param [Array<String>] files Optional specific files to lint
68
- #
69
- # @return [Array<String>] Final files to lint
70
- #
71
- def fetch_files_to_lint(files = nil)
72
- @files_to_lint ||= (files ? Dir.glob(files) : (git.modified_files + git.added_files))
73
- end
74
50
  end
75
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-pronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RestlessThinker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api