psychgus 1.2.2 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a27bbbad046bb56766bbbf05da64314757237a44b3f941105b848e178391625
4
- data.tar.gz: 61b3437d298d84718a226be9ee5e904cd0f46bde245200f0b239bcd3e0a6ba83
3
+ metadata.gz: dfe0fe918cc179a21aa9a7c37e0172344ef80b9f5c07c31e127ba97c79a5e69f
4
+ data.tar.gz: e0b7107993830b4366c6d332756c1771af7fab396fdc77deb713db01fae0c4e7
5
5
  SHA512:
6
- metadata.gz: 2af6115edfa0e408141e709331d308b6de33c338d1febbd924bf7e2fdd138abf65f1463d129a59799e50bfa57b2e6b631ef811c06e7a60ee8a23506f4087d104
7
- data.tar.gz: 31056d1397820d97b490aee89acef035f29424ba78f05d0d9ab0520b6898b9255e5284367b7f9c02fc6d54c2506abfad625b262415d7dc992b46e879234bc405
6
+ metadata.gz: 17ace1a7d1a8e6ddea35de17efdad5ce5250b1a8fe5a1e4a16a7f97c5b6100b5fb39acafcdd5e85e65aa3b90fccca09b8a13e8d272156eae63d07c4f5c82305d
7
+ data.tar.gz: 4f6598c2bff80330603f087df0c83e629063457eff41c6bcdd3dc11450d6e53fbb548d493ba33c56cc9cd93bedaa57d7f539ec448c76124b64ad81098529d79a
data/CHANGELOG.md CHANGED
@@ -2,7 +2,18 @@
2
2
 
