subspawn-common 0.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: eec59a77e567019d25a554da4dc658e8fd93e060e81411bd7e901ceeddda03c5
4
+ data.tar.gz: ca6bbcf14e8f3f1a758b11559ad471aac802018a06b146363b6bbcdc2eb82dd0
5
+ SHA512:
6
+ metadata.gz: b1c403bee048073ab29f1e57906fe7afb44d9b8cd394040afe2a9f907764b9823b7d55fa95ee8c5d72aaab0d4e4da819c7c99304c3ddf32cc6a7efd981acd0ee
7
+ data.tar.gz: 3de8722ece184a22aa52673d913402adc84e6386f29be0d90d07d7690c712218525483e1ba045ce863d3f7f3d1bf0d48742c49fd98f5663417ed0e64b6ab566f
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in process-wrapper-mid.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # SubSpawn Common Library
2
+
3
+ SubSpawn common utilities for all API levels.
4
+
5
+ ## Installation
6
+
7
+ Install one the other SubSpawn gems directly instead.
8
+
9
+ ## Usage
10
+
11
+ Use one of the other SubSpawn API's directly
12
+
13
+ ## Development
14
+
15
+ See parent SubSpawn readme
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :build
@@ -0,0 +1,139 @@
1
+ require 'subspawn/common/version'
2
+
3
+ module SubSpawn::Common
4
+
5
+ # combines two Unidirectional IO's into one "single" bidirectional IO
6
+ class BidiMergedIO # < IO
7
+ def initialize(read, write)
8
+ @read, @write = read, write
9
+ end
10
+
11
+ READS = %i{
12
+ autoclose?
13
+ binmode?
14
+ bytes
15
+ chars
16
+ close_read
17
+ codepoints
18
+ each
19
+ each_byte
20
+ each_char
21
+ each_codepoint
22
+ each_line
23
+ eof?
24
+ eof
25
+ external_encoding
26
+ fdatasync
27
+ getbyte
28
+ getc
29
+ gets
30
+ internal_encoding
31
+ lineno
32
+ lines
33
+ pos
34
+ pread
35
+ read
36
+ read_nonblock
37
+ readbyte
38
+ readchar
39
+ readline
40
+ readpartial
41
+ rewind
42
+ seek
43
+ stat
44
+ sysread
45
+ sync
46
+
47
+ autoclose=
48
+ binmode=
49
+ close_on_exec=
50
+ close
51
+ flush
52
+ fsync
53
+ set_encoding
54
+ }
55
+ WRITES = %i{
56
+ <<
57
+ close_write
58
+ print
59
+ printf
60
+ putc
61
+ puts
62
+ pwrite
63
+ syswrite
64
+ write
65
+ write_nonblock
66
+ sync
67
+
68
+ autoclose=
69
+ binmode=
70
+ close_on_exec=
71
+ close
72
+ flush
73
+ fsync
74
+ set_encoding
75
+ }
76
+
77
+ (READS + WRITES).uniq.each do |meth|
78
+ if READS.include? meth
79
+ if WRITES.include? meth # both
80
+ define_method(meth) do |*args|
81
+ @read.send(meth, *args)
82
+ @write.send(meth, *args)
83
+ end
84
+ else # read only
85
+ define_method(meth) do |*args|
86
+ @read.send(meth, *args)
87
+ end
88
+ end
89
+ else # write only
90
+ define_method(meth) do |*args|
91
+ @write.send(meth, *args)
92
+ end
93
+ end
94
+ end
95
+
96
+ def underlying_read_io
97
+ @read
98
+ end
99
+ def underlying_write_io
100
+ @write
101
+ end
102
+
103
+ def to_io
104
+ self
105
+ end
106
+
107
+ def closed?
108
+ @read.closed? && @write.closed?
109
+ end
110
+ end
111
+
112
+ class BidiMergedIOClosable
113
+ def self.new(read, write, &closer)
114
+ require 'engine-hacks'
115
+ EngineHacks.duplex_io(read, write).tap do |io|
116
+ class << io
117
+ alias :__original_close :close
118
+ end
119
+ underlying.send( :define_singleton_method, :close) do
120
+ __original_close
121
+ closer.call
122
+ end
123
+ end
124
+ end
125
+ end
126
+
127
+ class ClosableIO
128
+ def self.new(underlying, &closer)
129
+ class << underlying
130
+ alias :__original_close :close
131
+ end
132
+ underlying.send( :define_singleton_method, :close) do
133
+ __original_close
134
+ closer.call
135
+ end
136
+ underlying
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SubSpawn
4
+ module Common
5
+ VERSION = "0.2.0.pre1"
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'subspawn/common/version'
2
+ require 'subspawn/common/bidi-io'
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/subspawn/common/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "subspawn-common"
7
+ spec.version = SubSpawn::Common::VERSION
8
+ spec.authors = ["Patrick Plenefisch"]
9
+ spec.email = ["simonpatp@gmail.com"]
10
+
11
+ spec.summary = "SubSpawn Common for all API targets"
12
+ spec.description = "A SubSpawn subproject to provide classes common to all mid-level and high level APIs"
13
+ final_github = "https://github.com/byteit101/subspawn"
14
+ spec.homepage = final_github
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ #spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = final_github
21
+ spec.metadata["changelog_uri"] = final_github
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.require_paths = ["lib"]
31
+
32
+ # For more information and examples about making a new gem, check out our
33
+ # guide at: https://bundler.io/guides/creating_gem.html
34
+ spec.add_dependency "engine-hacks", "~> 0.2.0.pre1"
35
+
36
+ # You can use Ruby's license, or any of the JRuby tri-license options
37
+ spec.licenses = ["Ruby", "EPL-2.0", "LGPL-2.1-or-later"]
38
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: subspawn-common
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Plenefisch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: engine-hacks
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0.pre1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0.pre1
27
+ description: A SubSpawn subproject to provide classes common to all mid-level and
28
+ high level APIs
29
+ email:
30
+ - simonpatp@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".rspec"
36
+ - Gemfile
37
+ - README.md
38
+ - Rakefile
39
+ - lib/subspawn/common.rb
40
+ - lib/subspawn/common/bidi-io.rb
41
+ - lib/subspawn/common/version.rb
42
+ - subspawn-common.gemspec
43
+ homepage: https://github.com/byteit101/subspawn
44
+ licenses:
45
+ - Ruby
46
+ - EPL-2.0
47
+ - LGPL-2.1-or-later
48
+ metadata:
49
+ homepage_uri: https://github.com/byteit101/subspawn
50
+ source_code_uri: https://github.com/byteit101/subspawn
51
+ changelog_uri: https://github.com/byteit101/subspawn
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 2.6.0
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubygems_version: 3.5.3
68
+ signing_key:
69
+ specification_version: 4
70
+ summary: SubSpawn Common for all API targets
71
+ test_files: []