code_lister 0.0.6 → 0.0.7

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: fde9576db239d5b1600c135b1e50e98d37f92312
4
- data.tar.gz: 7bab4d02375dadea47e1d5eeae5f98df730e5fcf
3
+ metadata.gz: 29c1f57613e53602f8a8a101828cac54b05af619
4
+ data.tar.gz: f7268d21369628be9089d7a2becb88ece7bccaaa
5
5
  SHA512:
6
- metadata.gz: 1c0bae4f7989747ce15cff9164364d3ae99e232b1b8fd42de026e6c7a2d41015931f135e2f346236bd23358e22b24d5d76c17d847ab588ab99f13a3cbc203b97
7
- data.tar.gz: 7d93e8b9eb2aa048ed821368effe50f33cc232e2e91db7f2fc6a11012c0dc58d4ecd0e5df089c3944fb2abcc99322bdbf5bb6185b0201e55bf450aeef5e0e32b
6
+ metadata.gz: c969f80d68ff5a2d844faced9f2c9127a1319c1be362b2a2b4fcef79f7a22c10d5e1c037c9f691c8d71360598f678d30351fd4f8747aee262de434a372b02dad
7
+ data.tar.gz: dcb3aa77c8b80de464d5925c28d92c686315dd4f9330743fb202d90e0d34a7a0bc0b04efd884983f0d77d8e60c1df94ad75f6aebd9d4bb799ee226c4a37c0237
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/code_lister.svg)](http://badge.fury.io/rb/code_lister)
4
4
 
5
- This is the simple gem to search/filter the files based on simple criteria.
6
- It provides the functionality similar to subset of `find` command in Linux/Unix system.
5
+ Find/filter files based on simple criteria like `extension`, include/exclude some words in the name.
6
+ It provides the functionality similar to subset of `find | grep` command in Linux/Unix system.
7
7
 
8
- Initially it was part of my internal project. I extracted this out as a gem so
9
- that I can re-use it in other project. I hope you will find it useful.
8
+ Initially this was part of my internal project. I extracted this out as a gem so
9
+ that I can re-use it in other project.
10
10
 
11
11
  ### Installation
12
12
 
@@ -36,14 +36,15 @@ Usage/Synopsis:
36
36
 
37
37
  ```
38
38
  Usage:
39
- code_lister find
39
+ code_lister find [OPTIONS]
40
40
 
41
41
  Options:
42
42
  -b, [--base-dir=BASE_DIR] # Base directory
43
43
  # Default: . (current directory)
44
44
  -e, [--exts=one two three] # List of extensions to search for
45
- -n, [--inc-words=one two three] # List of words to be included in the result if any
46
- -x, [--exc-words=one two three] # List of words to be excluded from the result if any
45
+ -f, [--non-exts=one two three] # List of extensions to search for
46
+ -n, [--inc-words=one two three] # List of words to be included in the result
47
+ -x, [--exc-words=one two three] # List of words to be excluded from the result
47
48
  -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
48
49
  # Default: true
49
50
  -r, [--recursive], [--no-recursive] # Search for files recursively
@@ -57,8 +58,6 @@ Example Usage:
57
58
 
58
59
  - Find all java and ruby files in a given directory
59
60
 
60
- e.g.
61
-
62
61
  ```ruby
63
62
 
64
63
  # find all files that ends with '*.java' or '*.rb' in a given directory
@@ -83,7 +82,6 @@ spec/fixtures/demo1.xxx.rb
83
82
  spec/fixtures/demo2.xxx.rb
84
83
  spec/fixtures/java/demo3.xxx.java
85
84
  spec/fixtures/java/demo4.xxx.java
86
-
87
85
  ```
88
86
 
89
87
  - Same as previous step, but filter out result that contain the word `demo3` or `demo4`
@@ -130,11 +128,7 @@ rake -T
130
128
  # Play around with it using Pry
131
129
  rake pry
132
130
 
133
- # Or play around with it using IRB
134
- rake irb
135
- ```
136
-
137
- From inside `Pry` or `IRB`
131
+ From inside `Pry`
138
132
 
139
133
  ```ruby
140
134
  include CodeLister
@@ -155,27 +149,25 @@ always welcome.
155
149
 
156
150
  ### Changelogs
157
151
 
158
- #### 0.0.6
152
+ #### 0.0.7
153
+ - Make use of the 'agile_utils' gem for better code re-use
159
154
 
155
+ #### 0.0.6
160
156
  - Add `--non-exts` option that make it possible to include files without extension.
161
157
 
162
158
  #### 0.0.5
163
-
164
159
  - Refactoring the CLI options to make it easy for re-use in other library.
165
160
 
166
161
  #### 0.0.4
167
-
168
162
  - Add `ignore-case` option
169
163
  - Use `-n' for `--include-words` and use `-i` for `--ignore-case`.
170
164
  - Make the `--recursive` the default option
171
165
  - Make the `--ignore-case` the default option
172
166
 
173
167
  #### 0.0.3
174
-
175
168
  - Update README.md to include better sample usage, and misc cleanup.
176
169
 
177
170
  #### 0.0.2
178
-
179
171
  - initial release
180
172
 
181
173
  ## Contributing
data/Rakefile CHANGED
@@ -3,17 +3,8 @@ Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
- task :default => :spec
7
6
 
8
- task :irb do
9
- require 'irb'
10
- require 'awesome_print'
11
- require 'irb/completion'
12
- require 'code_lister'
13
- include CodeLister
14
- ARGV.clear
15
- IRB.start
16
- end
7
+ task :default => :spec
17
8
 
18
9
  task :pry do
19
10
  require 'pry'
data/code_lister.gemspec CHANGED
@@ -4,24 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'code_lister/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "code_lister"
7
+ spec.name = 'code_lister'
8
8
  spec.version = CodeLister::VERSION
9
- spec.authors = ["Burin Choomnuan"]
10
- spec.email = ["agilecreativity@gmail.com"]
11
- spec.summary = %q{Search, filter files easily using the power of ruby}
12
- spec.description = %q{List/filter files similar to 'find' command in Linux/Unix based system}
13
- spec.homepage = "https://github.com/agilecreativity/code_lister"
14
- spec.license = "MIT"
9
+ spec.authors = ['Burin Choomnuan']
10
+ spec.email = ['agilecreativity@gmail.com']
11
+ spec.summary = %q{List/filter files like 'find | grep' command in Linux/Unix based system}
12
+ spec.description = %q{List/filter files similar to 'find | grep' command in Linux/Unix based system}
13
+ spec.homepage = 'https://github.com/agilecreativity/code_lister'
14
+ spec.license = 'MIT'
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
19
- spec.add_runtime_dependency "thor"
20
- spec.add_development_dependency "bundler", "~> 1.5"
21
- spec.add_development_dependency "rake", "~> 10.1"
22
- spec.add_development_dependency "rspec", "~> 2.14"
23
- spec.add_development_dependency "guard-rspec", "~> 4.2"
24
- spec.add_development_dependency "awesome_print", "~> 1.2"
25
- spec.add_development_dependency "pry", "~> 0.9"
26
- spec.add_development_dependency "fuubar", "~> 1.3"
18
+ spec.require_paths = ['lib']
19
+ spec.add_runtime_dependency 'thor', '~> 0.19'
20
+ spec.add_runtime_dependency 'agile_utils', '~> 0.0.5'
21
+ spec.add_development_dependency 'bundler', '~> 1.5'
22
+ spec.add_development_dependency 'rake', '~> 10.1'
23
+ spec.add_development_dependency 'rspec', '~> 2.14'
24
+ spec.add_development_dependency 'guard-rspec', '~> 4.2'
25
+ spec.add_development_dependency 'awesome_print', '~> 1.2'
26
+ spec.add_development_dependency 'pry', '~> 0.9'
27
+ spec.add_development_dependency 'fuubar', '~> 1.3'
27
28
  end
@@ -1,74 +1,24 @@
1
1
  require 'thor'
2
+ require 'agile_utils'
2
3
  require_relative 'core_ext/hash'
3
-
4
- module CodeLister
5
- class BaseCLI < Thor
6
-
7
- def self.shared_options
8
-
9
- method_option :base_dir,
10
- aliases: "-b",
11
- desc: "Base directory",
12
- default: Dir.pwd
13
-
14
- method_option :exts,
15
- aliases: "-e",
16
- desc: "List of extensions to search for",
17
- type: :array,
18
- default: []
19
-
20
- method_option :non_exts,
21
- aliases: "-f",
22
- desc: "List of files without extension to search for",
23
- type: :array,
24
- default: []
25
-
26
- method_option :inc_words,
27
- aliases: "-n",
28
- desc: "List of words to be included in the result if any",
29
- type: :array,
30
- default: []
31
-
32
- method_option :exc_words,
33
- aliases: "-x",
34
- desc: "List of words to be excluded from the result if any",
35
- type: :array,
36
- default: []
37
-
38
- method_option :ignore_case,
39
- aliases: "-i",
40
- desc: "Match case insensitively",
41
- type: :boolean,
42
- default: true
43
-
44
- method_option :recursive,
45
- aliases: "-r",
46
- desc: "Search for files recursively",
47
- type: :boolean,
48
- default: true
49
-
50
- method_option :version,
51
- aliases: "-v",
52
- desc: "Display version information",
53
- type: :boolean,
54
- default: false
55
- end
56
- end
57
- end
58
-
59
4
  module CodeLister
60
- class CLI < CodeLister::BaseCLI
61
-
5
+ class CLI < Thor
62
6
  desc "find", "List files by extensions, patterns, and simple criteria"
63
-
64
- shared_options
65
-
7
+ method_option *AgileUtils::Options::BASE_DIR
8
+ method_option *AgileUtils::Options::EXTS
9
+ method_option *AgileUtils::Options::NON_EXTS
10
+ method_option *AgileUtils::Options::INC_WORDS
11
+ method_option *AgileUtils::Options::EXC_WORDS
12
+ method_option *AgileUtils::Options::IGNORE_CASE
13
+ method_option *AgileUtils::Options::RECURSIVE
14
+ method_option *AgileUtils::Options::VERSION
66
15
  def find
67
- if options[:version]
16
+ opts = options.symbolize_keys
17
+ if opts[:version]
68
18
  puts "You are using CodeLister Version #{CodeLister::VERSION}"
69
19
  exit
70
20
  end
71
- CodeLister::Main.run(options.symbolize_keys)
21
+ CodeLister::Main.run(opts)
72
22
  end
73
23
 
74
24
  # Note: we don't use help so that we can run :r !./bin/code_lister help find
@@ -81,11 +31,11 @@ Usage:
81
31
 
82
32
  Options:
83
33
  -b, [--base-dir=BASE_DIR] # Base directory
84
- # Default: /home/bchoomnuan/Dropbox/spikes/code_lister
34
+ # Default: . (current directory)
85
35
  -e, [--exts=one two three] # List of extensions to search for
86
- -f, [--non-exts=one two three] # List of files without extension to search for
87
- -n, [--inc-words=one two three] # List of words to be included in the result if any
88
- -x, [--exc-words=one two three] # List of words to be excluded from the result if any
36
+ -f, [--non-exts=one two three] # List of extensions to search for
37
+ -n, [--inc-words=one two three] # List of words to be included in the result
38
+ -x, [--exc-words=one two three] # List of words to be excluded from the result
89
39
  -i, [--ignore-case], [--no-ignore-case] # Match case insensitively
90
40
  # Default: true
91
41
  -r, [--recursive], [--no-recursive] # Search for files recursively
@@ -35,10 +35,6 @@ module CodeLister
35
35
  ignore_case: true
36
36
  }.merge(args)
