code_lister 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +94 -7
- data/{CHANGELOGS.md → CHANGELOG.md} +6 -0
- data/Gemfile +1 -1
- data/README.md +21 -9
- data/Rakefile +5 -5
- data/bin/code_lister +6 -2
- data/code_lister.gemspec +29 -31
- data/lib/code_lister.rb +5 -5
- data/lib/code_lister/cli.rb +7 -5
- data/lib/code_lister/code_lister.rb +6 -6
- data/lib/code_lister/logger.rb +1 -1
- data/lib/code_lister/main.rb +8 -8
- data/lib/code_lister/version.rb +1 -1
- metadata +3 -4
- data/rubocop-todo.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc886d3f4e601c170e30c41a311f61e37bfecac
|
4
|
+
data.tar.gz: e909544107643a2bf2b816edc3bf395f807bbc25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38ced4389d381c0826fefc77c3733db019f4c3a2a8a086d4602559e4f5d1de2124b9daad61c214cdf594a3d665826dafacb4612ab68ea5c34be43e7abb8255af
|
7
|
+
data.tar.gz: 3c2ae7129c7db2ebab95d10a40c1563041d9ed2e319f5fd0d04fc32b001352b742f54f540657e59f7d68fa5fbc963c5c3cb3c7a13564b512f23cf75fb6e2a7b7
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,97 @@
|
|
1
|
-
# This is the configuration used to check the rubocop source code.
|
2
1
|
AllCops:
|
3
2
|
Include:
|
4
|
-
-
|
5
|
-
-
|
6
|
-
-
|
3
|
+
- Gemfile
|
4
|
+
- Guardfile
|
5
|
+
- Rakefile
|
7
6
|
- bin/*
|
8
|
-
|
9
|
-
-
|
10
|
-
|
7
|
+
- code_lister.gemspec
|
8
|
+
- lib/**/*.rb
|
9
|
+
- spec/**/*.rb
|
10
|
+
|
11
|
+
# Avoid long parameter lists
|
12
|
+
ParameterLists:
|
13
|
+
Max: 5
|
14
|
+
CountKeywordArgs: true
|
15
|
+
|
16
|
+
MethodLength:
|
17
|
+
CountComments: false
|
18
|
+
Max: 15
|
19
|
+
|
20
|
+
# Avoid more than `Max` levels of nesting.
|
21
|
+
BlockNesting:
|
22
|
+
Max: 4
|
23
|
+
|
24
|
+
# Align with the style guide.
|
25
|
+
CollectionMethods:
|
26
|
+
PreferredMethods:
|
27
|
+
collect: 'map'
|
28
|
+
inject: 'reduce'
|
29
|
+
find: 'detect'
|
30
|
+
find_all: 'select'
|
31
|
+
|
32
|
+
# Do not force public/protected/private keyword to be indented at the same
|
33
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
34
|
+
# because I think when scanning code it makes it easier to identify the
|
35
|
+
# sections of code and visually separate them. When the keyword is at the same
|
36
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
37
|
+
# to scan the code and see where the sections are.
|
38
|
+
AccessModifierIndentation:
|
39
|
+
Enabled: false
|
40
|
+
|
41
|
+
# Limit line length
|
42
|
+
LineLength:
|
43
|
+
Enabled: false
|
44
|
+
|
45
|
+
# Disable documentation checking until a class needs to be documented once
|
46
|
+
Documentation:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
# Enforce Ruby 1.8-compatible hash syntax
|
50
|
+
HashSyntax:
|
51
|
+
Enabled: true
|
52
|
+
|
53
|
+
# No spaces inside hash literals
|
54
|
+
SpaceInsideHashLiteralBraces:
|
55
|
+
EnforcedStyle: no_space
|
56
|
+
|
57
|
+
# Allow dots at the end of lines
|
58
|
+
DotPosition:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
# Don't require magic comment at the top of every file
|
62
|
+
Encoding:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
# Enforce outdenting of access modifiers (i.e. public, private, protected)
|
66
|
+
AccessModifierIndentation:
|
67
|
+
EnforcedStyle: outdent
|
68
|
+
|
69
|
+
EmptyLinesAroundAccessModifier:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
# Align ends correctly
|
73
|
+
EndAlignment:
|
74
|
+
AlignWith: variable
|
75
|
+
|
76
|
+
# Indentation of when/else
|
77
|
+
CaseIndentation:
|
78
|
+
IndentWhenRelativeTo: end
|
79
|
+
IndentOneStep: false
|
80
|
+
|
81
|
+
DoubleNegation:
|
82
|
+
Enabled: false
|
83
|
+
|
84
|
+
PercentLiteralDelimiters:
|
85
|
+
PreferredDelimiters:
|
86
|
+
'%': ()
|
87
|
+
'%i': ()
|
88
|
+
'%q': ()
|
89
|
+
'%Q': ()
|
90
|
+
'%r': '{}'
|
91
|
+
'%s': ()
|
92
|
+
'%w': '[]'
|
93
|
+
'%W': '[]'
|
94
|
+
'%x': ()
|
95
|
+
|
96
|
+
StringLiterals:
|
97
|
+
EnforcedStyle: double_quotes
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -33,14 +33,14 @@ Or install it yourself as:
|
|
33
33
|
List all pdf and epub files in the `/opts/downloads/` directory recursively
|
34
34
|
|
35
35
|
```sh
|
36
|
-
$code_lister
|
36
|
+
$code_lister --base-dir /opt/downloads/ --exts pdf epub --recursive
|
37
37
|
```
|
38
38
|
|
39
39
|
Usage/Synopsis:
|
40
40
|
|
41
41
|
```
|
42
42
|
Usage:
|
43
|
-
code_lister
|
43
|
+
code_lister [OPTIONS]
|
44
44
|
|
45
45
|
Options:
|
46
46
|
-b, [--base-dir=BASE_DIR] # Base directory
|
@@ -63,10 +63,11 @@ Example Usage:
|
|
63
63
|
- Find all java and ruby files in a given directory
|
64
64
|
|
65
65
|
```ruby
|
66
|
-
|
67
66
|
# find all files that ends with '*.java' or '*.rb' in a given directory
|
68
|
-
|
69
|
-
|
67
|
+
code_lister -b spec/fixtures/ -e rb java
|
68
|
+
```
|
69
|
+
|
70
|
+
Output:
|
70
71
|
|
71
72
|
```
|
72
73
|
./demo1.xxx.rb
|
@@ -81,17 +82,27 @@ Example Usage:
|
|
81
82
|
|
82
83
|
- Find all java java and ruby files but include only the files that contain the word `xxx`
|
83
84
|
|
84
|
-
```
|
85
|
-
|
85
|
+
```sh
|
86
|
+
$code_lister -b spec/fixtures/ -e rb java -n xxx
|
87
|
+
```
|
88
|
+
|
89
|
+
Output:
|
86
90
|
|
91
|
+
```
|
87
92
|
./demo1.xxx.rb
|
88
93
|
./demo2.xxx.rb
|
89
94
|
./java/demo3.xxx.java
|
90
95
|
./java/demo4.xxx.java
|
91
96
|
```
|
97
|
+
|
92
98
|
- Same as previous step, but filter out result that contain the word `demo3` or `demo4`
|
99
|
+
|
93
100
|
```ruby
|
94
|
-
|
101
|
+
$code_lister -b spec/fixtures/ -e rb java -n xxx -x demo3 demo4
|
102
|
+
```
|
103
|
+
Output:
|
104
|
+
|
105
|
+
```
|
95
106
|
./demo1.xxx.rb
|
96
107
|
./demo2.xxx.rb
|
97
108
|
```
|
@@ -99,7 +110,7 @@ Example Usage:
|
|
99
110
|
#### Using as ruby library
|
100
111
|
|
101
112
|
This is probably the proper way to utilize the library as the CLI only serve to
|
102
|
-
|
113
|
+
show the result in the console.
|
103
114
|
|
104
115
|
Example of how you might use the library in your own project.
|
105
116
|
|
@@ -129,6 +140,7 @@ rake -T
|
|
129
140
|
|
130
141
|
# Play around with it using Pry
|
131
142
|
rake pry
|
143
|
+
```
|
132
144
|
|
133
145
|
From inside `Pry`
|
134
146
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
2
|
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
require
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
6
6
|
|
7
7
|
task default: :spec
|
8
8
|
|
9
9
|
task :pry do
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
10
|
+
require "pry"
|
11
|
+
require "awesome_print"
|
12
|
+
require "code_lister"
|
13
13
|
include CodeLister
|
14
14
|
ARGV.clear
|
15
15
|
Pry.start
|
data/bin/code_lister
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require_relative
|
2
|
+
require_relative "../lib/code_lister"
|
3
3
|
include CodeLister
|
4
|
-
|
4
|
+
if ARGV.empty?
|
5
|
+
CodeLister::CLI.start(%w[usage])
|
6
|
+
else
|
7
|
+
CodeLister::CLI.start(%w[find].concat(ARGV))
|
8
|
+
end
|
data/code_lister.gemspec
CHANGED
@@ -1,37 +1,35 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
5
|
-
|
4
|
+
require "code_lister/version"
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
9
|
-
spec.authors
|
10
|
-
spec.email
|
11
|
-
spec.summary
|
12
|
-
spec.description
|
13
|
-
spec.homepage
|
14
|
-
spec.license
|
15
|
-
spec.files
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
rubocop-todo.yml)
|
6
|
+
spec.name = "code_lister"
|
7
|
+
spec.version = CodeLister::VERSION
|
8
|
+
spec.authors = ["Burin Choomnuan"]
|
9
|
+
spec.email = ["agilecreativity@gmail.com"]
|
10
|
+
spec.summary = %q(List/filter files like 'find then grep' command in Linux/Unix based system)
|
11
|
+
spec.description = %q(List/filter files similar to 'find then grep' command in Linux/Unix based system)
|
12
|
+
spec.homepage = "https://github.com/agilecreativity/code_lister"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.files = Dir.glob("{bin,lib}/**/*") + %w[Gemfile
|
15
|
+
Rakefile
|
16
|
+
code_lister.gemspec
|
17
|
+
README.md
|
18
|
+
CHANGELOG.md
|
19
|
+
LICENSE
|
20
|
+
.rubocop.yml
|
21
|
+
.gitignore]
|
24
22
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
25
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
26
|
-
spec.require_paths = [
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
26
|
+
spec.add_runtime_dependency "agile_utils", "~> 0.1"
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
29
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
30
|
+
spec.add_development_dependency "guard-rspec", "~> 4.2"
|
31
|
+
spec.add_development_dependency "awesome_print", "~> 1.2"
|
32
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
33
|
+
spec.add_development_dependency "fuubar", "~> 1.3"
|
34
|
+
spec.add_development_dependency "rubocop", "~> 0.20"
|
37
35
|
end
|
data/lib/code_lister.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
5
|
-
require_relative
|
1
|
+
require_relative "code_lister/version"
|
2
|
+
require_relative "code_lister/logger"
|
3
|
+
require_relative "code_lister/code_lister"
|
4
|
+
require_relative "code_lister/cli"
|
5
|
+
require_relative "code_lister/main"
|
data/lib/code_lister/cli.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "thor"
|
2
|
+
require "agile_utils"
|
3
3
|
module CodeLister
|
4
4
|
class CLI < Thor
|
5
|
-
|
5
|
+
# rubocop:disable AmbiguousOperator, LineLength
|
6
|
+
desc "find", "List files by extensions, patterns, and simple criteria"
|
6
7
|
method_option *AgileUtils::Options::BASE_DIR
|
7
8
|
method_option *AgileUtils::Options::EXTS
|
8
9
|
method_option *AgileUtils::Options::NON_EXTS
|
@@ -22,11 +23,11 @@ module CodeLister
|
|
22
23
|
|
23
24
|
# Note: we don't use help so that we can run :r !./bin/code_lister help find
|
24
25
|
# to see the update help if we have to without commenting out
|
25
|
-
desc
|
26
|
+
desc "usage", "Display help screen"
|
26
27
|
def usage
|
27
28
|
puts <<-EOS
|
28
29
|
Usage:
|
29
|
-
code_lister
|
30
|
+
code_lister
|
30
31
|
|
31
32
|
Options:
|
32
33
|
-b, [--base-dir=BASE_DIR] # Base directory
|
@@ -44,6 +45,7 @@ Options:
|
|
44
45
|
List files by extensions, patterns, and simple criteria
|
45
46
|
EOS
|
46
47
|
end
|
48
|
+
# rubocop:enable AmbiguousOperator, LineLength
|
47
49
|
|
48
50
|
default_task :usage
|
49
51
|
end
|
@@ -15,15 +15,15 @@ module CodeLister
|
|
15
15
|
# base_dir = opts[:base_dir]
|
16
16
|
fail CustomError, "The directory #{base_dir} is not valid or or not readable!" unless File.exist?(base_dir)
|
17
17
|
|
18
|
-
wildcard = opts[:recursive] ?
|
18
|
+
wildcard = opts[:recursive] ? "**" : ""
|
19
19
|
exts = opts[:exts]
|
20
20
|
non_exts = opts[:non_exts]
|
21
21
|
|
22
|
-
files_with_extension = Dir.glob(File.join(base_dir, wildcard, "*.{#{exts.join(
|
22
|
+
files_with_extension = Dir.glob(File.join(base_dir, wildcard, "*.{#{exts.join(",")}}"))
|
23
23
|
files_without_extension = no_extension_files(base_dir, wildcard, non_exts)
|
24
24
|
# remove the 'base_dir' with .
|
25
|
-
files_with_extension.each { |f| f.gsub!(base_dir,
|
26
|
-
files_without_extension.each { |f| f.gsub!(base_dir,
|
25
|
+
files_with_extension.each { |f| f.gsub!(base_dir, ".") }
|
26
|
+
files_without_extension.each { |f| f.gsub!(base_dir, ".") }
|
27
27
|
# combine the result
|
28
28
|
(files_with_extension + files_without_extension).sort
|
29
29
|
end
|
@@ -42,7 +42,7 @@ module CodeLister
|
|
42
42
|
file_list
|
43
43
|
end
|
44
44
|
|
45
|
-
|
45
|
+
private
|
46
46
|
|
47
47
|
# List files that do not have the extension
|
48
48
|
#
|
@@ -50,7 +50,7 @@ module CodeLister
|
|
50
50
|
def no_extension_files(base_dir, wildcard, non_exts = [])
|
51
51
|
list = []
|
52
52
|
unless non_exts.empty?
|
53
|
-
list = Dir.glob(File.join(base_dir, wildcard, "{#{non_exts.join(
|
53
|
+
list = Dir.glob(File.join(base_dir, wildcard, "{#{non_exts.join(",")}}"))
|
54
54
|
end
|
55
55
|
list
|
56
56
|
end
|
data/lib/code_lister/logger.rb
CHANGED
data/lib/code_lister/main.rb
CHANGED
@@ -16,16 +16,16 @@ module CodeLister
|
|
16
16
|
files
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
private
|
20
20
|
|
21
21
|
def default_options
|
22
|
-
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
{base_dir: Dir.pwd,
|
23
|
+
recursive: true,
|
24
|
+
ignore_case: true,
|
25
|
+
inc_words: [],
|
26
|
+
exc_words: [],
|
27
|
+
exts: [],
|
28
|
+
non_exts: []}
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/code_lister/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_lister
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-05-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -161,7 +161,7 @@ extra_rdoc_files: []
|
|
161
161
|
files:
|
162
162
|
- ".gitignore"
|
163
163
|
- ".rubocop.yml"
|
164
|
-
-
|
164
|
+
- CHANGELOG.md
|
165
165
|
- Gemfile
|
166
166
|
- LICENSE
|
167
167
|
- README.md
|
@@ -174,7 +174,6 @@ files:
|
|
174
174
|
- lib/code_lister/logger.rb
|
175
175
|
- lib/code_lister/main.rb
|
176
176
|
- lib/code_lister/version.rb
|
177
|
-
- rubocop-todo.yml
|
178
177
|
homepage: https://github.com/agilecreativity/code_lister
|
179
178
|
licenses:
|
180
179
|
- MIT
|
data/rubocop-todo.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2014-05-12 22:42:32 +1000 using RuboCop version 0.21.0.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 8
|
9
|
-
AmbiguousOperator:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
# Offense count: 5
|
13
|
-
Documentation:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
# Offense count: 22
|
17
|
-
LineLength:
|
18
|
-
Max: 123
|
19
|
-
|
20
|
-
# Offense count: 2
|
21
|
-
# Configuration parameters: CountComments.
|
22
|
-
MethodLength:
|
23
|
-
Max: 16
|