code_lister 0.1.3 → 0.1.4
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 +5 -0
- data/lib/code_lister/code_lister.rb +20 -12
- data/lib/code_lister/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a84281fb10f66a88c340e7f579e4bb431ce9f535
|
4
|
+
data.tar.gz: 35aa9619078c07d07ccbbd47fe29b16fb2f360c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ce6deda9ba39722f9625f6780d5e9f1c0d4f93c77297a68d26f02b728947e88533f889f23961f8ecd30eab949afb224361c000145aae4037ef7f82d255da708
|
7
|
+
data.tar.gz: c998888606a774f9c8b771d7b7c6e55530c0fe97b5970212d5dd92a5e934bbd47838d69d887ca9533d0a88d4e934b0e78f690ebb9db7b25e7f6565a9cf7d70e7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
### Changelogs
|
2
2
|
|
3
|
+
#### 0.1.4
|
4
|
+
|
5
|
+
- Add more tests for 'files_from_command'
|
6
|
+
- Fix the path to 'Guardfile' to make it pick up the right test
|
7
|
+
|
3
8
|
#### 0.1.3
|
4
9
|
|
5
10
|
- Add new internal api to get the input files from output of the shell command for advanced usage [New]
|
@@ -2,28 +2,36 @@ module CodeLister
|
|
2
2
|
CustomError = Class.new(StandardError)
|
3
3
|
class << self
|
4
4
|
# Execute the command in the shell and extract the output to be used
|
5
|
-
#
|
6
|
-
#
|
5
|
+
#
|
6
|
+
# Example
|
7
|
+
#
|
8
|
+
# Use the file list from the 'find | grep' command
|
9
|
+
#
|
10
|
+
# 'find ~/Desktop/pdfkit -type f -iname "*.rb" | grep -v spec'
|
7
11
|
#
|
8
12
|
# @param [String] command the input command to be executed in the shell
|
9
13
|
# @param [String] base_dir the starting directory
|
10
14
|
# @return [Array<String>] file list or empty list if the shell command is not valid
|
11
|
-
def files_from_command(command, base_dir)
|
15
|
+
def files_from_command(command, base_dir = ".")
|
12
16
|
files = AgileUtils::Helper.shell(command.split(" ")).split(/\n/)
|
13
17
|
# Adapt the result and make sure that it starts with "./"
|
14
18
|
# like the result from 'CodeLister.files()' method
|
15
19
|
files.map! do |file|
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
22
26
|
end
|
23
27
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
files.delete_if do |file|
|
29
|
+
!File.exist?([
|
30
|
+
File.expand_path(base_dir),
|
31
|
+
file.gsub(/^\./, '')
|
32
|
+
].join(""))
|
33
|
+
end
|
34
|
+
files
|
27
35
|
rescue RuntimeError => e
|
28
36
|
# just return the empty list, if the user specified invalid command
|
29
37
|
return []
|
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.4
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|