37
37
 
38
- inc_words = opts[:inc_words]
39
- exc_words = opts[:exc_words]
40
- ignore_case = opts[:ignore_case]
41
-
42
38
  take_any!(file_list, opts)
43
39
  drop_any!(file_list, opts)
44
40
 
@@ -1,7 +1,6 @@
1
1
  module CodeLister
2
2
  class Main
3
3
  class << self
4
-
5
4
  def run(options = {})
6
5
  args = default_options.merge(options)
7
6
 
@@ -13,25 +12,20 @@ module CodeLister
13
12
 
14
13
  files = CodeLister.filter(files, inc_words: inc_words,
15
14
  exc_words: exc_words)
16
-
17
- # Note: for now just print out the list of files
18
15
  puts files
19
-
20
16
  files
21
17
  end
22
18
 
23
19
  private
24
20
 
25
21
  def default_options
26
- options = {
27
- base_dir: Dir.pwd,
28
- recursive: false,
22
+ { base_dir: Dir.pwd,
23
+ recursive: true,
29
24
  ignore_case: true,
30
25
  inc_words: [],
31
26
  exc_words: [],
32
27
  exts: [],
33
- non_exts: []
34
- }
28
+ non_exts: [] }
35
29
  end
36
30
  end
37
31
  end
@@ -1,3 +1,3 @@
1
1
  module CodeLister
