posix-short 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ee59548add3369f5cdb5f351f849578361cda93
4
+ data.tar.gz: 4c6cc121c9bd4a0af720a9cd9844d444fd3f93d0
5
+ SHA512:
6
+ metadata.gz: 1ba806bd33ee10b14073598732df3c1b0696e7e1b4ded507675d7740e42e2ee643c8a8c3599117bdf303c911659966bf00fb2eee5d2308524292c5d58180c851
7
+ data.tar.gz: d3053799a766f09e213544c482103b621c0affa7b550a956138b012479465714b867ebfd1a4d4b4f69ee1d6deb9888d0fec8a0575a02599e354fed6b1f94816c
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in posix-process.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ posix-short (0.0.1)
5
+ posix-spawn (~> 0.3, >= 0.3.11)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (3.1.2)
11
+ columnize (~> 0.8)
12
+ debugger-linecache (~> 1.2)
13
+ columnize (0.8.9)
14
+ debugger-linecache (1.2.0)
15
+ diff-lcs (1.2.5)
16
+ posix-spawn (0.3.11)
17
+ rake (10.3.2)
18
+ rspec (3.4.0)
19
+ rspec-core (~> 3.4.0)
20
+ rspec-expectations (~> 3.4.0)
21
+ rspec-mocks (~> 3.4.0)
22
+ rspec-core (3.4.2)
23
+ rspec-support (~> 3.4.0)
24
+ rspec-expectations (3.4.0)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.4.0)
27
+ rspec-mocks (3.4.1)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.4.0)
30
+ rspec-support (3.4.1)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.5)
37
+ byebug (~> 3.1, >= 3.1.2)
38
+ posix-short!
39
+ rake (~> 10.1, >= 10.1.0)
40
+ rspec (= 3.4)
41
+
42
+ BUNDLED WITH
43
+ 1.15.4
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Oleksii Kuznietsov
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # posix-short
2
+
3
+ A better way of use of Posix-Spawn gem
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'posix-short'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install posix-short
18
+
19
+ ## Usage
20
+
21
+ require 'posix-short'
22
+
23
+ Posix.exec('echo', '"Hello!"')
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/lib/posix.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'posix/spawn'
2
+
3
+ module PosixShort
4
+
5
+ NO_COMMAND_FOUND_MSG = 'No %s tool found, please install it and retry.'
6
+ NO_COMMAND_FOUND_CODE = 127
7
+
8
+ # Usage:
9
+ # Posix.exec('commandlinetool', argument_name_1, argument_value_1, ...)
10
+ #
11
+ def self.exec(*arguments)
12
+ result = POSIX::Spawn::Child.new(*arguments)
13
+ if result.status.exitstatus == NO_COMMAND_FOUND_CODE
14
+ raise(NO_COMMAND_FOUND_MSG % arguments.first)
15
+ end
16
+
17
+ error_text = result.err
18
+ return result.out if error_text.empty?
19
+
20
+ block_given? ? yield(result) : raise(error_text)
21
+ end
22
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module PosixShort
2
+ VERSION = '0.0.1'.freeze
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require_relative 'lib/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'posix-short'
8
+ spec.version = PosixShort::VERSION
9
+ spec.authors = ['Oleksii Kuznietsov']
10
+ spec.email = ['mail@nattfodd.com']
11
+ spec.summary = 'A simpler way to use POSIX gem to run processes'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'posix-spawn', '~> 0.3', '>= 0.3.11'
20
+ spec.add_development_dependency 'bundler', '~> 1.5'
21
+ spec.add_development_dependency 'rake', '~> 10.1', '>= 10.1.0'
22
+ spec.add_development_dependency 'rspec', '3.4'
23
+ spec.add_development_dependency 'byebug', '~> 3.1', '>= 3.1.2'
24
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe PosixShort do
4
+ describe '#exec' do
5
+ it 'executes provided command and returns output' do
6
+ expect(PosixShort.exec('echo', 'Hello')).to eq("Hello\n")
7
+ end
8
+
9
+ it 'raises error when command line tool is not installed' do
10
+ stub_const('POSIX::Spawn::Child',
11
+ double(:new => double('status' => double('exitstatus' => 127))))
12
+ expect { PosixShort.exec('sometool', 'some arguments') }.
13
+ to raise_error('No sometool tool found, please install it and retry.')
14
+ end
15
+ end
16
+ end
@@ -0,0 +1 @@
1
+ require 'posix-short'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: posix-short
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Oleksii Kuznietsov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: posix-spawn
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.11
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.3'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.3.11
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.5'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.5'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.1'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 10.1.0
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '10.1'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 10.1.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - '='
72
+ - !ruby/object:Gem::Version
73
+ version: '3.4'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - '='
79
+ - !ruby/object:Gem::Version
80
+ version: '3.4'
81
+ - !ruby/object:Gem::Dependency
82
+ name: byebug
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '3.1'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 3.1.2
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '3.1'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 3.1.2
101
+ description:
102
+ email:
103
+ - mail@nattfodd.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - lib/posix.rb
114
+ - lib/version.rb
115
+ - posix-short.gemspec
116
+ - spec/lib/posix_process_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage:
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.13
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A simpler way to use POSIX gem to run processes
142
+ test_files:
143
+ - spec/lib/posix_process_spec.rb
144
+ - spec/spec_helper.rb