vdf 1.0.2 → 1.0.3

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: 671fed7feb60fe6633dbf7f0e59be7871b6ebcdce21526f4a48a2995f74bab30
4
- data.tar.gz: 27d447b2bdaa23854f08b8d39765baec1119e80362e565eceb3c07761144faa8
3
+ metadata.gz: ea8791384e1412acbaf3adb8e3d6c927b551beffa7ca464d0c13d2afc09f3467
4
+ data.tar.gz: 31b28036937bf19217f598c7c59614448af11e4f7d70e6c4fb1f72d948252deb
5
5
  SHA512:
6
- metadata.gz: 52725af93ca37ad09273f16ffc1cad5c1ea90c89703187e915a8c8855806795a33f2378c07a76b7ef81e59de6344338ae8f5ac81104c3621d777283a24e2abca
7
- data.tar.gz: 335f96798e24298f69aeda8a8df290bf5245126951c69e556312b53d5b98fe998653d324620c76fbce6ce717de9e96db31b5ddbc9c79ae39a09506ffa1e6e2e5
6
+ metadata.gz: 961a27599e581e3ce2452a74833ac5b67d89d23d4eb98454602b6c33533c2102468ba80661543ea08468b47de2328de23b1931300c3d013b98e8323debd95038
7
+ data.tar.gz: 63d5f33713c9ad9f9d32c32f6b3f75ab90661ff48b286e463392390720daf05ad23c078d17b0bdc2e07e57c66b49c31c877d5cdc780819a47749cc73fb80fb32
@@ -27,7 +27,7 @@ jobs:
27
27
  chmod 0600 $HOME/.gem/credentials
28
28
  printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
29
  gem build *.gemspec
30
- gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
30
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem || true
31
31
  env:
32
32
  GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
33
33
  OWNER: sapphyrus
@@ -39,6 +39,6 @@ jobs:
39
39
  chmod 0600 $HOME/.gem/credentials
40
40
  printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
41
41
  gem build *.gemspec
42
- gem push *.gem
42
+ gem push *.gem || true
43
43
  env:
44
44
  GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # VDF
2
2
 
