vdf 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gempush.yml +2 -2
- data/README.md +16 -3
- data/lib/vdf.rb +3 -0
- data/lib/vdf/generate.rb +10 -0
- data/lib/vdf/parse.rb +34 -2
- data/lib/vdf/version.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea8791384e1412acbaf3adb8e3d6c927b551beffa7ca464d0c13d2afc09f3467
|
4
|
+
data.tar.gz: 31b28036937bf19217f598c7c59614448af11e4f7d70e6c4fb1f72d948252deb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/lib/vdf/generate.rb
CHANGED
@@ -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
|
data/lib/vdf/parse.rb
CHANGED
@@ -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
|
-
|
95
|
-
|
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
|
data/lib/vdf/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|