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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55f282cee442aa6ed419c2ddfa5e3c6fae07e5ef
4
- data.tar.gz: ba33eec999eaba9de4ed0b2f32992ec1bc04b117
3
+ metadata.gz: a84281fb10f66a88c340e7f579e4bb431ce9f535
4
+ data.tar.gz: 35aa9619078c07d07ccbbd47fe29b16fb2f360c1
5
5
  SHA512:
6
- metadata.gz: be5d451e55374dc9f4d06fad15f0623d088b88de522e51f62defcd7f30c540580a9be7b189c0ba8dc1c1c4021f9af0cb6c3810d6e41b7105fe05921fe14f42db
7
- data.tar.gz: f363a7ad16338af98bfc3681c7430fcd66f34ca927975807bdcf2d09d64be1dd696edf251435b7e8dcf6120fc6e39b5cd4b541af66cd59d1049828735f5d7563
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
- # e.g. `git diff --name-only HEAD~1` is getting the list of files that have been
6
- # updated in the last commit
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 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}"
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
- # 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)) }
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 []
@@ -1,3 +1,3 @@
1
1
  module CodeLister
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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.3
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-14 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor