code_lister 0.1.2 → 0.1.3
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 +4 -0
- data/lib/code_lister/code_lister.rb +28 -0
- 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: 55f282cee442aa6ed419c2ddfa5e3c6fae07e5ef
|
4
|
+
data.tar.gz: ba33eec999eaba9de4ed0b2f32992ec1bc04b117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be5d451e55374dc9f4d06fad15f0623d088b88de522e51f62defcd7f30c540580a9be7b189c0ba8dc1c1c4021f9af0cb6c3810d6e41b7105fe05921fe14f42db
|
7
|
+
data.tar.gz: f363a7ad16338af98bfc3681c7430fcd66f34ca927975807bdcf2d09d64be1dd696edf251435b7e8dcf6120fc6e39b5cd4b541af66cd59d1049828735f5d7563
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,34 @@
|
|
1
1
|
module CodeLister
|
2
2
|
CustomError = Class.new(StandardError)
|
3
3
|
class << self
|
4
|
+
# Execute the command in the shell and extract the output to be used
|
5
|
+
# e.g. `git diff --name-only HEAD~1` is getting the list of files that have been
|
6
|
+
# updated in the last commit
|
7
|
+
#
|
8
|
+
# @param [String] command the input command to be executed in the shell
|
9
|
+
# @param [String] base_dir the starting directory
|
10
|
+
# @return [Array<String>] file list or empty list if the shell command is not valid
|
11
|
+
def files_from_command(command, base_dir)
|
12
|
+
files = AgileUtils::Helper.shell(command.split(" ")).split(/\n/)
|
13
|
+
# Adapt the result and make sure that it starts with "./"
|
14
|
+
# like the result from 'CodeLister.files()' method
|
15
|
+
files.map! do |file|
|
16
|
+
if file =~ /^\.\//
|
17
|
+
# skip if the file start with './' string
|
18
|
+
file
|
19
|
+
else
|
20
|
+
# add './' to the one that does not already have one
|
21
|
+
"./#{file}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
# Note: this make sure that it works with deleted file when use
|
25
|
+
# this with something like 'git diff --name-only HEAD~2'
|
26
|
+
files.delete_if { |file| !File.exist?(file.gsub(/^\./, base_dir)) }
|
27
|
+
rescue RuntimeError => e
|
28
|
+
# just return the empty list, if the user specified invalid command
|
29
|
+
return []
|
30
|
+
end
|
31
|
+
|
4
32
|
# List files base on multiple simple criteria
|
5
33
|
#
|
6
34
|
# @param [Hash<Symbol>,<Object>] args argument hash
|
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.3
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|