code_lister 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ### Changelogs
2
2
 
3
+ #### 0.2.2
4
+
5
+ - Support ruby version 1.9.3+
6
+
3
7
  #### 0.2.1
4
8
 
5
9
  - Make ruby version 2.1.0+ mandatory
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in code_explorer.gemspec
4
2
  gemspec
data/README.md CHANGED
@@ -14,8 +14,8 @@ Note: starting from version `0.1.0` this gem will follow the [Semantic Versionin
14
14
 
15
15
  ### NOTES
16
16
 
17
- - Starting from version 0.2.0 only ruby 2.0.x are supported
18
- - Use version 0.1.x if you need to use with ruby 1.9.x
17
+ - Starting from version 0.2.0 only ruby 2.1.0+ are supported (use refinement instead of monkeypatching)
18
+ - Use version 0.1.x if you need to use with ruby 1.9.3
19
19
 
20
20
  ### Installation
21
21
 
data/code_lister.gemspec CHANGED
@@ -11,26 +11,28 @@ Gem::Specification.new do |spec|
11
11
  spec.description = "List/filter files similar to 'find then grep' command in Linux/Unix based system"
12
12
  spec.homepage = "https://github.com/agilecreativity/code_lister"
13
13
  spec.license = "MIT"
14
- spec.required_ruby_version = ">= 2.1.0"
15
- spec.files = Dir.glob("{bin,lib}/**/*") + %w[Gemfile
16
- Rakefile
17
- code_lister.gemspec
18
- README.md
19
- CHANGELOG.md
20
- LICENSE
21
- .rubocop.yml
22
- .gitignore]
14
+ spec.required_ruby_version = ">= 1.9.3"
15
+ spec.files = Dir.glob("{bin,lib,spec}/**/*") + %w[Gemfile
16
+ Rakefile
17
+ code_lister.gemspec
18
+ README.md
19
+ CHANGELOG.md
20
+ LICENSE
21
+ .rubocop.yml
22
+ .gitignore]
23
23
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ["lib"]
26
- spec.add_runtime_dependency "thor", "~> 0.19"
27
- spec.add_runtime_dependency "agile_utils", "~> 0.2.0"
28
- spec.add_development_dependency "bundler", "~> 1.6"
29
- spec.add_development_dependency "rake", "~> 10.3"
30
- spec.add_development_dependency "rspec", "~> 2.14"
31
- spec.add_development_dependency "guard-rspec", "~> 4.2"
32
- spec.add_development_dependency "awesome_print", "~> 1.2"
33
- spec.add_development_dependency "pry", "~> 0.9"
34
- spec.add_development_dependency "fuubar", "~> 1.3"
35
- spec.add_development_dependency "rubocop", "~> 0.23"
26
+
27
+ spec.add_runtime_dependency "agile_utils", "~> 0.2.2"
28
+ spec.add_runtime_dependency "thor", "~> 0.19.1"
29
+
30
+ spec.add_development_dependency "awesome_print", "~> 1.2.0"
31
+ spec.add_development_dependency "bundler", "~> 1.7.0"
32
+ spec.add_development_dependency "fuubar", "~> 2.0.0"
33
+ spec.add_development_dependency "guard-rspec", "~> 4.3.1"
34
+ spec.add_development_dependency "pry", "~> 0.10.0"
35
+ spec.add_development_dependency "rake", "~> 10.3.2"
36
+ spec.add_development_dependency "rspec", "~> 3.0.0"
37
+ spec.add_development_dependency "rubocop", "~> 0.24.1"
36
38
  end
data/lib/code_lister.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require_relative "code_lister/version"
2
- require_relative "code_lister/logger"
3
2
  require_relative "code_lister/code_lister"
4
3
  require_relative "code_lister/cli"
5
4
  require_relative "code_lister/main"
@@ -2,8 +2,6 @@ require "thor"
2
2
  require "agile_utils"
3
3
  module CodeLister
4
4
  class CLI < Thor
5
- using AgileUtils::HashExt
6
-
7
5
  # rubocop:disable AmbiguousOperator, LineLength
8
6
  desc "find", "List files by extensions, patterns, and simple criteria"
9
7
  method_option *AgileUtils::Options::BASE_DIR
@@ -12,7 +12,9 @@ module CodeLister
12
12
  files
13
13
  end
14
14
 
15
- private def default_options
15
+ private
16
+
17
+ def default_options
16
18
  {
17
19
  base_dir: Dir.pwd,
18
20
  recursive: true,
@@ -1,3 +1,3 @@
1
1
  module CodeLister
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/demo1.xxx.rb
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/demo1.yyy.rb
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/demo2.xxx.rb
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/demo2.yyy.rb
@@ -0,0 +1 @@
1
+ // file: test/fixtures/java/demo3.xxx.java
@@ -0,0 +1 @@
1
+ // file: test/fixtures/java/demo3.yyy.java
@@ -0,0 +1 @@
1
+ // file: test/fixtures/java/demo4.xxx.java
@@ -0,0 +1 @@
1
+ // file: test/fixtures/java/demo4.yyy.java
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/noexts1_zzz
@@ -0,0 +1 @@
1
+ # file: spec/fixtures/noexts2_zzz
@@ -0,0 +1,74 @@
1
+ require_relative "../../spec_helper"
2
+ describe CodeLister do
3
+ context "#files_from_command" do
4
+ it "returns empty result with invalid parameter" do
5
+ expect(CodeLister.files_from_command("invalid-command")).to eq []
6
+ end
7
+ describe "use with `find` command" do
8
+ it "returns result list when base_dir is a not a current directory" do
9
+ base_dir = File.expand_path(File.dirname(__FILE__) + "/../../fixtures")
10
+ files = CodeLister.files_from_command("find ./spec/fixtures -type f -iname '*.rb'")
11
+ files = CodeLister.remove_prefix(files, base_dir).sort
12
+ expect(files.sort)
13
+ .to eq [
14
+ "./demo1.xxx.rb",
15
+ "./demo1.yyy.rb",
16
+ "./demo2.xxx.rb",
17
+ "./demo2.yyy.rb"
18
+ ]
19
+ end
20
+ it "returns empty list when no match found" do
21
+ base_dir = File.expand_path(File.dirname(__FILE__) + "/../fixtures")
22
+ files = CodeLister.files_from_command("find ./spec/fixtures -type f -iname '*.XYZ'")
23
+ files = CodeLister.remove_prefix(files, base_dir).sort
24
+ expect(files).to be_empty
25
+ end
26
+ end
27
+ end
28
+
29
+ context "#files" do
30
+ it "works with invalid input" do
31
+ expect { CodeLister.files("bad-args") }.to raise_error
32
+ end
33
+
34
+ it "works with valid input" do
35
+ expect(CodeLister.files(base_dir: "spec/fixtures", exts: %w[xxx.rb])).to eq ["./demo1.xxx.rb",
36
+ "./demo2.xxx.rb"]
37
+ end
38
+
39
+ it "returns empty result if no match found" do
40
+ expect(CodeLister.files(base_dir: "spec/fixtures", exts: %w[invalid-extension])).to eq []
41
+ end
42
+ end
43
+
44
+ context "#filter" do
45
+ before :each do
46
+ @file_list = CodeLister.files(base_dir: "spec/fixtures", exts: %w[xxx.rb], recursive: true)
47
+ end
48
+
49
+ it "works with empty filter inputs" do
50
+ expect(CodeLister.filter(@file_list, inc_words: [], exc_words: [])).to eq @file_list
51
+ end
52
+
53
+ it "works with unique match" do
54
+ expect(CodeLister.filter(@file_list, inc_words: %w[demo1])).to eq ["./demo1.xxx.rb"]
55
+ end
56
+
57
+ it "works with multiples matches" do
58
+ expect(CodeLister.filter(@file_list, inc_words: %w[demo])).to eq ["./demo1.xxx.rb",
59
+ "./demo2.xxx.rb"]
60
+ end
61
+
62
+ it "filters out the words that we don't want" do
63
+ expect(CodeLister.filter(@file_list, exc_words: %w[demo1])).to eq ["./demo2.xxx.rb"]
64
+ end
65
+
66
+ it "ignores case by default" do
67
+ expect(CodeLister.filter(@file_list, inc_words: %w[DeMo1])).to eq ["./demo1.xxx.rb"]
68
+ end
69
+
70
+ it "does not ignore case if specified" do
71
+ expect(CodeLister.filter(@file_list, inc_words: %w[DeMo1], ignore_case: false)).to be_empty
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,12 @@
1
+ require_relative "../../spec_helper"
2
+ describe CodeLister do
3
+ context "#files" do
4
+ it "works with non_exts option" do
5
+ list = CodeLister::Main.run base_dir: "spec/fixtures/",
6
+ recursive: true,
7
+ non_exts: %w[noexts1_zzz noexts2_zzz]
8
+ expect(list).to eq ["./noexts1_zzz",
9
+ "./noexts2_zzz"]
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = "random"
17
+ end
18
+ require_relative "../lib/code_lister"
19
+ include CodeLister
metadata CHANGED
@@ -1,155 +1,176 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_lister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Burin Choomnuan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
12
+ date: 2014-08-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
- name: thor
15
+ name: agile_utils
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: '0.19'
21
+ version: 0.2.2
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
- version: '0.19'
29
+ version: 0.2.2
27
30
  - !ruby/object:Gem::Dependency
28
- name: agile_utils
31
+ name: thor
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
- version: 0.2.0
37
+ version: 0.19.1
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
- version: 0.2.0
45
+ version: 0.19.1
41
46
  - !ruby/object:Gem::Dependency
42
- name: bundler
47
+ name: awesome_print
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - "~>"
51
+ - - ~>
46
52
  - !ruby/object:Gem::Version
47
- version: '1.6'
53
+ version: 1.2.0
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - "~>"
59
+ - - ~>
53
60
  - !ruby/object:Gem::Version
54
- version: '1.6'
61
+ version: 1.2.0
55
62
  - !ruby/object:Gem::Dependency
56
- name: rake
63
+ name: bundler
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - "~>"
67
+ - - ~>
60
68
  - !ruby/object:Gem::Version
61
- version: '10.3'
69
+ version: 1.7.0
62
70
  type: :development
63
71
  prerelease: false
64
72
  version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - "~>"
75
+ - - ~>
67
76
  - !ruby/object:Gem::Version
68
- version: '10.3'
77
+ version: 1.7.0
69
78
  - !ruby/object:Gem::Dependency
70
- name: rspec
79
+ name: fuubar
71
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
72
82
  requirements:
73
- - - "~>"
83
+ - - ~>
74
84
  - !ruby/object:Gem::Version
75
- version: '2.14'
85
+ version: 2.0.0
76
86
  type: :development
77
87
  prerelease: false
78
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
79
90
  requirements:
80
- - - "~>"
91
+ - - ~>
81
92
  - !ruby/object:Gem::Version
82
- version: '2.14'
93
+ version: 2.0.0
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: guard-rspec
85
96
  requirement: !ruby/object:Gem::Requirement
97
+ none: false
86
98
  requirements:
87
- - - "~>"
99
+ - - ~>
88
100
  - !ruby/object:Gem::Version
89
- version: '4.2'
101
+ version: 4.3.1
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
93
106
  requirements:
94
- - - "~>"
107
+ - - ~>
95
108
  - !ruby/object:Gem::Version
96
- version: '4.2'
109
+ version: 4.3.1
97
110
  - !ruby/object:Gem::Dependency
98
- name: awesome_print
111
+ name: pry
99
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
100
114
  requirements:
101
- - - "~>"
115
+ - - ~>
102
116
  - !ruby/object:Gem::Version
103
- version: '1.2'
117
+ version: 0.10.0
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
107
122
  requirements:
108
- - - "~>"
123
+ - - ~>
109
124
  - !ruby/object:Gem::Version
110
- version: '1.2'
125
+ version: 0.10.0
111
126
  - !ruby/object:Gem::Dependency
112
- name: pry
127
+ name: rake
113
128
  requirement: !ruby/object:Gem::Requirement
129
+ none: false
114
130
  requirements:
115
- - - "~>"
131
+ - - ~>
116
132
  - !ruby/object:Gem::Version
117
- version: '0.9'
133
+ version: 10.3.2
118
134
  type: :development
119
135
  prerelease: false
120
136
  version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
121
138
  requirements:
122
- - - "~>"
139
+ - - ~>
123
140
  - !ruby/object:Gem::Version
124
- version: '0.9'
141
+ version: 10.3.2
125
142
  - !ruby/object:Gem::Dependency
126
- name: fuubar
143
+ name: rspec
127
144
  requirement: !ruby/object:Gem::Requirement
145
+ none: false
128
146
  requirements:
129
- - - "~>"
147
+ - - ~>
130
148
  - !ruby/object:Gem::Version
131
- version: '1.3'
149
+ version: 3.0.0
132
150
  type: :development
133
151
  prerelease: false
134
152
  version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
135
154
  requirements:
136
- - - "~>"
155
+ - - ~>
137
156
  - !ruby/object:Gem::Version
138
- version: '1.3'
157
+ version: 3.0.0
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: rubocop
141
160
  requirement: !ruby/object:Gem::Requirement
161
+ none: false
142
162
  requirements:
143
- - - "~>"
163
+ - - ~>
144
164
  - !ruby/object:Gem::Version
145
- version: '0.23'
165
+ version: 0.24.1
146
166
  type: :development
147
167
  prerelease: false
148
168
  version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
149
170
  requirements:
150
- - - "~>"
171
+ - - ~>
151
172
  - !ruby/object:Gem::Version
152
- version: '0.23'
173
+ version: 0.24.1
153
174
  description: List/filter files similar to 'find then grep' command in Linux/Unix based
154
175
  system
155
176
  email:
@@ -159,44 +180,70 @@ executables:
159
180
  extensions: []
160
181
  extra_rdoc_files: []
161
182
  files:
162
- - ".gitignore"
163
- - ".rubocop.yml"
164
- - CHANGELOG.md
165
- - Gemfile
166
- - LICENSE
167
- - README.md
168
- - Rakefile
169
183
  - bin/code_lister
170
- - code_lister.gemspec
171
- - lib/code_lister.rb
172
184
  - lib/code_lister/cli.rb
173
185
  - lib/code_lister/code_lister.rb
174
- - lib/code_lister/logger.rb
175
186
  - lib/code_lister/main.rb
176
187
  - lib/code_lister/version.rb
188
+ - lib/code_lister.rb
189
+ - spec/fixtures/demo1.xxx.rb
190
+ - spec/fixtures/demo1.yyy.rb
191
+ - spec/fixtures/demo2.xxx.rb
192
+ - spec/fixtures/demo2.yyy.rb
193
+ - spec/fixtures/java/demo3.xxx.java
194
+ - spec/fixtures/java/demo3.yyy.java
195
+ - spec/fixtures/java/demo4.xxx.java
196
+ - spec/fixtures/java/demo4.yyy.java
197
+ - spec/fixtures/noexts1_zzz
198
+ - spec/fixtures/noexts2_zzz
199
+ - spec/lib/code_lister/code_lister_spec.rb
200
+ - spec/lib/code_lister/main_spec.rb
201
+ - spec/spec_helper.rb
202
+ - Gemfile
203
+ - Rakefile
204
+ - code_lister.gemspec
205
+ - README.md
206
+ - CHANGELOG.md
207
+ - LICENSE
208
+ - .rubocop.yml
209
+ - .gitignore
177
210
  homepage: https://github.com/agilecreativity/code_lister
178
211
  licenses:
179
212
  - MIT
180
- metadata: {}
181
213
  post_install_message:
182
214
  rdoc_options: []
183
215
  require_paths:
184
216
  - lib
185
217
  required_ruby_version: !ruby/object:Gem::Requirement
218
+ none: false
186
219
  requirements:
187
- - - ">="
220
+ - - ! '>='
188
221
  - !ruby/object:Gem::Version
189
- version: 2.1.0
222
+ version: 1.9.3
190
223
  required_rubygems_version: !ruby/object:Gem::Requirement
224
+ none: false
191
225
  requirements:
192
- - - ">="
226
+ - - ! '>='
193
227
  - !ruby/object:Gem::Version
194
228
  version: '0'
195
229
  requirements: []
196
230
  rubyforge_project:
197
- rubygems_version: 2.2.2
231
+ rubygems_version: 1.8.23.2
198
232
  signing_key:
199
- specification_version: 4
233
+ specification_version: 3
200
234
  summary: List/filter files like 'find then grep' command in Linux/Unix based system
201
- test_files: []
235
+ test_files:
236
+ - spec/fixtures/demo1.xxx.rb
237
+ - spec/fixtures/demo1.yyy.rb
238
+ - spec/fixtures/demo2.xxx.rb
239
+ - spec/fixtures/demo2.yyy.rb
240
+ - spec/fixtures/java/demo3.xxx.java
241
+ - spec/fixtures/java/demo3.yyy.java
242
+ - spec/fixtures/java/demo4.xxx.java
243
+ - spec/fixtures/java/demo4.yyy.java
244
+ - spec/fixtures/noexts1_zzz
245
+ - spec/fixtures/noexts2_zzz
246
+ - spec/lib/code_lister/code_lister_spec.rb
247
+ - spec/lib/code_lister/main_spec.rb
248
+ - spec/spec_helper.rb
202
249
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: d8e7e0850ac1c629bb18a504492d663bb2a8f898
4
- data.tar.gz: ff1c57d1ad759d9e3672119a890ec06cc790460b
5
- SHA512:
6
- metadata.gz: cc7d65ff2a50bd2e33dadf8a26b9a2b114a586264015efd274acb86e058b5b4e27049ce145891ae2f319047402938d566801cebfdf95d20a6297e062d4c819be
7
- data.tar.gz: 9aee7c7be3b9c210e326230ad4b2ec28da45c0329382bca0385c63eceb42ecf241e752de654323ab95ac1ca878e052bc7b8773cf308ad362590b758ef3cc215a
@@ -1,10 +0,0 @@
1
- require "logger"
2
- module CodeLister
3
- class << self
4
- attr_writer :logger
5
- # @return [Logger] the Logger for the project
6
- def logger
7
- @logger ||= Logger.new STDOUT
8
- end
9
- end
10
- end