skipjack 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 346e360f1203eaf442ccdbc7fd11459aaf177401
4
- data.tar.gz: e219ec7484e6a1d6360bbf1cd60abae841a600bc
3
+ metadata.gz: e197313df74648d36c9608a97523791d2982d239
4
+ data.tar.gz: 9e0d38d5fd325164bf6975b79beb768e90dd75eb
5
5
  SHA512:
6
- metadata.gz: 8f6ff2ad0d53c0d85b118be1a4637fa80f25c2a2bbd3f33ce95f8ee076b6380044ed86ae6bb3b44af85a509273183edd7d29015c3b6adb10819b7bf9f8c53d48
7
- data.tar.gz: c740d7eb3781a01e22127aadb5b683e5d7cf5748a29d9b845b48faede73a933cb66be2f187634230d66e3d9985c6de65b1f38d629c66ea1669493263a783ad0b
6
+ metadata.gz: e0a3059a796649cf21344eaacf2e872bafd39752906d49e0cfe4e5dcd20cdd3be3bd943660fbb941f570952ff1a5549a26eec828a93e18776337d6c156dfd283
7
+ data.tar.gz: 4743affd7b7db28f0a2c08e72600d567f89733b4bf194e96445000ba5ab3e723710033a75ae5bff12ad0651445a896488d2eff754841b9de743a33bbd499abcf
@@ -1,7 +1,6 @@
1
1
  module Skipjack
2
2
  class FSharpCompiler
3
3
  attr_reader :target
4
- attr_accessor :output_folder, :output_file
5
4
  attr_writer :references
6
5
 
7
6
  def initialize *args
@@ -26,29 +25,27 @@ module Skipjack
26
25
  @references ||= []
27
26
  end
28
27
 
29
- def create_file_task
30
- output_file_name = output_folder ? "#{output_folder}/#{output_file}" : output_file
28
+ def create_file_task *args
31
29
  dependencies = source_files
32
- file_task = Rake::FileTask::define_task output_file_name => dependencies do |t|
30
+ file_task = Rake::FileTask::define_task *args do |t|
33
31
  if t.application.windows?
34
32
  compiler = "fsc"
35
33
  else
36
34
  compiler = "fsharpc"
37
35
  end
38
36
 
39
- out = "--out:#{output_file_name}"
37
+ out = "--out:#{t.name}"
40
38
  src = source_files.join(" ")
41
39
  refs = references.each {|r| r.prepend("--reference:") }
42
40
  refs = refs.join(" ")
43
41
  cmd = "#{compiler} #{refs} #{out} --target:#{target.to_s} #{src}"
44
42
  raise "Error executing command" unless Kernel.system cmd
45
43
  end
44
+ file_task.enhance dependencies
46
45
  end
47
46
 
48
47
  def create_task
49
- task = Rake::Task::define_task *@args
50
- file_task = create_file_task
51
- task.enhance [file_task]
48
+ create_file_task *@args
52
49
  end
53
50
  end
54
51
  end
@@ -1,3 +1,3 @@
1
1
  module Skipjack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -17,20 +17,22 @@ describe 'fsharp' do
17
17
  context "when a task is not executed" do
18
18
  it "does not call the system" do
19
19
  expect_no_system_call
20
- @task = fsc :build
20
+ @task = fsc "dummy.exe"
21
21
  end
22
22
  end
23
23
 
24
24
  describe "command line args" do
25
25
  before :each do
26
- expect_compiler_call { |opts| @opts = opts }
26
+ expect_compiler_call do |opts|
27
+ @opts = opts
28
+ end
27
29
  end
28
30
 
29
31
  let :options do
30
- invoke_fsc_task do |t|
31
- t.output_file = "dummy.exe" # in case test doesn't set one up
32
+ task = fsc "dummy.exe" do |t|
32
33
  @setup.call(t) if @setup
33
34
  end
35
+ task.invoke
34
36
  @opts
35
37
  end
36
38
 
@@ -90,20 +92,11 @@ describe 'fsharp' do
90
92
 
91
93
  describe "output" do
92
94
  it "sets the output file" do
93
- @setup = lambda do |t|
94
- t.output_folder = "f"
95
- t.output_file = "p.exe"
96
- end
97
- expect(options.out).to eq("f/p.exe")
98
- end
99
- end
100
-
101
- context "when folder not specified" do
102
- it "sets the output file" do
103
- @setup = lambda do |t|
104
- t.output_file = "p.exe"
95
+ task = fsc "f/p.exe" do |t|
96
+ @setup.call(t) if @setup
105
97
  end
106
- expect(options.out).to eq("p.exe")
98
+ task.invoke
99
+ expect(@opts.out).to eq("f/p.exe")
107
100
  end
108
101
  end
109
102
 
@@ -112,24 +105,24 @@ describe 'fsharp' do
112
105
  it "calls the compiler", :focus => true do
113
106
  FileUtils.touch('./p.exe')
114
107
  FileUtils.touch('s.fs')
115
- @setup = lambda do |t|
108
+ task = fsc "p.exe" do |t|
116
109
  t.target = :exe
117
- t.output_file = "p.exe"
118
110
  t.source_files = ["s.fs"]
119
111
  end
120
- expect(options).to_not be_nil
112
+ task.invoke
113
+ expect(@opts).to_not be_nil
121
114
  end
122
115
  end
123
116
  context "build output is newer than source files" do
124
117
  it "does not call the compiler", :focus => true do
125
118
  FileUtils.touch('s.fs')
126
119
  FileUtils.touch('./p.exe')
127
- @setup = lambda do |t|
120
+ task = fsc "p.exe" do |t|
128
121
  t.target = :exe
129
- t.output_file = "p.exe"
130
122
  t.source_files = ["s.fs"]
131
123
  end
132
- expect(options).to be_nil
124
+ task.invoke
125
+ expect(@opts).to be_nil
133
126
  end
134
127
  end
135
128
  end
@@ -138,11 +131,11 @@ describe 'fsharp' do
138
131
  describe "target type" do
139
132
  it "fails when using invalid target option" do
140
133
  op = lambda do
141
- invoke_fsc_task do |t|
134
+ task = fsc "p.exe" do |t|
142
135
  t.target = :invalid_option
143
136
  end
144
137
  end
145
- expect(op).to raise_error
138
+ expect(op).to raise_error(/^Invalid target/)
146
139
  end
147
140
  end
148
141
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skipjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Strøiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-08 00:00:00.000000000 Z
11
+ date: 2016-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler