polishgeeks-dev-tools 1.1.1 → 1.1.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
  SHA1:
3
- metadata.gz: 6cdf2be6fcee075622277eecdbd4ecaf6858ec15
4
- data.tar.gz: 19e96f4dfa8fab46ec45bc7d1ac9dd256d45494a
3
+ metadata.gz: f4c7e5f2ebd0f096a10ac590409dd86df64cb6b0
4
+ data.tar.gz: c2a9424bac6e6719c716ce3f1dab75cbe933ebf3
5
5
  SHA512:
6
- metadata.gz: 836d8a4b439be5dd06d0994a768df7b9302ef08128d87f22592022426866be9317dc05551b711c025079267d7a4f06cc77380b7533915c2b86a469e8094b052a
7
- data.tar.gz: 02d38ea6c905261198cd47e89a35c78e71197aa78eb10a28dd5a90c86a5a5d542aeb717bc670e65d79d0d713d3fe263abed3ac8976c6c3f9332d3fb68dd95079
6
+ metadata.gz: 56b7f225f663f401a4c89f486f3cab8627ba84e6cab5b6d0c2a6a0d7f37b7ecce6e843b2bb7225ea1abc0e0d00cde28594e9baf01d4937d1e9f6c88618758a77
7
+ data.tar.gz: 753bd5caff7b3183e938f175342d52eee52a2bb3d7a130e252838a522934ed974b3b2d1bcffa10a20951c0209a02a3187dfc3e9db7d9396fd8d36313172bde89
@@ -1,5 +1,10 @@
1
1
  # PolishGeeks Dev Tools Changelog
2
2
 
3
+ ## 1.1.2
4
+
5
+ - Ignore .DS_Store files in FinalBlankLine validator.
6
+ - Changed FinalBlankLine excluded mechanism. You can define directories and files (ex. lib/command or lib/file.rb). Please don't use path with stars convention (ex. lib/**/*).
7
+
3
8
  ## 1.1.1
4
9
 
5
10
  - Ignore doc directory in FinalBlankLine validator
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polishgeeks-dev-tools (1.1.1)
4
+ polishgeeks-dev-tools (1.1.2)
5
5
  brakeman
6
6
  faker
7
7
  haml-lint
@@ -148,7 +148,7 @@ GEM
148
148
  reek (= 1.6.3)
149
149
  ruby2ruby (>= 2.1.1, < 3.0)
150
150
  virtus (~> 1.0)
151
- sass (3.4.17)
151
+ sass (3.4.18)
152
152
  sexp_processor (4.6.0)
153
153
  shoulda (3.5.0)
154
154
  shoulda-context (~> 1.0, >= 1.0.1)
data/README.md CHANGED
@@ -70,10 +70,10 @@ determine, which you can use in your project:
70
70
 
71
71
  Some validators might accept additional config settings - please refer to this table for a description on how to use them:
72
72
 
73
- | Option | Validator | Description |
74
- |-------------------------------|-----------------------|-----------------------------------------------------------------------------------------------------|
75
- | rspec_files_structure_ignored | rspec_files_structure | You can provide an array of files that should be ignored |
76
- | final_blank_line_ignored | final_blank_line | You can provide an array of files (ex. lib/file.rb) or paths (ex. lib/\*\*/\*) that should be ignored |
73
+ | Option | Validator | Description |
74
+ |-------------------------------|-----------------------|-------------------------------------------------------------------------------------------------------------|
75
+ | rspec_files_structure_ignored | rspec_files_structure | You can provide an array of files that should be ignored |
76
+ | final_blank_line_ignored | final_blank_line | You can provide an array of files (ex. lib/file.rb) or directories (ex. lib/command) that should be ignored |
77
77
 
78
78
  ## Usage in any Rails/Ruby application
79
79
 
@@ -17,6 +17,7 @@ module PolishGeeks
17
17
  public
18
18
  app/assets/images
19
19
  app/assets/fonts
20
+ .DS_Store
20
21
  )
21
22
 
22
23
  # Executes this command and set output and counter variables
@@ -49,40 +50,33 @@ module PolishGeeks
49
50
  private
50
51
 
51
52
  # @return [Array<String>] array with files to analyze
53
+ # @note method take all not excluded files, also with hidden files
52
54
  def files_to_analyze
53
55
  # expression {*,.*} is needed because glob method don't take unix-like hidden files
54
- files_from_path('**/{*,.*}') - excludes
56
+ files = files_from_path('**/{*,.*}')
57
+ remove_excludes files
55
58
  end
56
59
 
