fake_io 0.1.0

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: 6add78cb6f8768583e80b667c3fa13dd562e55c4b7f58cc965d00fbaf3f71a69
4
+ data.tar.gz: bfe25da6a390b407310968ed8d15bf1b5c49adce541d9cd23e55c831541b7003
5
+ SHA512:
6
+ metadata.gz: 83e0b3c7b142bdfc9ce89e8721d02bbd0b0192d574b571cb75543383dba67050e908b52643e2c6e69f176bf98732dcb7d60d8397ae4205b47258603eaa9ca818
7
+ data.tar.gz: '009aabe37420f4f234e93eb69f784be7a5616ce874e6a6cf2d7f55cb2d943fe1ce2aa4994fa52c3ab348adc021d2c89758c4338297087ee7ab0495b59a0a1054'
data/.document ADDED
@@ -0,0 +1,3 @@
1
+ -
2
+ ChangeLog.*
3
+ LICENSE.txt
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on: [ push, pull_request ]
4
+
5
+ jobs:
6
+ tests:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby:
12
+ - 2.6
13
+ - 2.7
14
+ - '3.0'
15
+ - 3.1
16
+ - jruby
17
+ - truffleruby
18
+ name: Ruby ${{ matrix.ruby }}
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ - name: Install dependencies
26
+ run: bundle install --jobs 4 --retry 3
27
+ - name: Run tests
28
+ run: bundle exec rake test
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /Gemfile.lock
2
+ /coverage
3
+ /doc/
4
+ /pkg/
5
+ /vendor/bundle/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown --title "fake_io Documentation" --protected --quiet
data/ChangeLog.md ADDED
@@ -0,0 +1,8 @@
1
+ ### 0.1.0 / 2022-02-01
2
+
3
+ * Initial release:
4
+ * Require [Ruby] >= 2.0.0.
5
+ * Supports all of the Ruby 2.x and 3.x [IO] instance methods.
6
+
7
+ [Ruby]: https://www.ruby-lang.org/
8
+ [IO]: https://rubydoc.info/stdlib/core/IO
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'rubygems-tasks', '~> 0.2'
8
+
9
+ gem 'rspec', '~> 3.0'
10
+ gem 'simplecov', '~> 0.20'
11
+
12
+ gem 'kramdown'
13
+ gem 'redcarpet', platform: :mri
14
+ gem 'yard', '~> 0.9'
15
+ gem 'yard-spellcheck', require: false
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-2021 Hal Brodigan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # fake_io
2
+
3
+ [![CI](https://github.com/postmodern/fake_io.rb/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/fake_io.rb/actions/workflows/ruby.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/fake_io.svg)](https://badge.fury.io/rb/fake_io)
5
+
6
+ * [Source](https://github.com/postmodern/fake_io.rb)
7
+ * [Issues](https://github.com/postmodern/fake_io.rb/issues)
8
+ * [Documentation](https://rubydoc.info/gems/fake_io)
9
+
10
+ ## Description
11
+
12
+ {FakeIO} is a mixin module for creating fake [IO]-like classes.
13
+
14
+ ## Features
15
+
16
+ * Supports all of the Ruby 2.x and 3.x [IO] instance methods.
17
+ * Emulates buffered I/O.
18
+ * UTF-8 aware.
19
+ * Can be included into any Class.
20
+ * Zero dependencies.
21
+
22
+ ## Requirements
23
+
24
+ * [Ruby] >= 2.0.0
25
+
26
+ [Ruby]: https://www.ruby-lang.org/
27
+
28
+ ## Install
29
+
30
+ ```shell
31
+ $ gem install fake_io
32
+ ```
33
+
34
+ ### gemspec
35
+
36
+ ```ruby
37
+ gem.add_dependency 'fake_io', '~> 1.0'
38
+ ```
39
+
40
+ ### Gemfile
41
+
42
+ ```ruby
43
+ gem 'fake_io', '~> 1.0'
44
+ ```
45
+
46
+ ## Examples
47
+
48
+ ```ruby
49
+ require 'fake_io'
50
+
51
+ class FakeFile
52
+
53
+ include FakeIO
54
+
55
+ def initialize(chunks=[])
56
+ @index = 0
57
+ @chunks = chunks
58
+
59
+ io_initialize
60
+ end
61
+
62
+ protected
63
+
64
+ def io_read
65
+ unless (block = @chunks[@index])
66
+ raise(EOFError,"end of stream")
67
+ end
68
+
69
+ @index += 1
70
+ return block
71
+ end
72
+
73
+ def io_write(data)
74
+ @chunks[@index] = data
75
+ @index += 1
76
+
77
+ return data.length
78
+ end
79
+
80
+ end
81
+
82
+ file = FakeFile.new(["one\ntwo\n", "three\nfour", "\n"])
83
+ file.readlines
84
+ # => ["one\n", "two\n", "three\n", "four\n"]
85
+ ```
86
+
87
+ ## Copyright
88
+
89
+ Copyright (c) 2021 Hal Brodigan
90
+
91
+ See {file:LICENSE.txt} for details.
92
+
93
+ [IO]: https://rubydoc.info/stdlib/core/IO
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+
3
+ require 'rubygems/tasks'
4
+ Gem::Tasks.new
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new
8
+ task :test => :spec
9
+ task :default => :spec
10
+
11
+ require 'yard'
12
+ YARD::Rake::YardocTask.new
13
+ task :doc => :yard
data/fake_io.gemspec ADDED
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'fake_io/version'
14
+ FakeIO::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
24
+
25
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
26
+
27
+ gem.files = `git ls-files`.split($/)
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
29
+
30
+ gem.executables = gemspec.fetch('executables') do
31
+ glob['bin/*'].map { |path| File.basename(path) }
32
+ end
33
+ gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
34
+
35
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
36
+ gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
37
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
38
+
39
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
40
+ %w[ext lib].select { |dir| File.directory?(dir) }
41
+ })
42
+
43
+ gem.requirements = gemspec['requirements']
44
+ gem.required_ruby_version = gemspec['required_ruby_version']
45
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
46
+ gem.post_install_message = gemspec['post_install_message']
47
+
48
+ split = lambda { |string| string.split(/,\s*/) }
49
+
50
+ if gemspec['dependencies']
51
+ gemspec['dependencies'].each do |name,versions|
52
+ gem.add_dependency(name,split[versions])
53
+ end
54
+ end
55
+
56
+ if gemspec['development_dependencies']
57
+ gemspec['development_dependencies'].each do |name,versions|
58
+ gem.add_development_dependency(name,split[versions])
59
+ end
60
+ end
61
+ end
data/gemspec.yml ADDED
@@ -0,0 +1,20 @@
1
+ name: fake_io
2
+ summary: Fake IO module
3
+ description: A mixin module for creating fake IO-like classes.
4
+ license: MIT
5
+ authors: Postmodern
6
+ email: postmodern.mod3@gmail.com
7
+ homepage: https://github.com/postmodern/fake_io.rb#readme
8
+ has_yard: true
9
+
10
+ metadata:
11
+ documentation_uri: https://rubydoc.info/gems/fake_io
12
+ source_code_uri: https://github.com/postmodern/fake_io.rb
13
+ bug_tracker_uri: https://github.com/postmodern/fake_io.rb/issues
14
+ changelog_uri: https://github.com/postmodern/fake_io.rb/blob/master/ChangeLog.md
15
+ rubygems_mfa_required: 'true'
16
+
17
+ required_ruby_version: ">= 2.0.0"
18
+
19
+ development_dependencies:
20
+ bundler: ~> 2.0
@@ -0,0 +1,4 @@
1
+ module FakeIO
2
+ # fake_io version
3
+ VERSION = '0.1.0'
4
+ end