Skip to content

Commit 6c8d795

Browse files
committed
trying to build the rust lib
1 parent 648d62b commit 6c8d795

File tree

7 files changed

+24
-92
lines changed

7 files changed

+24
-92
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Rust
22
Cargo.lock
3+
Gemfile.lock
34
/lib/case_transform/native.bundle
4-
/target/
5+
target/
56

67
*.gem
78
*.rbc
9+
mkmf.log
810
/.config
911
/coverage/
1012
/InstalledFiles

Gemfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ source 'https://rubygems.org'
33

44
# Specify your gem's dependencies in authorizable.gemspec
55
gemspec
6-
7-
gem 'helix_runtime', github: 'rustbridge/helix', require: 'helix_runtime/ruby'

Gemfile.lock

Lines changed: 0 additions & 73 deletions
This file was deleted.

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'rake/testtask'
55
require 'bundler/setup'
66
require 'thermite/tasks'
77

8-
Thermite::Tasks.new
8+
Thermite::Tasks.new(cargo_project_path: 'ext/case_transform')
99

1010
# rubocop config copied from AMS
1111
begin
@@ -44,7 +44,7 @@ Rake::TestTask.new(:test) do |t|
4444
t.test_files = FileList['test/**/*_test.rb']
4545
end
4646

47-
task default: [:test, :rubocop]
47+
task default: ['thermite:build', :test, :rubocop]
4848

4949
desc 'CI test task'
5050
task ci: [:default]

ext/case_transform/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name = "case_transform"
33
version = "0.1.0"
44
authors = ["L. Preston Sego III <[email protected]>"]
55

6+
[package.metadata.thermite]
7+
github_releases = true
8+
69
[lib]
710
name = "case_transform"
811
crate-type = ["dylib"]

ext/case_transform/src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
extern crate ruru;
33
extern crate inflector;
44

5-
use ruru::{Class,RString};
6-
75
// // dash: kebab-case
86
// use inflector::cases::kebabcase::to_kebab_case;
97
// // underscore: snake_case
@@ -14,26 +12,28 @@ use ruru::{Class,RString};
1412
// use inflector::cases::classcase::to_class_case;
1513
use inflector::Inflector;
1614

15+
use ruru::{ Class, RString };
16+
1717
methods! (
1818
RString,
1919
itself,
2020

21-
fn toSnakeCase(self) -> RString {
22-
self.to_string().to_snake_case()
21+
fn toSnakeCase() -> String {
22+
itself.to_string().to_snake_case()
2323
}
2424

25-
fn toCamelCase(self) -> RString {
26-
self.to_string().to_camel_case()
25+
fn toCamelCase() -> String {
26+
itself.to_string().to_camel_case()
2727
}
2828

29-
fn toClassCase(self) -> RString {
30-
self.to_string().to_class_case()
29+
fn toClassCase() -> String {
30+
itself.to_string().to_class_case()
3131
}
3232

33-
fn toKebabCase(self) -> RString {
34-
self.to_string().to_kebab_case()
33+
fn toKebabCase() -> String {
34+
itself.to_string().to_kebab_case()
3535
}
36-
)
36+
);
3737

3838
#[no_mangle]
3939
pub extern fn initialize_string() {

lib/case_transform.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# frozen_string_literal: true
22

33
require 'case_transform/version'
4+
require 'thermite/config'
45

5-
require 'helix_runtime'
6+
ruby_dir = File.dirname(File.dirname(__FILE__))
7+
ext_dir = ruby_dir + '/ext/case_transform'
8+
config = Thermite::Config.new(cargo_project_path: ext_dir, ruby_project_path: ruby_dir)
9+
# Do I have to use fiddle? :-\
610

7-
RubyString = String
8-
require 'case_transform/native'
911

1012
module CaseTransform
1113
module_function

0 commit comments

Comments
 (0)