57
- # @return [Array<String>] list of files that
58
- # should be excluded from checking
59
- def excludes
60
- (default_excludes + config_excludes).flatten
61
- end
62
-
63
- # @return [Array<String>] list of default excluded files
64
- # defined in DEFAULT_PATHS_TO_EXCLUDE
65
- def default_excludes
66
- excluded_files = []
67
-
68
- DEFAULT_PATHS_TO_EXCLUDE.each do |path|
69
- excluded_files << files_from_path("#{path}/**/{*,.*}")
60
+ # @param [Array<String>] files list which we want analyse
61
+ # @return [Array<String>] array without excluded files
62
+ def remove_excludes(files)
63
+ excluded_paths = excludes
64
+ files.delete_if do |file|
65
+ excluded_paths.any? { |exclude| file =~ /#{exclude}/ }
70
66
  end
67
+ end
71
68
 
72
- excluded_files
69
+ # @return [Array<String>] list of files/directories that
70
+ # should be excluded from checking
71
+ # @note excluded files/directories are defined in DEFAULT_PATHS_TO_EXCLUDE
72
+ # and in configuration file
73
+ def excludes
74
+ config_excludes + DEFAULT_PATHS_TO_EXCLUDE
73
75
  end
74
76
 
75
- # @return [Array<String>] list of excluded files from config file
77
+ # @return [Array<String>] list of excluded files/directories from config file
76
78
  def config_excludes
77
- excluded_files = []
78
- config_paths = DevTools.config.final_blank_line_ignored
79
- return [] unless config_paths
80
-
81
- config_paths.each do |path|
82
- excluded_files << files_from_path(path)
83
- end
84
-
85
- excluded_files
79
+ DevTools.config.final_blank_line_ignored || []
86
80
  end
87
81
 
88
82
  # @param [String] path from which we want take files
@@ -3,6 +3,6 @@ module PolishGeeks
3
3
  # Dev Tools for PolishGeeks developers
4
4
  module DevTools
5
5
  # Current version of dev tools
6
- VERSION = '1.1.1'
6
+ VERSION = '1.1.2'
7
7
  end
8
8
  end
@@ -90,8 +90,6 @@ RSpec.describe PolishGeeks::DevTools::Command::FinalBlankLine do
90
90
 
91
91
  describe '#files_to_analyze' do
92
92
  let(:files) { [rand.to_s, rand.to_s] }
93
- let(:excludes) { [files[0]] }
94
- let(:expected) { [files[1]] }
95
93
 
96
94
  before do
97
95
  expect(subject)
@@ -99,24 +97,33 @@ RSpec.describe PolishGeeks::DevTools::Command::FinalBlankLine do
99
97
  .with('**/{*,.*}')
100
98
  .and_return(files)
101
99
 
100
+ expect(subject)
101
+ .to receive(:remove_excludes)
102
+ .with(files)
103
+ .and_return(files)
104
+ end
105
+
106
+ it { expect(subject.send(:files_to_analyze)).to eq files }
107
+ end
108
+
109
+ describe '#remove_excludes' do
110
+ let(:files) { %w(lib/file.txt exclude.txt file.rb) }
111
+ let(:excludes) { %w(lib exclude.txt) }
112
+
113
+ before do
102
114
  expect(subject)
103
115
  .to receive(:excludes)
104
116
  .and_return(excludes)
105
117
  end
106
118
 
107
- it { expect(subject.send(:files_to_analyze)).to eq expected }
119
+ it { expect(subject.send(:remove_excludes, files)).to eq ['file.rb'] }
108
120
  end
109
121
 
110
122
  describe '#excludes' do
111
- let(:defaults) { [rand.to_s, rand.to_s] }
112
123
  let(:configs) { [rand.to_s] }
113
- let(:expected) { (defaults + configs).flatten }
124
+ let(:expected) { configs + described_class::DEFAULT_PATHS_TO_EXCLUDE }
114
125
 
115
126
  before do
116
- expect(subject)
117
- .to receive(:default_excludes)
118
- .and_return(defaults)
119
-
120
127
  expect(subject)
121
128
  .to receive(:config_excludes)
122
129
  .and_return(configs)
@@ -125,19 +132,6 @@ RSpec.describe PolishGeeks::DevTools::Command::FinalBlankLine do
125
132
  it { expect(subject.send(:excludes)).to eq expected }
126
133
  end
127
134
 
128
- describe '#default_excludes' do
129
- before do
130
- described_class::DEFAULT_PATHS_TO_EXCLUDE.each do |path|
131
- expect(subject)
132
- .to receive(:files_from_path)
133
- .with("#{path}/**/{*,.*}")
134
- .and_return(path)
135
- end
136
- end
137
-
138
- it { expect(subject.send(:default_excludes)).to eq described_class::DEFAULT_PATHS_TO_EXCLUDE }
139
- end
140
-
141
135
  describe '#config_excludes' do
142
136
  context 'final_blank_line_ignored is set' do
143
137
  let(:paths) { [rand.to_s, rand.to_s] }
@@ -147,13 +141,6 @@ RSpec.describe PolishGeeks::DevTools::Command::FinalBlankLine do
147
141
  expect(PolishGeeks::DevTools)
148
142
  .to receive(:config)
149
143
  .and_return config
150
-
151
- paths.each do |path|
152
- expect(subject)
153
- .to receive(:files_from_path)
154
- .with("#{path}")
155
- .and_return(path)
156
- end
157
144
  end
158
145
 
159
146
  it { expect(subject.send(:config_excludes)).to eq paths }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polishgeeks-dev-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maciej Mensfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-25 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler