run-command 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a98764c775cf0417c45f4d2b652263d792aefc30624759f7cccef5d114d43490
4
+ data.tar.gz: 07ea9656757fb971759ce719df8229820956ca691030353e1bd8ff031cb9347d
5
+ SHA512:
6
+ metadata.gz: 959caa28c1446bae0a6b909f93a3dedeb481c11de97c43329f9f9eb2dd93740fa3ac3f8faf5e7e9a9ff91aa13dcc0dd493ee475d3f007690a261ad864d8d0f5c
7
+ data.tar.gz: 47633e6c3484daf8ebdb0318bc1367c9dce62ee1a0f694603c2e9d0366c424a6176469d36cfb16900f2e63153c1871e932aad9267e88e80760cf34a091511d88
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ *.gem
@@ -0,0 +1 @@
1
+ FIXME
@@ -0,0 +1,3 @@
1
+ require 'rubygems/tasks'
2
+
3
+ Gem::Tasks.new
@@ -0,0 +1,45 @@
1
+ require 'shellwords'
2
+
3
+ class RunCommand
4
+
5
+ class Error < Exception; end
6
+
7
+ def self.run_command(command, *args)
8
+ new.run_command(command, *args)
9
+ end
10
+
11
+ def run_command(command, *args)
12
+ command = command.to_s
13
+ options = args.last.kind_of?(Hash) ? args.pop.dup : {}
14
+ options[:exception] = true
15
+ args = args.flatten.compact.map(&:to_s)
16
+ env = options.delete(:env) || {}
17
+ verbose = options.delete(:verbose) || false
18
+ pretend = options.delete(:pretend) || false
19
+ argv0 = options.delete(:argv0)
20
+ if verbose
21
+ warn "$ %s%s" % [
22
+ env.empty? ? nil : env.map { |kv| kv.join('=') }.join(' ') + ' ',
23
+ [command, *args].shelljoin,
24
+ ]
25
+ end
26
+ unless pretend
27
+ data = ''
28
+ IO.popen(env, [argv0 ? [command, argv0] : command, *args], 'r', options) do |io|
29
+ data += io.read
30
+ end
31
+ data
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ if $0 == __FILE__
38
+
39
+ RunCommand.run_command('echo', %w{a b}, verbose: true)
40
+ RunCommand.run_command('echo', %w{a b}, verbose: true, env: { 'FOO' => 'bar' })
41
+ RunCommand.run_command('echo', %w{a b}, verbose: true, env: { 'FOO' => 'bar' }, argv0: 'DATE')
42
+ RunCommand.run_command('echo', %w{a b}, verbose: true, pretend: true)
43
+ RunCommand.run_command('echo', ['a', 'b', [1, :foo]], verbose: true)
44
+
45
+ end
@@ -0,0 +1,5 @@
1
+ class RunCommand
2
+
3
+ VERSION = '0.1'
4
+
5
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'lib/run-command/version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'run-command'
5
+ s.version = RunCommand::VERSION
6
+ s.summary = 'A friendlier system().'
7
+ s.author = 'John Labovitz'
8
+ s.email = 'johnl@johnlabovitz.com'
9
+ s.description = %q{
10
+ RunCommand provides a friendlier system().
11
+ }
12
+ s.license = 'MIT'
13
+ s.homepage = 'http://github.com/jslabovitz/run-command'
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_path = 'lib'
18
+
19
+ s.add_development_dependency 'rake', '~> 12.3'
20
+ s.add_development_dependency 'rubygems-tasks', '~> 0.2'
21
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: run-command
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - John Labovitz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubygems-tasks
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ description: "\n RunCommand provides a friendlier system().\n "
42
+ email: johnl@johnlabovitz.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - README.md
49
+ - Rakefile
50
+ - lib/run-command.rb
51
+ - lib/run-command/version.rb
52
+ - run-command.gemspec
53
+ homepage: http://github.com/jslabovitz/run-command
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.2.3
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: A friendlier system().
76
+ test_files: []