3
3
  Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [[Unreleased]](https://github.com/esotericpig/psychgus/compare/v1.2.2...master)
5
+ ## [[Unreleased]](https://github.com/esotericpig/psychgus/compare/v1.3.2...master)
6
+
7
+ ## [v1.3.2] - 2020-04-23
8
+
9
+ ### Changed
10
+ - SuperSniffer::Parent
11
+ - Changed to use Delegator to delegate all methods of `node`
12
+ - Psychgus.dump_file()/parse_file()
13
+ - Changed `opt` to expect a Hash
14
+
15
+ ### Fixed
16
+ - Fixed some Ruby 2.7 warnings in tests
6
17
 
7
18
  ## [v1.2.2] - 2020-03-15
8
19
 
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Psychgus
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/psychgus.svg)](https://badge.fury.io/rb/psychgus) ![ruby tests](https://github.com/esotericpig/psychgus/workflows/ruby%20tests/badge.svg)
3
+ [![Gem Version](https://badge.fury.io/rb/psychgus.svg)](https://badge.fury.io/rb/psychgus)
4
+ [![Build Status](https://travis-ci.org/esotericpig/psychgus.svg?branch=master)](https://travis-ci.org/esotericpig/psychgus)
5
+ [![Doc Coverage](http://inch-ci.org/github/esotericpig/psychgus.svg?branch=master)](https://inch-ci.org/github/esotericpig/psychgus)
4
6
 
5
7
  [![Documentation](https://img.shields.io/badge/doc-yard-%23A0522D.svg)](https://esotericpig.github.io/docs/psychgus/yardoc/index.html)
6
8
  [![Source Code](https://img.shields.io/badge/source-github-%23211F1F.svg)](https://github.com/esotericpig/psychgus)
@@ -47,7 +47,7 @@ module Psychgus
47
47
  # @see SuperSniffer#end_parent SuperSniffer#end_parent
48
48
  # @see Styler
49
49
  ###
50
- class Parent
50
+ class Parent < Delegator
51
51
  # Calling the getter is fine; calling the setter is *not* and could cause weird results.
52
52
  #
53
53
  # @return [Integer] the next child's position
@@ -80,47 +80,9 @@ module Psychgus
80
80
  @position = sniffer.position
81
81
  end
82
82
 
83
- # @see Psych::Nodes::Alias#anchor=
84
- # @see Psych::Nodes::Mapping#anchor=
85
- # @see Psych::Nodes::Scalar#anchor=
86
- # @see Psych::Nodes::Sequence#anchor=
87
- def anchor=(anchor)
88
- @node.anchor = anchor
89
- end
90
-
91
- # @see Psych::Nodes::Scalar#plain=
92
- def plain=(plain)
93
- @node.plain = plain
94
- end
95
-
96
- # @see Psych::Nodes::Scalar#quoted=
97
- def quoted=(quoted)
98
- @node.quoted = quoted
99
- end
100
-
101
- # @see Psych::Nodes::Mapping#style=
102
- # @see Psych::Nodes::Scalar#style=
103
- # @see Psych::Nodes::Sequence#style=
104
- def style=(style)
105
- @node.style = style
106
- end
107
-
108
- # @see Psych::Nodes::Node#tag=
109
- def tag=(tag)
110
- @node.tag = tag
111
- end
112
-
113
- # @see Psych::Nodes::Scalar#value=
114
- def value=(value)
115
- @node.value = value
116
- end
117
-
118
- # @see Psych::Nodes::Alias#anchor
119
- # @see Psych::Nodes::Mapping#anchor
120
- # @see Psych::Nodes::Scalar#anchor
121
- # @see Psych::Nodes::Sequence#anchor
122
- def anchor()
123
- return @node.anchor
83
+ # @api private
84
+ def __getobj__
85
+ return @node
124
86
  end
125
87
 
126
88
  # Check if the children of this parent are keys to a Mapping.
@@ -141,21 +103,6 @@ module Psychgus
141
103
  return @child_type == :value
142
104
  end
143
105
 
144
- # @see Psych::Nodes::Stream#encoding
145
- def encoding()
146
- return @node.encoding
147
- end
148
-
149
- # @see Psych::Nodes::Node#end_column
150
- def end_column()
151
- return @node.end_column
152
- end
153
-
154
- # @see Psych::Nodes::Node#end_line
155
- def end_line()
156
- return @node.end_line
157
- end
158
-
159
106
  # @see Psych::Nodes::Document#implicit
160
107
  # @see Psych::Nodes::Mapping#implicit
161
108
  # @see Psych::Nodes::Sequence#implicit
@@ -183,54 +130,12 @@ module Psychgus
183
130
  return @node.quoted
184
131
  end
185
132
 
186
- # @see Psych::Nodes::Node#start_column
187
- def start_column()
188
- return @node.start_column
189
- end
190
-
191
- # @see Psych::Nodes::Node#start_line
192
- def start_line()
193
- return @node.start_line
194
- end
195
-
196
- # @see Psych::Nodes::Mapping#style
197
- # @see Psych::Nodes::Scalar#style
198
- # @see Psych::Nodes::Sequence#style
199
- def style()
200
- return @node.style
201
- end
202
-
203
- # @see Psych::Nodes::Node#tag
204
- def tag()
205
- return @node.tag
206
- end
207
-
208
- # @see Psych::Nodes::Document#tag_directives
209
- def tag_directives()
210
- return @node.tag_directives
211
- end
212
-
213
- # @see Psych::Nodes::Scalar#value
214
- def value()
215
- return @node.value
216
- end
217
-
218
- # @see Psych::Nodes::Document#version
219
- def version()
220
- return @node.version
221
- end
222
-
223
133
  # @note If this method is modified, then tests will fail
224
134
  #
225
135
  # @return [String] a String representation of this class for debugging and testing
226
136
  def to_s()
227
137
  return "<#{@debug_tag}:(#{@level}:#{@position}):#{@child_type}:(:#{@child_position})>"
228
138
  end
229
-
230
- alias_method :implicit,:implicit?
231
- alias_method :implicit_end,:implicit_end?
232
- alias_method :plain,:plain?
233
- alias_method :quoted,:quoted?
234
139
  end
235
140
  end
236
141
  end
@@ -23,5 +23,5 @@
23
23
 
24
24
  module Psychgus
25
25
  # Version of this gem in "#.#.#" format
26
- VERSION = '1.2.2'
26
+ VERSION = '1.3.2'
27
27
  end
data/lib/psychgus.rb CHANGED
@@ -413,8 +413,7 @@ module Psychgus
413
413
  # [+'a:UTF-16'+] create a new file or append to an existing file
414
414
  # and use UTF-16 encoding
415
415
  # @param perm [Integer] the permission bits to use (platform dependent)
416
- # @param opt [Symbol] the option(s) to use, more readable alternative to +mode+;
417
- # examples: +:textmode+, +:autoclose+
416
+ # @param opt [Hash] Hash of keyword args to pass to +File.open()+
418
417
  # @param options [Hash] the options (or keyword args) to use; see {.dump_stream}
419
418
  #
420
419
  # @see .dump_stream
@@ -422,7 +421,9 @@ module Psychgus
422
421
  # @see IO.new
423
422
  # @see https://ruby-doc.org/core/IO.html#method-c-new
424
423
  def self.dump_file(filename,*objects,mode: 'w',perm: nil,opt: nil,**options)
425
- File.open(filename,mode,perm,opt) do |file|
424
+ opt = Hash(opt)
425
+
426
+ File.open(filename,mode,perm,**opt) do |file|
426
427
  file.write(dump_stream(*objects,**options))
427
428
  end
428
429
  end
@@ -625,6 +626,7 @@ module Psychgus
625
626
  # @param filename [String] the name of the YAML file (and path) to parse
626
627
  # @param fallback [Object] the return value when nothing is parsed
627
628
  # @param mode [String,Integer] the IO open mode to use; example: +'r:BOM|UTF-8'+
629
+ # @param opt [Hash] Hash of keyword args to pass to +File.open()+
628
630
  # @param kargs [Hash] the keyword args to use; see {.parse_stream}
629
631
  #
630
632
  # @return [Psych::Nodes::Document] the parsed Document node
@@ -634,8 +636,10 @@ module Psychgus
634
636
  # @see Psych::Nodes::Document
635
637
  # @see File.open
636
638
  # @see IO.new
637
- def self.parse_file(filename,fallback: false,mode: 'r:BOM|UTF-8',**kargs)
638
- result = File.open(filename,mode) do |file|
639
+ def self.parse_file(filename,fallback: false,mode: 'r:BOM|UTF-8',opt: nil,**kargs)
640
+ opt = Hash(opt)
641
+
642
+ result = File.open(filename,mode,**opt) do |file|
639
643
  parse(file,filename: filename,**kargs)
640
644
  end
641
645
 
data/psychgus.gemspec CHANGED
@@ -58,7 +58,7 @@ Gem::Specification.new() do |spec|
58
58
  # - https://github.com/ruby/psych/commit/712a65a53f3c15105cd86e8ad3ee3c779050ada4
59
59
  spec.add_runtime_dependency 'psych','>= 3.0'
60
60
 
61
- spec.add_development_dependency 'bundler' ,'~> 1.17'
61
+ spec.add_development_dependency 'bundler' ,'~> 2.1'
62
62
  spec.add_development_dependency 'minitest' ,'~> 5.14' # For testing
63
63
  spec.add_development_dependency 'rake' ,'~> 13.0'
64
64
  spec.add_development_dependency 'rdoc' ,'~> 6.2' # For RDoc for YARD (*.rb)
@@ -86,15 +86,28 @@ Toppings:
86
86
  Tempfile.create(['Psychgus','.yaml']) do |file|
87
87
  puts "Testing #{self.class.name} w/ temp file: #{file.path}"
88
88
 
89
- Psychgus.dump_file(file,BURGERS_DATA,stylers: @flow_styler)
89
+ Psychgus.dump_file(file,BURGERS_DATA,
90
+ mode: File::CREAT | File::RDWR,
91
+ opt: {textmode: true},
92
+ #perm: 644, # Unix only
93
+ stylers: @flow_styler,
94
+ )
90
95
 
91
96
  file.rewind()
97
+
92
98
  lines = file.readlines().join()
93
99
  assert_equal EXPECTED_BURGERS,lines
94
100
 
95
101
  file.rewind()
102
+ file.close()
103
+
96
104
  data = Psych.load_file(file)
97
105
  refute_equal false,data
106
+ refute_equal nil,data
107
+
108
+ data = Psychgus.parse_file(file)
109
+ refute_equal false,data
110
+ refute_equal nil,data
98
111
  end
99
112
  end
100
113
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: psychgus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bradley Whited (@esotericpig)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-15 00:00:00.000000000 Z
11
+ date: 2020-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: psych
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.17'
33
+ version: '2.1'
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: '1.17'
40
+ version: '2.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement