crystalruby 0.1.9 → 0.1.11
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/README.md +18 -3
- data/exe/crystalruby +8 -8
- data/lib/crystalruby/config.rb +8 -7
- data/lib/crystalruby/version.rb +1 -1
- data/lib/crystalruby.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cf95b936e86d15e4cbfc45d38ee8ec4bf81a2db762fde8bcfc848d5c73dc3d6
|
4
|
+
data.tar.gz: 05d21217238b8a82b809005de6bed2af202b1d1f4fbd5f4da67588cd83f45428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88306803e6fe56de62ceb826128767879f0cf46d1656e852deb3e98519d8dd304f151ca03ba8c505915ecc164c8663a19bdb5ea28d751e47e32cc4e8fc555902
|
7
|
+
data.tar.gz: 6b0621a641bf771a9313b652e1d503bfb734942ee1135188ad7baf68d08850577b581cb76a941861c5e2270744e289c32ce720ea4500729483ca50bd365d927f
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ module Cache
|
|
87
87
|
end
|
88
88
|
|
89
89
|
crystalize [key: :string, value: :string] => :string
|
90
|
-
def redis_set_and_return(key)
|
90
|
+
def redis_set_and_return(key, value)
|
91
91
|
redis = Redis::Client.new
|
92
92
|
redis.set(key, value)
|
93
93
|
Cache.redis_get(key)
|
@@ -465,7 +465,7 @@ bundle exec crystalruby clean
|
|
465
465
|
|
466
466
|
## Design Goals
|
467
467
|
|
468
|
-
`crystalruby`'s primary purpose is provide ergonomic access to Crystal from Ruby, over FFI.
|
468
|
+
`crystalruby`'s primary purpose is to provide ergonomic access to Crystal from Ruby, over FFI.
|
469
469
|
For simple usage, advanced knowledge of Crystal should not be required.
|
470
470
|
|
471
471
|
However, the abstraction it provides should remain simple, transparent, and easy to hack on and it should not preclude users from supplementing its capabilities with a more direct integration using ffi primtives.
|
@@ -501,7 +501,7 @@ Or install it yourself as:
|
|
501
501
|
$ gem install crystalruby
|
502
502
|
```
|
503
503
|
|
504
|
-
`crystalruby`
|
504
|
+
`crystalruby` supports some basic configuration options, which can be specified inside a crystalruby.yaml file in the root of your project.
|
505
505
|
You can run `crystalruby init` to generate a configuration file with sane defaults.
|
506
506
|
|
507
507
|
```bash
|
@@ -513,6 +513,21 @@ crystal_src_dir: "./crystalruby/src"
|
|
513
513
|
crystal_lib_dir: "./crystalruby/lib"
|
514
514
|
crystal_main_file: "main.cr"
|
515
515
|
crystal_lib_name: "crlib"
|
516
|
+
crystal_codegen_dir: "generated"
|
517
|
+
debug: true
|
518
|
+
```
|
519
|
+
|
520
|
+
Alternatively, these can be set programmatically:
|
521
|
+
|
522
|
+
```ruby
|
523
|
+
CrystalRuby.configure do |config|
|
524
|
+
config.crystal_src_dir = "./crystalruby/src"
|
525
|
+
config.crystal_lib_dir = "./crystalruby/lib"
|
526
|
+
config.crystal_main_file = "main.cr"
|
527
|
+
config.crystal_lib_name = "crlib"
|
528
|
+
config.crystal_codegen_dir = "generated"
|
529
|
+
config.debug = true
|
530
|
+
end
|
516
531
|
```
|
517
532
|
|
518
533
|
## Development
|
data/exe/crystalruby
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "crystalruby"
|
5
|
-
require
|
5
|
+
require "fileutils"
|
6
6
|
|
7
7
|
# Define the actions for the commands
|
8
8
|
def init
|
@@ -14,20 +14,20 @@ def init
|
|
14
14
|
crystal_main_file: "main.cr"
|
15
15
|
crystal_lib_name: "crlib"
|
16
16
|
crystal_codegen_dir: "generated"
|
17
|
+
debug: true
|
17
18
|
YAML
|
18
19
|
|
19
20
|
# Create the file at the root of the current directory
|
20
|
-
File.write(
|
21
|
-
puts
|
21
|
+
File.write("crystalruby.yaml", yaml_content)
|
22
|
+
puts "Initialized crystalruby.yaml file with dummy content."
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
25
|
def install
|
26
26
|
Dir.chdir("#{CrystalRuby.config.crystal_src_dir}") do
|
27
|
-
if system(
|
28
|
-
puts
|
27
|
+
if system("shards update")
|
28
|
+
puts "Shards installed successfully."
|
29
29
|
else
|
30
|
-
puts
|
30
|
+
puts "Error installing shards."
|
31
31
|
end
|
32
32
|
end
|
33
33
|
clean
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
|
41
41
|
def build
|
42
42
|
# This is a stub for the build command
|
43
|
-
puts
|
43
|
+
puts "Build command is not implemented yet."
|
44
44
|
end
|
45
45
|
|
46
46
|
# Main program
|
data/lib/crystalruby/config.rb
CHANGED
@@ -9,25 +9,26 @@ module CrystalRuby
|
|
9
9
|
# Define a nested Config class
|
10
10
|
class Config
|
11
11
|
include Singleton
|
12
|
-
attr_accessor :debug, :crystal_src_dir, :crystal_lib_dir, :crystal_main_file,
|
12
|
+
attr_accessor :debug, :crystal_src_dir, :crystal_lib_dir, :crystal_main_file,
|
13
|
+
:crystal_lib_name, :crystal_codegen_dir
|
13
14
|
|
14
15
|
def initialize
|
15
16
|
@debug = true
|
16
|
-
config =
|
17
|
-
YAML.safe_load(IO.read("crystalruby.yaml"))
|
18
|
-
|
19
|
-
|
20
|
-
end
|
17
|
+
config = File.exist?("crystalruby.yaml") && begin
|
18
|
+
YAML.safe_load(IO.read("crystalruby.yaml"))
|
19
|
+
rescue StandardError
|
20
|
+
nil
|
21
|
+
end || {}
|
21
22
|
@crystal_src_dir = config.fetch("crystal_src_dir", "./crystalruby/src")
|
22
23
|
@crystal_lib_dir = config.fetch("crystal_lib_dir", "./crystalruby/lib")
|
23
24
|
@crystal_main_file = config.fetch("crystal_main_file", "main.cr")
|
24
25
|
@crystal_lib_name = config.fetch("crystal_lib_name", "crlib")
|
25
26
|
@crystal_codegen_dir = config.fetch("crystal_codegen_dir", "generated")
|
27
|
+
@debug = config.fetch("debug", "true")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
31
|
def self.configure
|
30
|
-
setup
|
31
32
|
yield(config)
|
32
33
|
end
|
33
34
|
end
|
data/lib/crystalruby/version.rb
CHANGED
data/lib/crystalruby.rb
CHANGED
@@ -86,7 +86,10 @@ module CrystalRuby
|
|
86
86
|
receiver.prepend(Module.new do
|
87
87
|
define_method(method_name) do |*args|
|
88
88
|
CrystalRuby.compile! unless CrystalRuby.compiled?
|
89
|
-
|
89
|
+
unless CrystalRuby.attached?
|
90
|
+
CrystalRuby.attach!
|
91
|
+
return send(method_name, *args) if block
|
92
|
+
end
|
90
93
|
args.each_with_index do |arg, i|
|
91
94
|
args[i] = function[:arg_maps][i][arg] if function[:arg_maps][i]
|
92
95
|
end
|