2
- VERSION = "0.0.6"
2
+ VERSION = '0.0.7'
3
3
  end
@@ -52,6 +52,5 @@ describe CodeLister do
52
52
  "spec/fixtures/demo2.xxx.rb" ]
53
53
  end
54
54
  end
55
-
56
55
  end
57
56
  end
@@ -1,12 +1,12 @@
1
1
  require_relative '../spec_helper'
2
2
  describe CodeLister do
3
- context "#files" do
3
+ context '#files' do
4
4
  it 'works with non_exts option' do
5
5
  list = CodeLister::Main.run base_dir: 'spec/fixtures/',
6
6
  recursive: true,
7
7
  non_exts: %w(noexts1_zzz noexts2_zzz)
8
- expect(list).to eq [ "spec/fixtures/noexts1_zzz",
9
- "spec/fixtures/noexts2_zzz" ]
8
+ expect(list).to eq ['spec/fixtures/noexts1_zzz',
9
+ 'spec/fixtures/noexts2_zzz']
10
10
  end
11
11
  end
12
12
  end
data/spec/spec_helper.rb CHANGED
@@ -16,5 +16,5 @@ RSpec.configure do |config|
16
16
  config.order = 'random'
17
17
  end
18
18
 
19
- require_relative "../lib/code_lister"
19
+ require_relative '../lib/code_lister'
20
20
  include CodeLister
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_lister
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burin Choomnuan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.19'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: agile_utils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: '0'
40
+ version: 0.0.5
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +136,8 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '1.3'
125
- description: List/filter files similar to 'find' command in Linux/Unix based system
139
+ description: List/filter files similar to 'find | grep' command in Linux/Unix based
140
+ system
126
141
  email:
127
142
  - agilecreativity@gmail.com
128
143
  executables:
@@ -183,7 +198,7 @@ rubyforge_project:
183
198
  rubygems_version: 2.2.2
184
199
  signing_key:
185
200
  specification_version: 4
186
- summary: Search, filter files easily using the power of ruby
201
+ summary: List/filter files like 'find | grep' command in Linux/Unix based system
187
202
  test_files:
188
203
  - spec/code_lister/code_lister_spec.rb
189
204
  - spec/code_lister/main_spec.rb