Skip to content

Commit dd9065f

Browse files
committed
allow setting debug flag in rake task
1 parent 6e6036e commit dd9065f

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/rubex/rake_task.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Rubex
77
class RakeTask < ::Rake::TaskLib
88
attr_reader :ext_dir, :rubex_files
9+
attr_accessor :debug
910

1011
def initialize name, gem_spec=nil, &block
1112
@name = name
@@ -15,6 +16,7 @@ def initialize name, gem_spec=nil, &block
1516
@source_pattern = "*.rubex"
1617
@compiled_pattern = "*.c"
1718
@config_script = "extconf.rb"
19+
@debug = true
1820
instance_eval(&block) if block_given?
1921
define_compile_tasks
2022
end
@@ -41,7 +43,7 @@ def define_compile_tasks
4143
desc "Compile a Rubex file into a shared object."
4244
task :compile do
4345
file_name = "#{@ext_dir}/#{@name}#{@source_pattern[1..-1]}"
44-
Rubex::Compiler.compile file_name, target_dir: "#{@ext_dir}"
46+
Rubex::Compiler.compile file_name, target_dir: "#{@ext_dir}", debug: @debug
4547
end
4648

4749
desc "Delete all generated files."

spec/rake_task_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@
3030
expect(task.ext_dir).to eq(Dir.pwd)
3131
end
3232
end
33+
34+
context "#debug" do
35+
before do
36+
@task_name = "test"
37+
end
38+
39+
it "sets debug flag -g during compilation" do
40+
task = Rubex::RakeTask.new(@task_name) do
41+
debug = true
42+
end
43+
44+
expect(task.debug).to eq(true)
45+
end
46+
end
3347
end
3448

3549
describe "rake" do

0 commit comments

Comments
 (0)