cslrb 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d33a65a3c8bef259e507b130abab7ba117ab8a39fb0bd210a2f5761361a35e9c
4
+ data.tar.gz: 1f6ecd01d18c9dcbf08a1dc07969eeb083917e2ae3dd07e48f6dd0e24107e162
5
+ SHA512:
6
+ metadata.gz: 87ec3a4f7fdb7eba2e04a4906641a4050d8b22150f7341d18bde9eaedd1e8f386ab827d8c41c5f5cf16154489ece04c73dd031e502c56bc6a558d7394fefe6c3
7
+ data.tar.gz: 3324c23d5d29ad6de5df7e3671bcf20bcd94671fdaa41e62e2fc63a8e80ff48e95654ed68e82f6fb9345fed5eba42ea4fac9f3b3f63e573ea296ec6cb3174597
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+
14
+ #Added by cargo
15
+ #
16
+ #already existing elements are commented out
17
+
18
+ /target
19
+ **/*.rs.bk
20
+ Cargo.lock
21
+ mkmf.log
22
+ *.so
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.0.2
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.2
data/Cargo.toml ADDED
@@ -0,0 +1,15 @@
1
+ [package]
2
+ name = "cslrb"
3
+ version = "0.1.0"
4
+ authors = ["Sascha Knobloch <saschaknobloch.dev@gmail.com>"]
5
+ edition = "2018"
6
+
7
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
+
9
+ [dependencies]
10
+ rutie = "0.8.2"
11
+ cardano-serialization-lib = "11.4.0"
12
+
13
+ [lib]
14
+ name = "cslrb"
15
+ crate-type = ["dylib"]
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in sterilize.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cslrb (0.1.0)
5
+ rutie (~> 0.0.4)
6
+ thermite (~> 0.13)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
13
+ json (2.6.3)
14
+ language_server-protocol (3.17.0.3)
15
+ minitar (0.9)
16
+ parallel (1.23.0)
17
+ parser (3.2.2.3)
18
+ ast (~> 2.4.1)
19
+ racc
20
+ racc (1.7.1)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ regexp_parser (2.8.1)
24
+ rexml (3.2.5)
25
+ rspec (3.12.0)
26
+ rspec-core (~> 3.12.0)
27
+ rspec-expectations (~> 3.12.0)
28
+ rspec-mocks (~> 3.12.0)
29
+ rspec-core (3.12.2)
30
+ rspec-support (~> 3.12.0)
31
+ rspec-expectations (3.12.3)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.12.0)
34
+ rspec-mocks (3.12.6)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.12.0)
37
+ rspec-support (3.12.1)
38
+ rubocop (1.54.2)
39
+ json (~> 2.3)
40
+ language_server-protocol (>= 3.17.0)
41
+ parallel (~> 1.10)
42
+ parser (>= 3.2.2.3)
43
+ rainbow (>= 2.2.2, < 4.0)
44
+ regexp_parser (>= 1.8, < 3.0)
45
+ rexml (>= 3.2.5, < 4.0)
46
+ rubocop-ast (>= 1.28.0, < 2.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 2.4.0, < 3.0)
49
+ rubocop-ast (1.29.0)
50
+ parser (>= 3.2.1.0)
51
+ ruby-progressbar (1.13.0)
52
+ rutie (0.0.4)
53
+ thermite (0.13.0)
54
+ minitar (~> 0.5)
55
+ rake (>= 10)
56
+ tomlrb (~> 1.2)
57
+ tomlrb (1.3.0)
58
+ unicode-display_width (2.4.2)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ bundler (~> 2.0)
65
+ cslrb!
66
+ json (~> 2.6)
67
+ rake (~> 13.0)
68
+ rspec (~> 3.6)
69
+ rubocop (~> 1.54)
70
+
71
+ BUNDLED WITH
72
+ 2.2.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Martin Feckie
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Cslrb
2
+
3
+ Cslrb is a gem which uses the Rust library [cardano-serialization-lib](https://github.com/Emurgo/cardano-serialization-lib) to make some of its features available in Ruby.
4
+
5
+ > Cardano Serialization Lib is a library, written in Rust, for serialization & deserialization of data structures used in Cardano's Haskell implementation of Alonzo along with useful utility functions.
6
+
7
+ ## Installation
8
+
9
+ In order to use this library you will need to have access to Rust's build tooling [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html), this simplest way to get this is via [rustup](https://rustup.rs/).
10
+
11
+ After ensuring you have these things available, add the gem to your bundle
12
+
13
+ ```ruby
14
+ gem 'cslrb'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install cslrb
24
+
25
+ `cslrb` includes a Rake task which will compile the Rust library for your platform and copy it to the correct location.
26
+
27
+ ## Usage
28
+
29
+ `cslrb` currently provides a single method, `Cslrb.tx_body_from_hex` which accepts a string (TX CBOR as hex).
30
+
31
+ ```shell
32
+ pry(main)> cbor_hex = "84a40081825820f97da637cc2e8b5b970b1952bcdc62422e82873bb0503a75ab70ed3c3476e9cc010182825839010a7bc8293ae50dd74ae399b261446abff238ea7c564ad52a52168e0b8c6663f1d8c19ba014cf7357207946d54731f2535ae8720c667cdbbc1a000f42408258390177992ea7e2b434bd4ba92e3b2c9592c0805a4552e1d2bb7a7e9c726b4b3ff6604e58320d841aa3af6d4aca9583bd3741ec93518d973a498e1a022468b3021a0002917d031a05d25734a10081825820e41c3c43e11599b056d0de12a55ef49346bb941fcafef7aad08a7b3361b4ccf55840b1fb566bacc3c5f97748dd281f65abec51c64814c289ddcd2792e094091750755542ef4cea7d423a09066486fb2ce185da6fef380dbf65fcadb9bda6c697d701f5f6"
33
+ pry(main)> Cslrb.tx_body_from_hex(cbor_hex)
34
+ => "{\n \"inputs\": [\n {\n \"transaction_id\": \"f97da637cc2e8b5b970b1952bcdc62422e82873bb0503a75ab70ed3c3476e9c...
35
+ ```
36
+
37
+ Passing anything other than a `String` will result in an error.
38
+
39
+ ## Available Methods
40
+
41
+ ```ruby
42
+ Cslrb.tx_body_from_hex(cbor_hex)
43
+ ```
44
+
45
+ ## Development
46
+
47
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
48
+
49
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
50
+
51
+ ## Contributing
52
+
53
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cslrb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'thermite/tasks'
9
+
10
+ Thermite::Tasks.new
11
+
12
+ desc 'Run Rust & Ruby testsuites'
13
+ task test: ['thermite:build', 'thermite:test', 'spec']
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'cslrb'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/cslrb.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'cslrb/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'cslrb'
9
+ spec.version = Cslrb::VERSION
10
+ spec.authors = ['Sascha Knobloch']
11
+ spec.email = ['saschaknobloch.dev@gmail.com']
12
+
13
+ spec.summary = 'Cslrb uses the Rust library Cardano Serialization Lib to make some of its features available in Ruby.'
14
+ spec.description = 'This gem provides a Ruby interface to the Cardano Serialization Lib by leveraging Rutie, allowing developers to work with Cardano-specific data structures in their Ruby applications.'
15
+ spec.homepage = 'https://github.com/saschaknobloch/cslrb'
16
+ spec.license = 'MIT'
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+
26
+ spec.extensions = ['ext/Rakefile']
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_runtime_dependency 'rutie', '~> 0.0.4'
30
+ spec.add_runtime_dependency 'thermite', '~> 0.13'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 2.0'
33
+ spec.add_development_dependency 'rake', '~> 13.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.6'
35
+ spec.add_development_dependency 'rubocop', '~> 1.54'
36
+ spec.add_development_dependency 'json', '~> 2.6'
37
+ end
data/ext/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thermite/tasks'
4
+
5
+ project_dir = File.dirname(File.dirname(__FILE__))
6
+ Thermite::Tasks.new(cargo_project_path: project_dir, ruby_project_path: project_dir)
7
+ task default: %w[thermite:build]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cslrb
4
+ VERSION = '0.1.0'
5
+ end
data/lib/cslrb.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cslrb/version'
4
+ require 'rutie'
5
+
6
+ module Cslrb
7
+ Rutie.new(:cslrb).init('Init_cslrb', __dir__)
8
+ end
data/src/lib.rs ADDED
@@ -0,0 +1,30 @@
1
+ #[macro_use]
2
+ extern crate rutie;
3
+
4
+ use cardano_serialization_lib::{Transaction};
5
+ use rutie::{Module, Object, RString, VM};
6
+
7
+ module!(Cslrb);
8
+
9
+ methods!(
10
+ Cslrb,
11
+ _itself,
12
+ fn tx_body_from_hex(cbor_hex: RString) -> RString {
13
+ let ruby_string = cbor_hex.map_err(|e| VM::raise_ex(e) ).unwrap();
14
+ let transaction = Transaction::from_hex(&ruby_string.to_string()).unwrap();
15
+ let transaction_body = transaction.body();
16
+
17
+ match transaction_body.to_json() {
18
+ Ok(json_string) => return RString::new_utf8(&json_string),
19
+ Err(err) => return RString::new_utf8(&format!("Error: {}", err)),
20
+ }
21
+ }
22
+ );
23
+
24
+ #[allow(non_snake_case)]
25
+ #[no_mangle]
26
+ pub extern "C" fn Init_cslrb() {
27
+ Module::from_existing("Cslrb").define(|itself| {
28
+ itself.def_self("tx_body_from_hex", tx_body_from_hex);
29
+ });
30
+ }
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cslrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sascha Knobloch
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-07-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rutie
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: thermite
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.13'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.13'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '13.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '13.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.6'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.6'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.54'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.54'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.6'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.6'
111
+ description: This gem provides a Ruby interface to the Cardano Serialization Lib by
112
+ leveraging Rutie, allowing developers to work with Cardano-specific data structures
113
+ in their Ruby applications.
114
+ email:
115
+ - saschaknobloch.dev@gmail.com
116
+ executables: []
117
+ extensions:
118
+ - ext/Rakefile
119
+ extra_rdoc_files: []
120
+ files:
121
+ - ".gitignore"
122
+ - ".rspec"
123
+ - ".ruby-version"
124
+ - ".travis.yml"
125
+ - Cargo.toml
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bin/console
132
+ - bin/setup
133
+ - cslrb.gemspec
134
+ - ext/Rakefile
135
+ - lib/cslrb.rb
136
+ - lib/cslrb/version.rb
137
+ - src/lib.rs
138
+ homepage: https://github.com/saschaknobloch/cslrb
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubygems_version: 3.4.17
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Cslrb uses the Rust library Cardano Serialization Lib to make some of its
161
+ features available in Ruby.
162
+ test_files: []