crystalruby 0.1.9 → 0.1.11

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: ca096d0563b6201c3ef4f084fff3304cfa212fda88e81085580b2de5ff10536f
4
- data.tar.gz: ccc68dc96c30f973c9bafcbaec75a2461bbaa275e32913a0781c4cc5488f034f
3
+ metadata.gz: 3cf95b936e86d15e4cbfc45d38ee8ec4bf81a2db762fde8bcfc848d5c73dc3d6
4
+ data.tar.gz: 05d21217238b8a82b809005de6bed2af202b1d1f4fbd5f4da67588cd83f45428
5
5
  SHA512:
6
- metadata.gz: 134e9888d563673d78dc0b9075a239ee3bab6c4a07eb63ff903c748b97684ec87e9bb33011e9f276504f855edd2a25c29860ebc626aa181f74350f68ace8b9e8
7
- data.tar.gz: f3f7a25d12459178e5c8d3cb6a46cfa0e375f65099cdcde15c834a1ba0872198b8475919ec7e5472fa10529bfb71ede67e0edfb88105be5eb220226f2d0ba4ad
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` requires some basic initialization options inside a crystalruby.yaml file in the root of your project.
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 'fileutils'
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('crystalruby.yaml', yaml_content)
21
- puts 'Initialized crystalruby.yaml file with dummy content.'
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('shards update')
28
- puts 'Shards installed successfully.'
27
+ if system("shards update")
28
+ puts "Shards installed successfully."
29
29
  else
30
- puts 'Error installing shards.'
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 'Build command is not implemented yet.'
43
+ puts "Build command is not implemented yet."
44
44
  end
45
45
 
46
46
  # Main program
@@ -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, :crystal_lib_name, :crystal_codegen_dir
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 = if File.exist?("crystalruby.yaml")
17
- YAML.safe_load(IO.read("crystalruby.yaml")) rescue {}
18
- else
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Crystalruby
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.11"
5
5
  end
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
- CrystalRuby.attach! unless CrystalRuby.attached?
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crystalruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters