vdf 1.0.4 → 1.0.5
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 +4 -4
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/gempush.yml +5 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/lib/vdf/generate.rb +7 -5
- data/lib/vdf/parse.rb +20 -13
- data/lib/vdf/version.rb +3 -1
- data/lib/vdf.rb +5 -3
- data/vdf.gemspec +15 -15
- metadata +6 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5061239d0e55f0aec46fcde2f175862500ed7d5c25af67a0842e030cb97d90f7
|
|
4
|
+
data.tar.gz: 82198cb9b25f2345e450f8d2a2734ff66495b0c645512fcceb7fee8e96607c4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb1542c98373562ca7c23799eb3c9b5b7e0a1a6e07e3b7c4b595cefa55f51953e865eb286ba6fdd0bd60efce11e919f7844acdb110ec28e2969e71a8b72bf328
|
|
7
|
+
data.tar.gz: 7e87b0dbda7edde4a33371b907ea2cef21e6c91c3c1e30928dbf8e7e13d54270e781bbee8d09a004dffb3658144be0334c994d2c6cc8fd6f206072189927b4fa
|
|
@@ -14,11 +14,12 @@ jobs:
|
|
|
14
14
|
runs-on: ubuntu-latest
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
|
-
- uses: actions/checkout@
|
|
18
|
-
- name: Set up Ruby
|
|
19
|
-
uses:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Set up Ruby
|
|
19
|
+
uses: ruby/setup-ruby@v1
|
|
20
20
|
with:
|
|
21
|
-
version:
|
|
21
|
+
ruby-version: 3.4
|
|
22
|
+
bundler-cache: true
|
|
22
23
|
|
|
23
24
|
- name: Publish to GPR
|
|
24
25
|
run: |
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -68,7 +68,7 @@ puts VDF.generate(object)
|
|
|
68
68
|
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
If you're dealing with parsing large files, you should avoid loading them into memory
|
|
71
|
+
If you're dealing with parsing large files, you should avoid loading them into memory fully. This library supports parsing a VDF file from a File object like this:
|
|
72
72
|
```ruby
|
|
73
73
|
require "vdf"
|
|
74
74
|
|
|
@@ -106,7 +106,7 @@ The latest version of this library can be downloaded at
|
|
|
106
106
|
|
|
107
107
|
* https://rubygems.org/gems/vdf
|
|
108
108
|
|
|
109
|
-
Online Documentation
|
|
109
|
+
Online Documentation is located at
|
|
110
110
|
|
|
111
111
|
* https://www.rubydoc.info/gems/vdf
|
|
112
112
|
|
data/lib/vdf/generate.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module VDF
|
|
2
4
|
# The Generator class is responsible for generating VDF documents from input hashes.
|
|
3
5
|
# @see VDF.generate
|
|
@@ -9,7 +11,7 @@ module VDF
|
|
|
9
11
|
# @param object [Hash] the input object
|
|
10
12
|
# @return [String] the generated VDF document
|
|
11
13
|
def generate(object)
|
|
12
|
-
raise ArgumentError,
|
|
14
|
+
raise ArgumentError, 'Object has to respond to each' unless object.respond_to? :each
|
|
13
15
|
|
|
14
16
|
generate_impl(object, 0)
|
|
15
17
|
end
|
|
@@ -17,14 +19,14 @@ module VDF
|
|
|
17
19
|
private
|
|
18
20
|
|
|
19
21
|
def generate_impl(object, level)
|
|
20
|
-
result =
|
|
21
|
-
indent =
|
|
22
|
+
result = String.new
|
|
23
|
+
indent = "\t" * level
|
|
22
24
|
|
|
23
25
|
object.each do |key, value|
|
|
24
26
|
if value.respond_to? :each
|
|
25
|
-
result << [indent,
|
|
27
|
+
result << [indent, '"', key, "\"\n", indent, "{\n", generate_impl(value, level + 1), indent, "}\n"].join
|
|
26
28
|
else
|
|
27
|
-
result << [indent,
|
|
29
|
+
result << [indent, '"', key, '"', indent, indent, '"', value.to_s, "\"\n"].join
|
|
28
30
|
end
|
|
29
31
|
end
|
|
30
32
|
|
data/lib/vdf/parse.rb
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'stringio'
|
|
4
|
+
|
|
1
5
|
module VDF
|
|
2
6
|
# The Parser class is responsible for parsing a VDF document into a Ruby Hash
|
|
3
7
|
# @see VDF.parse
|
|
@@ -29,7 +33,7 @@ module VDF
|
|
|
29
33
|
# puts contents.inspect
|
|
30
34
|
# end
|
|
31
35
|
def parse(input)
|
|
32
|
-
raise ArgumentError,
|
|
36
|
+
raise ArgumentError, 'Input has to respond to :each_line or :to_str' unless input.respond_to?(:each_line) || input.respond_to?(:to_str)
|
|
33
37
|
input = StringIO.new(input) unless input.respond_to? :pos
|
|
34
38
|
|
|
35
39
|
result = {}
|
|
@@ -40,17 +44,20 @@ module VDF
|
|
|
40
44
|
enum = input.each_line
|
|
41
45
|
enum.with_index do |line, _|
|
|
42
46
|
i += 1
|
|
43
|
-
line.encode!(
|
|
44
|
-
next if line.empty? || line[0] ==
|
|
47
|
+
line.encode!('UTF-8').strip!
|
|
48
|
+
next if line.empty? || line[0] == '/'
|
|
45
49
|
|
|
46
|
-
if line.start_with?(
|
|
50
|
+
if line.start_with?('{')
|
|
47
51
|
expect = false
|
|
48
52
|
next
|
|
49
53
|
elsif expect
|
|
50
54
|
raise ParserError, "Invalid syntax on line #{i+1} (Expected bracket)"
|
|
51
55
|
end
|
|
52
56
|
|
|
53
|
-
if line.start_with?(
|
|
57
|
+
if line.start_with?('}')
|
|
58
|
+
if stack.length == 1
|
|
59
|
+
raise ParserError, "Invalid syntax on line #{i} (Unexpected closing bracket)"
|
|
60
|
+
end
|
|
54
61
|
stack.pop
|
|
55
62
|
next
|
|
56
63
|
end
|
|
@@ -76,7 +83,7 @@ module VDF
|
|
|
76
83
|
end
|
|
77
84
|
|
|
78
85
|
i += 1
|
|
79
|
-
line <<
|
|
86
|
+
line << "\n" << next_line.to_s.encode("UTF-8").strip
|
|
80
87
|
next
|
|
81
88
|
end
|
|
82
89
|
|
|
@@ -85,14 +92,14 @@ module VDF
|
|
|
85
92
|
Integer(val)
|
|
86
93
|
rescue ArgumentError
|
|
87
94
|
Float(val)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
when
|
|
95
|
+
end
|
|
96
|
+
rescue ArgumentError
|
|
97
|
+
case val.downcase
|
|
98
|
+
when 'true'
|
|
92
99
|
true
|
|
93
|
-
when
|
|
100
|
+
when 'false'
|
|
94
101
|
false
|
|
95
|
-
when
|
|
102
|
+
when 'null'
|
|
96
103
|
nil
|
|
97
104
|
else
|
|
98
105
|
val
|
|
@@ -104,7 +111,7 @@ module VDF
|
|
|
104
111
|
end
|
|
105
112
|
end
|
|
106
113
|
|
|
107
|
-
raise ParserError,
|
|
114
|
+
raise ParserError, 'Open parentheses somewhere' unless stack.length == 1
|
|
108
115
|
|
|
109
116
|
return result
|
|
110
117
|
end
|
data/lib/vdf/version.rb
CHANGED
data/lib/vdf.rb
CHANGED
data/vdf.gemspec
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
lib = File.expand_path(
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
-
require
|
|
3
|
+
require 'vdf/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = 'vdf'
|
|
7
7
|
spec.version = VDF::VERSION
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
8
|
+
spec.authors = ['sapphyrus']
|
|
9
|
+
spec.email = ['phil5686@gmail.com']
|
|
10
10
|
|
|
11
|
-
spec.summary =
|
|
12
|
-
spec.homepage =
|
|
13
|
-
spec.license =
|
|
11
|
+
spec.summary = 'Parses Valve\'s KeyValue format to Ruby Hashes and back'
|
|
12
|
+
spec.homepage = 'https://github.com/sapphyrus/vdf'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
14
|
|
|
15
15
|
spec.description = <<-EOF
|
|
16
16
|
VDF is a gem to convert Valve's KeyValue format to Ruby hashes and create a VDF string from a Ruby hash.
|
|
17
17
|
It's based on the excellent node-steam/vdf JS library and it's optimized for performance
|
|
18
18
|
EOF
|
|
19
19
|
|
|
20
|
-
spec.metadata[
|
|
21
|
-
spec.metadata[
|
|
22
|
-
spec.metadata[
|
|
23
|
-
spec.metadata[
|
|
20
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
21
|
+
spec.metadata['source_code_uri'] = 'https://github.com/sapphyrus/vdf'
|
|
22
|
+
spec.metadata['bug_tracker_uri'] = 'https://github.com/sapphyrus/vdf/issues'
|
|
23
|
+
spec.metadata['documentation_uri'] = 'https://www.rubydoc.info/gems/vdf'
|
|
24
|
+
|
|
25
|
+
spec.required_ruby_version = '>= 2.5'
|
|
24
26
|
|
|
25
27
|
# Specify which files should be added to the gem when it is released.
|
|
26
28
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
27
29
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
28
30
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
29
31
|
end
|
|
30
|
-
spec.require_paths = [
|
|
31
|
-
|
|
32
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
|
32
|
+
spec.require_paths = ['lib']
|
|
33
33
|
end
|
metadata
CHANGED
|
@@ -1,29 +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.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sapphyrus
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: bundler
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '2.0'
|
|
20
|
-
type: :development
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - "~>"
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
27
12
|
description: |2
|
|
28
13
|
VDF is a gem to convert Valve's KeyValue format to Ruby hashes and create a VDF string from a Ruby hash.
|
|
29
14
|
It's based on the excellent node-steam/vdf JS library and it's optimized for performance
|
|
@@ -33,6 +18,7 @@ executables: []
|
|
|
33
18
|
extensions: []
|
|
34
19
|
extra_rdoc_files: []
|
|
35
20
|
files:
|
|
21
|
+
- ".github/dependabot.yml"
|
|
36
22
|
- ".github/workflows/gempush.yml"
|
|
37
23
|
- ".gitignore"
|
|
38
24
|
- LICENSE.txt
|
|
@@ -50,7 +36,6 @@ metadata:
|
|
|
50
36
|
source_code_uri: https://github.com/sapphyrus/vdf
|
|
51
37
|
bug_tracker_uri: https://github.com/sapphyrus/vdf/issues
|
|
52
38
|
documentation_uri: https://www.rubydoc.info/gems/vdf
|
|
53
|
-
post_install_message:
|
|
54
39
|
rdoc_options: []
|
|
55
40
|
require_paths:
|
|
56
41
|
- lib
|
|
@@ -58,15 +43,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
58
43
|
requirements:
|
|
59
44
|
- - ">="
|
|
60
45
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
46
|
+
version: '2.5'
|
|
62
47
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
48
|
requirements:
|
|
64
49
|
- - ">="
|
|
65
50
|
- !ruby/object:Gem::Version
|
|
66
51
|
version: '0'
|
|
67
52
|
requirements: []
|
|
68
|
-
rubygems_version: 3.
|
|
69
|
-
signing_key:
|
|
53
|
+
rubygems_version: 3.6.9
|
|
70
54
|
specification_version: 4
|
|
71
55
|
summary: Parses Valve's KeyValue format to Ruby Hashes and back
|
|
72
56
|
test_files: []
|