code_lister 0.1.2 → 0.1.3

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: 23c2c55f6c39b00ae60f077b1084bc9953b4f79a
4
- data.tar.gz: 381925655a9501099259f6faddad7d97644fb180
3
+ metadata.gz: 55f282cee442aa6ed419c2ddfa5e3c6fae07e5ef
4
+ data.tar.gz: ba33eec999eaba9de4ed0b2f32992ec1bc04b117
5
5
  SHA512:
6
- metadata.gz: 0a216909fc91b708f6f400553275b24a46ab757a62c73959b337fdcba1c06709d5c51475a1d30a12561b6f92da118aff9c3cec0fc98f398288f451769f0271c4
7
- data.tar.gz: c8c0b36b8c0331d7c2bf77b96306d2d803bf748e2dcb7df40a1d47f85dbf157f9d22c441fe69dfb2d442ab62bb015a86d0776526bc2144d6c6c134b0017411db
6
+ metadata.gz: be5d451e55374dc9f4d06fad15f0623d088b88de522e51f62defcd7f30c540580a9be7b189c0ba8dc1c1c4021f9af0cb6c3810d6e41b7105fe05921fe14f42db
7
+ data.tar.gz: f363a7ad16338af98bfc3681c7430fcd66f34ca927975807bdcf2d09d64be1dd696edf251435b7e8dcf6120fc6e39b5cd4b541af66cd59d1049828735f5d7563
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ### Changelogs
2
2
 
3
+ #### 0.1.3
4
+
5
+ - Add new internal api to get the input files from output of the shell command for advanced usage [New]
6
+
3
7
  #### 0.1.2
4
8
 
5
9
  - Improve documentation
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CodeLister
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
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.2
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-02 00:00:00.000000000 Z
11
+ date: 2014-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor