indented_io 0.8.1 → 0.8.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c36c671ed19295dbc8816818028ce7d561f572c8aacc340c5d84236ce19a1e1e
4
- data.tar.gz: 87b38c79f9ccce609c0a165438f62b2dd5194e1cb00df4b98623856f134019a1
3
+ metadata.gz: cfc1de7e7ffda4d1fa37cd2979367b91b105cc43bc83a18d67816d14c3abd334
4
+ data.tar.gz: b54b5d64a8af0ca25cb333a2aa94599fba21be53063bd8fe1953d48bb8e4e3c1
5
5
  SHA512:
6
- metadata.gz: b04768c215fa7fd6baf00c6f99915dd43bcaa36db6bb3f8c140f0d43f2cd8b721c246f6cdb1e380e0f8bf718dbcc26961dff665a1163a1eccf5a0395113b9178
7
- data.tar.gz: 8d689f7775d01772ece81d43cc8100d8e7e484c406e61ac84a84b0204a4708cd7436477d8af12c1c3ed3a28b8acfb6938ec24df3f7b9c8b41e9628a6ebe7396b
6
+ metadata.gz: 84b4b34e808dd75d2fbf8d6c2e581448352d0c4d1c0f4bcf363b43e4b3b550a7619d80418fde9a5e8968e97b8c973b73ec9bb391b25c7967454061c9b39e824a
7
+ data.tar.gz: f9041fd50c2f791c95b896e34b61b22050d792c938e83af9b89d48c81fb3e49b56d60b012d32c7cbdbc70a4e43d6e50ad651b7a12e13777da7178ab59cd01895
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.5.0
1
+ ruby-2.7.1
data/README.md CHANGED
@@ -149,7 +149,7 @@ the class define a `#write` method with the same semantics as `IO#write`
149
149
  require 'indented_io'
150
150
  class MyIO
151
151
  include IndentedIO::IndentedIOInterface
152
- def writte(*args) ... end
152
+ def write(*args) ... end
153
153
  end
154
154
 
155
155
  my_io = MyIO.new
data/TODO CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
2
  TODO
3
+ o Find a solution for the inclusion of StringIO and Tempfile (the last is
4
+ required by ruby 2.7 - see also note in lib/indented_io/tempfile.rb
3
5
  o Check if IO object is writable - no good solution ?
4
6
  o better name for @this_indent ? 'string' ?
5
7
  o Reimplement core loop in C
data/indented_io.gemspec CHANGED
@@ -37,6 +37,6 @@ Gem::Specification.new do |spec|
37
37
  spec.require_paths = ["lib"]
38
38
 
39
39
  spec.add_development_dependency "bundler", "~> 1.16"
40
- spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rake", ">= 12.3.3"
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
42
  end
data/lib/indented_io.rb CHANGED
@@ -6,6 +6,7 @@ require 'indented_io/indented_io_interface'
6
6
  require 'indented_io/kernel'
7
7
  require 'indented_io/io'
8
8
  require 'indented_io/stringio'
9
+ require 'indented_io/tempfile'
9
10
 
10
11
  # IndentedIO module. See {IndentedIO::IndentedIO} for documentation on how to
11
12
  # use this module
@@ -53,8 +53,8 @@ module IndentedIO
53
53
  end
54
54
 
55
55
  # Indent and print args to the underlying device. #p has the same semantic
56
- # as Kernel#p. Please note that #p is usually not defined on other classes
57
- # than Kernel but can be used on any IndentedIO object
56
+ # as Kernel#p. Please note that #p is only defined on Kernel in the Ruby core
57
+ # library but can be used on any IndentedIO object
58
58
  def p(*args)
59
59
  if bol
60
60
  args.each { |arg| write(arg.inspect, "\n") }
@@ -68,8 +68,8 @@ module IndentedIO
68
68
 
69
69
  # Make IndentedIO behave like the underlying @device
70
70
  # @!visibility private
71
- def respond_to?(method)
72
- [:indent, :level, :print, :puts, :p].include?(method) || device.respond_to?(method)
71
+ def respond_to?(method, include_all = false)
72
+ [:indent, :level, :print, :printf, :puts, :p].include?(method) || device.respond_to?(method)
73
73
  end
74
74
 
75
75
  # Make IndentedIO behave like the underlying @device
@@ -85,8 +85,8 @@ module IndentedIO
85
85
  attr_reader :device
86
86
 
87
87
  # First IndentedIO object on the stack. Equal to self if self is the first
88
- # indentation object. #base is used to keep track of #bol for the whole
89
- # stack of IndentedIO objects
88
+ # indentation object. The #base object is used to keep track of #bol for
89
+ # the whole stack of IndentedIO objects
90
90
  attr_reader :base
91
91
 
92
92
  # Parent IndentedIO or IO object
@@ -4,6 +4,7 @@ module IndentedIO
4
4
  # #write method like this:
5
5
  #
6
6
  # require 'indented_io'
7
+ #
7
8
  # class MyIO
8
9
  # include IndentedIO::IndentedIOInterface
9
10
  # def write(*args) ... end
@@ -18,7 +19,7 @@ module IndentedIO
18
19
  #
19
20
  module IndentedIOInterface
20
21
  # Returns a IndentedIO object that can be used for printing. The IO object
21
- # will pass-through all method to the underlying device except #print,
22
+ # will pass-through all methods to the underlying device except #print,
22
23
  # #printf, #puts, and #p
23
24
  #
24
25
  # +level+ is the number of leves to indent and +string+ is the string used
@@ -3,7 +3,7 @@ require 'indented_io/indented_io_interface'
3
3
  module Kernel
4
4
  # Like {IndentedIO::IndentedIOInterface#indent} except the underlying device is
5
5
  # not the receiver (Kernel) but $stdout. Kernel#indent also allows a block without
6
- # and argument. In that case it manipulates $stdout to print indented:
6
+ # an argument. In that case it manipulates $stdout to print indented:
7
7
  #
8
8
  # puts "Not indented
9
9
  # indent do
@@ -1,3 +1,4 @@
1
+ require 'stringio' # Requiered to avoid 'superclass mismatch' errors in other modules
1
2
  require 'indented_io/indented_io_interface'
2
3
 
3
4
  # Includes the IndentedIOInterface that define the #indent method
@@ -0,0 +1,14 @@
1
+ require 'indented_io/indented_io_interface'
2
+
3
+ require "tempfile"
4
+
5
+ # Includes the IndentedIOInterface that define the #indent method
6
+ #
7
+ # Note that Tempfile used to be a (kind of) IO but that changed in ruby-2.7.
8
+ # The problem is that we now have to require both StringIO and Tempfile and
9
+ # possible other classes to inject the #indent method instead of just doing it
10
+ # once in the IO class itself. TODO: Find a better solution - probably by
11
+ # implementing a check in Kernel
12
+ class Tempfile
13
+ include IndentedIO::IndentedIOInterface
14
+ end
@@ -1,4 +1,4 @@
1
1
  module IndentedIO
2
2
  # Version number
3
- VERSION = '0.8.1'
3
+ VERSION = '0.8.6'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indented_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -82,6 +82,7 @@ files:
82
82
  - lib/indented_io/io.rb
83
83
  - lib/indented_io/kernel.rb
84
84
  - lib/indented_io/stringio.rb
85
+ - lib/indented_io/tempfile.rb
85
86
  - lib/indented_io/version.rb
86
87
  - scripts/perf.rb
87
88
  homepage: https://github.com/clrgit/indented_io
@@ -104,8 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.7.3
108
+ rubygems_version: 3.1.4
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Print indented text