script_utils 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/script_utils.rb +11 -1
- data/script_utils.gemspec +8 -8
- data/spec/script_utils/script_utils_spec.rb +21 -0
- data/spec/test_dir/dog/file2 +0 -0
- data/spec/test_dir/file +0 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6b47f24fe85a20396499477fa1663d2a8f1ac32
|
4
|
+
data.tar.gz: 7108e85348a4ff49bb16c466adbf5343582de3e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc3bb757348b5277e12f527592a336790deaacf934854b33c3236fcd0758cbb9d00ccedaf9cb27557eb6606851448778c542fa4ef06d465d13cfd9e2878a037
|
7
|
+
data.tar.gz: fea83bc70af99ed9d8f8583a20e388410a02ce1c43eb97e8b8470d5b79d3303791866b0dfd39f3bdbec5a47bda251b002e5d2a5de8f661a85fa06528ca1ab094
|
data/Gemfile.lock
CHANGED
data/lib/script_utils.rb
CHANGED
@@ -7,4 +7,14 @@ module ScriptUtils
|
|
7
7
|
output ? system(cmd) : `#{cmd}`
|
8
8
|
raise if ensure_success && !$?.success?
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
def files(dir)
|
12
|
+
dir = dir[0...-1] if dir.end_with?('/')
|
13
|
+
dir = "#{dir}/*"
|
14
|
+
Dir[dir].select { |f| File.file?(f) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def file_names(dir)
|
18
|
+
files(dir).map { |f| File.basename(f) }
|
19
|
+
end
|
20
|
+
end
|
data/script_utils.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
|
-
gem.name
|
3
|
-
gem.version
|
4
|
-
gem.summary
|
5
|
-
gem.author
|
6
|
-
gem.email
|
2
|
+
gem.name = 'script_utils'
|
3
|
+
gem.version = '0.0.3'
|
4
|
+
gem.summary = 'script helpers'
|
5
|
+
gem.author = 'Lihan Li'
|
6
|
+
gem.email = 'frankieteardrop@gmail.com'
|
7
7
|
gem.homepage = 'https://github.com/lihanli/script_utils'
|
8
8
|
|
9
9
|
gem.add_development_dependency('rspec', '3.2.0')
|
10
10
|
gem.add_development_dependency('pry')
|
11
11
|
|
12
|
-
gem.files
|
13
|
-
gem.test_files
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
end
|
15
|
+
end
|
@@ -1,6 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe ScriptUtils do
|
4
|
+
describe '#files' do
|
5
|
+
context 'without a trailing slash' do
|
6
|
+
it 'should list the files in a directory' do
|
7
|
+
expect(ScriptUtils.files("spec/test_dir")).to eq(["spec/test_dir/file"])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'with a trailing slash' do
|
12
|
+
it 'should list the files in a directory' do
|
13
|
+
expect(ScriptUtils.files("spec/test_dir/")).to eq(["spec/test_dir/file"])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#file_names' do
|
19
|
+
it 'should list the files names' do
|
20
|
+
expect(ScriptUtils.file_names('spec/test_dir')).to eq(['file'])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
4
24
|
describe '#run' do
|
5
25
|
def run(*args)
|
6
26
|
ScriptUtils.run(*args)
|
@@ -8,6 +28,7 @@ RSpec.describe ScriptUtils do
|
|
8
28
|
|
9
29
|
def expect_command(cmd, output: false)
|
10
30
|
expect(ScriptUtils).to receive(:"#{output ? 'system' : '`'}").once.with(cmd)
|
31
|
+
allow($?).to receive(:success?).and_return(true)
|
11
32
|
end
|
12
33
|
|
13
34
|
context 'when ensure_success is false' do
|
File without changes
|
data/spec/test_dir/file
ADDED
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lihan Li
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- script_utils.gemspec
|
52
52
|
- spec/script_utils/script_utils_spec.rb
|
53
53
|
- spec/spec_helper.rb
|
54
|
+
- spec/test_dir/dog/file2
|
55
|
+
- spec/test_dir/file
|
54
56
|
homepage: https://github.com/lihanli/script_utils
|
55
57
|
licenses: []
|
56
58
|
metadata: {}
|
@@ -77,3 +79,5 @@ summary: script helpers
|
|
77
79
|
test_files:
|
78
80
|
- spec/script_utils/script_utils_spec.rb
|
79
81
|
- spec/spec_helper.rb
|
82
|
+
- spec/test_dir/dog/file2
|
83
|
+
- spec/test_dir/file
|