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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc870e4f34690796193842a596e310ab952d2a4ae356cb2d659b3fbd0222f6b5
4
- data.tar.gz: ab5ad05ac45f58022870aa90fb34b11ab34ddb87bfa8b5bdacca0bcb800481ff
3
+ metadata.gz: d8b32eb82d7b2bb7b0d366e435405248d3a1454e611ea3c4c00c8cb1c3532733
4
+ data.tar.gz: 22fe8c85fe18a4024cf64449eca7b25695e23cf816a38941bdef953d3541b6ad
5
5
  SHA512:
6
- metadata.gz: e19d95fa64daaf1cc440938f17f4ea329eb8267e2ecae13ec8976efabe156a09187397d272a90dba8151b5fbec9adce1146f6dc56ed8607d49fbdd0e20cd14dc
7
- data.tar.gz: 9bc97e9d8bc56bee2bb0c29945697582fd02e7f8bbb43cffe2674a5d8f96ea7693e084272d0b3e6e01bb1d2632df46946b1fda3dcedff62626e022145bcfe9b6
6
+ metadata.gz: 5385238a65243317cbf0b41be926281d04504714433c663ffadfcfa752a0c489db46543b5933c5f436411708cb723ab6ebaf1b889a05e1db5461c25113ac9201
7
+ data.tar.gz: dfac733d4b8c3cd5609317e5f0a5f0d7f46edad769ac0a01345827b77238c346d6eaa6fdedab7bbb1c2f14a28c79eb001a84fb1396e729ef8719fd8e51400d33
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- troml (0.1.0)
4
+ troml (0.1.3)
5
5
  rutie (~> 0.0.4)
6
6
 
7
7
  GEM
data/Rakefile CHANGED
@@ -11,4 +11,10 @@ end
11
11
 
12
12
  require "standard/rake"
13
13
 
14
+ task :cargo_build do
15
+ system("cargo build --release")
16
+ end
17
+
18
+ task test: :cargo_build
19
+
14
20
  task default: %i[test standard]
data/lib/troml/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Troml
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
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
- Rutie.new(:troml).init "Init_troml", __dir__
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.3
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