troml 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +6 -0
- data/lib/troml/version.rb +1 -1
- data/lib/troml.rb +18 -1
- metadata +2 -4
- data/exe/troml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b32eb82d7b2bb7b0d366e435405248d3a1454e611ea3c4c00c8cb1c3532733
|
4
|
+
data.tar.gz: 22fe8c85fe18a4024cf64449eca7b25695e23cf816a38941bdef953d3541b6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5385238a65243317cbf0b41be926281d04504714433c663ffadfcfa752a0c489db46543b5933c5f436411708cb723ab6ebaf1b889a05e1db5461c25113ac9201
|
7
|
+
data.tar.gz: dfac733d4b8c3cd5609317e5f0a5f0d7f46edad769ac0a01345827b77238c346d6eaa6fdedab7bbb1c2f14a28c79eb001a84fb1396e729ef8719fd8e51400d33
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/lib/troml/version.rb
CHANGED
data/lib/troml.rb
CHANGED
@@ -17,7 +17,24 @@ module Troml
|
|
17
17
|
class ExtParseError < Error; end
|
18
18
|
|
19
19
|
# Initialize external library
|
20
|
-
|
20
|
+
#
|
21
|
+
# This is a hack to work around the weirdness of developing
|
22
|
+
# a Rust extension while relying on Rubygems' native Cargo builder.
|
23
|
+
# Rubygems builds copies the shared object into the gem's lib directory
|
24
|
+
# when gem install is run, so it's available for loading in.
|
25
|
+
#
|
26
|
+
# However, while developing the gem, we want to be able to run the gem from its
|
27
|
+
# source context, so we rely on Rutie's convention of loading the shared object
|
28
|
+
# built by Cargo.
|
29
|
+
if File.exist?("troml.so")
|
30
|
+
# We are running in "installed" mode.
|
31
|
+
# Load the shared object built by rubygems.
|
32
|
+
require "troml.so"
|
33
|
+
else
|
34
|
+
# Otherwise we are running in "dev" mode.
|
35
|
+
# Load the target/release object via Rutie.
|
36
|
+
Rutie.new(:troml).init "Init_troml", __dir__
|
37
|
+
end
|
21
38
|
|
22
39
|
# Returns a hash representation of the TOML string passed.
|
23
40
|
# Raises on parse failure.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: troml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pawan Dubey
|
@@ -55,8 +55,7 @@ dependencies:
|
|
55
55
|
description: Blazing fast TOML parser, with the power of Rust.
|
56
56
|
email:
|
57
57
|
- git@pawandubey.com
|
58
|
-
executables:
|
59
|
-
- troml
|
58
|
+
executables: []
|
60
59
|
extensions:
|
61
60
|
- Cargo.toml
|
62
61
|
extra_rdoc_files: []
|
@@ -73,7 +72,6 @@ files:
|
|
73
72
|
- LICENSE.txt
|
74
73
|
- README.md
|
75
74
|
- Rakefile
|
76
|
-
- exe/troml
|
77
75
|
- lib/troml.rb
|
78
76
|
- lib/troml/version.rb
|
79
77
|
- sig/troml.rbs
|
data/exe/troml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
require "troml"
|
6
|
-
require "json"
|
7
|
-
|
8
|
-
def tag(val)
|
9
|
-
case val
|
10
|
-
when String
|
11
|
-
{type: "string", value: val}
|
12
|
-
when Integer
|
13
|
-
{type: "integer", value: val}
|
14
|
-
when Float
|
15
|
-
{type: "float", value: val}
|
16
|
-
when TrueClass, FalseClass
|
17
|
-
{type: "bool", value: val}
|
18
|
-
when Array
|
19
|
-
val.map { |e| tag(e) }
|
20
|
-
when Hash
|
21
|
-
val.transform_values { |v| tag(v) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
raw_toml = ARGF.read
|
26
|
-
|
27
|
-
parsed_toml = Troml.parse(raw_toml)
|
28
|
-
|
29
|
-
tagged_hash = tag(parsed_toml)
|
30
|
-
|
31
|
-
puts tagged_hash.to_json
|