3
- VDF is a gem to convert Valve's KeyValue format to ruby hashes and back, based on the excellent [node-steam/vdf](https://github.com/node-steam/vdf)
4
-
5
- [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsapphyrus%2Fvdf%2Fbadge&style=popout)](https://actions-badge.atrox.dev/sapphyrus/vdf/goto)
3
+ [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsapphyrus%2Fvdf%2Fbadge&style=flat)](https://actions-badge.atrox.dev/sapphyrus/vdf/goto)
6
4
  [![Gem](https://img.shields.io/gem/v/vdf?color=%23E9573F)](https://rubygems.org/gems/vdf)
5
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/gems/vdf)
6
+ [![GitHub issues](https://img.shields.io/github/issues/sapphyrus/vdf)](https://github.com/sapphyrus/vdf/issues)
7
+ [![License](https://img.shields.io/github/license/sapphyrus/vdf)](https://github.com/sapphyrus/vdf/blob/master/LICENSE.txt)
8
+
9
+ VDF is a gem to convert Valve's KeyValue format to Ruby hashes and back, based on the excellent [node-steam/vdf](https://github.com/node-steam/vdf)
7
10
 
8
11
  ## Installation
9
12
 
@@ -83,6 +86,16 @@ vdf4r 53.422000 0.016000 53.438000 ( 54.020029)
83
86
 
84
87
  Compared to the [vdf4r gem](https://github.com/skadistats/vdf4r) using [this script](https://gist.github.com/sapphyrus/3aab81ad06949c3743ad91e20ccf7c65).
85
88
 
89
+ ## Download
90
+
91
+ The latest version of this library can be downloaded at
92
+
93
+ * https://rubygems.org/gems/vdf
94
+
95
+ Online Documentation should be located at
96
+
97
+ * https://www.rubydoc.info/gems/vdf
98
+
86
99
  ## Contributing
87
100
 
88
101
  Bug reports and pull requests are welcome on GitHub at https://github.com/sapphyrus/vdf.
data/lib/vdf.rb CHANGED
@@ -2,7 +2,10 @@ require "vdf/version"
2
2
  require "vdf/parse"
3
3
  require "vdf/generate"
4
4
 
5
+ # Main VDF module
6
+ # @author sapphyrus
5
7
  module VDF
8
+ # Error while parsing a VDF document
6
9
  class ParserError < StandardError
7
10
  end
8
11
  end
@@ -1,7 +1,13 @@
1
1
  module VDF
2
+ # The Generator class is responsible for generating VDF documents from input hashes.
3
+ # @see VDF.generate
2
4
  class Generator
3
5
  class << self
4
6
 
7
+ # Generates a VDF document from a Ruby Hash and returns it
8
+ #
9
+ # @param object [Hash] the input object
10
+ # @return [String] the generated VDF document
5
11
  def generate(object)
6
12
  raise ArgumentError, "Object has to respond to each" unless object.respond_to? :each
7
13
 
@@ -27,6 +33,10 @@ module VDF
27
33
  end
28
34
  end
29
35
 
36
+ # Generates a VDF document from a ruby hash.
37
+ #
38
+ # @param object [Hash] the input object
39
+ # @return [String] the generated VDF document
30
40
  def generate(object)
31
41
  Generator.generate(object)
32
42
  end
@@ -1,6 +1,9 @@
1
1
  module VDF
2
+ # The Parser class is responsible for parsing a VDF document into a Ruby Hash
3
+ # @see VDF.parse
2
4
  class Parser
3
5
  class << self
6
+ # Regex for splitting up a line in a VDF document into meaningful parts. Taken from {https://github.com/node-steam/vdf/blob/master/src/index.ts#L18-L24}
4
7
  REGEX = Regexp.new(
5
8
  '^("((?:\\\\.|[^\\\\"])+)"|([a-z0-9\\-\\_]+))' +
6
9
  '([ \t]*(' +
@@ -9,7 +12,22 @@ module VDF
9
12
  '))?',
10
13
  Regexp::MULTILINE
11
14
  )
15
+ private_constant :REGEX
12
16
 
17
+ # Parses a VDF document into a Ruby Hash and returns it
18
+ #
19
+ # For large files, it's recommended to pass the File object to VDF.parse instead of reading the whole File contents into memory
20
+ #
21
+ # @param input [String, File, #to_str, #each_line] the input object
22
+ # @return [Hash] the contents of the VDF document, parsed into a Ruby Hash
23
+ # @raise [ParserError] if the VDF document is invalid
24
+ # @example Parse the contents of a VDF String
25
+ # contents = VDF.parse(string)
26
+ # @example Parse the contents of a VDF File
27
+ # File.open("filename.vdf", "r") do |file|
28
+ # contents = VDF.parse(file)
29
+ # puts contents.inspect
30
+ # end
13
31
  def parse(input)
14
32
  raise ArgumentError, "Input has to respond to :each_line or :to_str" unless input.respond_to?(:each_line) || input.respond_to?(:to_str)
15
33
  input = StringIO.new(input) unless input.respond_to? :pos
@@ -91,8 +109,22 @@ module VDF
91
109
  end
92
110
  end
93
111
 
94
- def parse(text)
95
- Parser.parse(text)
112
+ # Parses a VDF document into a Ruby Hash and returns it
113
+ #
114
+ # For large files, it's recommended to pass the File object to VDF.parse instead of reading the whole File contents into memory
115
+ #
116
+ # @param input [String, File, #to_str, #each_line] the input object
117
+ # @return [Hash] the contents of the VDF document, parsed into a Ruby Hash
118
+ # @raise [ParserError] if the VDF document is invalid
119
+ # @example Parse the contents of a VDF String
120
+ # contents = VDF.parse(string)
121
+ # @example Parse the contents of a VDF File
122
+ # File.open("filename.vdf", "r") do |file|
123
+ # contents = VDF.parse(file)
124
+ # puts contents.inspect
125
+ # end
126
+ def parse(input)
127
+ Parser.parse(input)
96
128
  end
97
129
  module_function :parse
98
130
  end
@@ -1,3 +1,4 @@
1
1
  module VDF
2
- VERSION = "1.0.2"
2
+ # The current version
3
+ VERSION = "1.0.3"
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sapphyrus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-24 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler