code_lister 0.1.5 → 0.1.6
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/CHANGELOG.md +6 -0
- data/code_lister.gemspec +1 -1
- data/lib/code_lister/code_lister.rb +20 -27
- data/lib/code_lister/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfde1ca13e9439d3c3a32f17e99162355cb98dee
|
4
|
+
data.tar.gz: 105d46aaeb7abb5bfd55d3c1b539474fe3614037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 745702c17b9c5c68649907f280fc33e0955365382d5b760454c475a8fdce17e12881c7c0952f5b3110aa6a8574a4cb0739580e5c8ea2c74a9eb4235e73e8a37f
|
7
|
+
data.tar.gz: d3c35b8ba4bc9209726bb169409dc193f1df13e63f219475e430190b3662a7762b159eb4ef3b4a10c822e8c93e09b65ee32c7e2d5dba3317677740a906954080
|
data/CHANGELOG.md
CHANGED
data/code_lister.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
spec.add_runtime_dependency "thor", "~> 0.19"
|
26
|
-
spec.add_runtime_dependency "agile_utils", "~> 0.1"
|
26
|
+
spec.add_runtime_dependency "agile_utils", "~> 0.1.4"
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.6"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.3"
|
29
29
|
spec.add_development_dependency "rspec", "~> 2.14"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'agile_utils'
|
1
2
|
module CodeLister
|
2
3
|
CustomError = Class.new(StandardError)
|
3
4
|
class << self
|
@@ -10,30 +11,17 @@ module CodeLister
|
|
10
11
|
# 'find ~/Desktop/pdfkit -type f -iname "*.rb" | grep -v spec'
|
11
12
|
#
|
12
13
|
# @param [String] command the input command to be executed in the shell
|
13
|
-
# @param [String] base_dir the starting directory
|
14
14
|
# @return [Array<String>] file list or empty list if the shell command is not valid
|
15
|
-
def files_from_command(command
|
15
|
+
def files_from_command(command)
|
16
16
|
files = AgileUtils::Helper.shell(command.split(" ")).split(/\n/)
|
17
|
-
|
18
|
-
#
|
19
|
-
files.map! do |file|
|
20
|
-
if base_dir
|
21
|
-
if file =~ /^\./
|
22
|
-
File.expand_path(file).gsub(File.expand_path(base_dir), ".")
|
23
|
-
else
|
24
|
-
File.expand_path(file).gsub(File.expand_path(base_dir), ".")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
17
|
+
files.map! { |file| File.expand_path(file) }
|
18
|
+
# Some command result in the deleted files (e.g. git diff --name-only HEAD~n)
|
28
19
|
files.delete_if do |file|
|
29
|
-
!File.exist?(
|
30
|
-
File.expand_path(base_dir),
|
31
|
-
file.gsub(/^\./, "")
|
32
|
-
].join(""))
|
20
|
+
!File.exist?(file)
|
33
21
|
end
|
34
22
|
files
|
35
23
|
rescue RuntimeError => e
|
36
|
-
#
|
24
|
+
# return empty list for invalid command
|
37
25
|
return []
|
38
26
|
end
|
39
27
|
|
@@ -63,11 +51,9 @@ module CodeLister
|
|
63
51
|
|
64
52
|
files_with_extension = Dir.glob(File.join(base_dir, wildcard, "*.{#{exts.join(",")}}"))
|
65
53
|
files_without_extension = no_extension_files(base_dir, wildcard, non_exts)
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
# combine the result
|
70
|
-
(files_with_extension + files_without_extension).sort
|
54
|
+
# Replace prefix directory with just "."
|
55
|
+
files = (files_with_extension + files_without_extension)
|
56
|
+
files.map! { |file| file.gsub(base_dir, ".") }.sort
|
71
57
|
end
|
72
58
|
|
73
59
|
# Filter out the list based on simple criteria
|
@@ -84,13 +70,22 @@ module CodeLister
|
|
84
70
|
exc_words: [],
|
85
71
|
ignore_case: true
|
86
72
|
}.merge(args)
|
87
|
-
|
88
73
|
take_any!(file_list, opts)
|
89
74
|
drop_any!(file_list, opts)
|
90
|
-
|
91
75
|
file_list
|
92
76
|
end
|
93
77
|
|
78
|
+
# Remove each prefix string from a given list of string
|
79
|
+
#
|
80
|
+
# @param [Array<String>] files list of file path/name
|
81
|
+
# @param [String] base_dir
|
82
|
+
# @return [Array<String>] list of files with the prefix replaced by "."
|
83
|
+
def remove_prefix(files, prefix)
|
84
|
+
prefix = File.expand_path(prefix) if prefix
|
85
|
+
files.map! { |file| prefix ? file.gsub(prefix, ".") : file }
|
86
|
+
files
|
87
|
+
end
|
88
|
+
|
94
89
|
private
|
95
90
|
|
96
91
|
# List files that do not have the extension
|
@@ -107,13 +102,11 @@ module CodeLister
|
|
107
102
|
def take_any!(file_list, args = {})
|
108
103
|
words = args[:inc_words]
|
109
104
|
ignore_case = args[:ignore_case]
|
110
|
-
|
111
105
|
unless words.empty?
|
112
106
|
file_list.select! do |file|
|
113
107
|
matched_any?(words, file, ignore_case)
|
114
108
|
end
|
115
109
|
end
|
116
|
-
|
117
110
|
file_list
|
118
111
|
end
|
119
112
|
|
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.6
|
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-06-
|
11
|
+
date: 2014-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|