mortar 0.15.13 → 0.15.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mortar/project.rb +13 -3
- data/lib/mortar/templates/script/runpig.sh +3 -0
- data/lib/mortar/version.rb +1 -1
- data/spec/mortar/project_spec.rb +12 -1
- data/spec/spec_helper.rb +9 -0
- metadata +2 -2
data/lib/mortar/project.rb
CHANGED
@@ -142,7 +142,17 @@ module Mortar
|
|
142
142
|
if File.directory? @path
|
143
143
|
# get {script_name => full_path}
|
144
144
|
file_paths = Dir[File.join(@path, "**", "*#{@filename_extension}")]
|
145
|
-
|
145
|
+
|
146
|
+
scripts = file_paths.collect{|element_path| [element_name(element_path), element(element_name(element_path), element_path)]}
|
147
|
+
|
148
|
+
#Check for duplicates.
|
149
|
+
name_groups = scripts.group_by{ |x| x[0] }
|
150
|
+
duplicates = name_groups.find_all{ |k,v| v.length > 1 }
|
151
|
+
if duplicates.length > 0
|
152
|
+
raise ProjectError, "Multiple scripts found with the same name. Each script must have a unique name regardless of what directory it is in. Duplicate script names found: #{duplicates.collect{|d| d[0]}}"
|
153
|
+
end
|
154
|
+
|
155
|
+
file_paths_hsh = scripts.flatten
|
146
156
|
return Hash[*file_paths_hsh]
|
147
157
|
else
|
148
158
|
raise ProjectError, "Unable to find #{@name} directory in project" if not @optional
|
@@ -217,7 +227,7 @@ module Mortar
|
|
217
227
|
class ControlScript < Script
|
218
228
|
|
219
229
|
def executable_path
|
220
|
-
"
|
230
|
+
"#{self.rel_path}/#{self.name}.pig"
|
221
231
|
end
|
222
232
|
|
223
233
|
end
|
@@ -225,7 +235,7 @@ module Mortar
|
|
225
235
|
class PigScript < Script
|
226
236
|
|
227
237
|
def executable_path
|
228
|
-
"
|
238
|
+
"#{self.rel_path}/#{self.name}.pig"
|
229
239
|
end
|
230
240
|
|
231
241
|
end
|
@@ -7,6 +7,9 @@ export PIG_CLASSPATH=<%= @pig_classpath %>
|
|
7
7
|
export CLASSPATH=<%= @classpath %>
|
8
8
|
export PIG_MAIN_CLASS=com.mortardata.hawk.HawkMain
|
9
9
|
export PIG_OPTS="<% @pig_opts.each do |k,v| %>-D<%= k %>=<%= v %> <% end %>"
|
10
|
+
#Uncomment to debug pig code
|
11
|
+
#export PIG_OPTS="$PIG_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000"
|
12
|
+
|
10
13
|
|
11
14
|
# UDF paths are relative to this direectory
|
12
15
|
if [ -d "<%= @project_home %>/pigscripts" ]; then
|
data/lib/mortar/version.rb
CHANGED
data/spec/mortar/project_spec.rb
CHANGED
@@ -64,7 +64,7 @@ module Mortar
|
|
64
64
|
write_file pigscript_path
|
65
65
|
p.pigscripts.my_script.name.should == "my_script"
|
66
66
|
p.pigscripts.my_script.path.should == pigscript_path
|
67
|
-
p.pigscripts.my_script.executable_path.
|
67
|
+
p.pigscripts.my_script.executable_path.end_with?("pigscripts/my_script.pig")
|
68
68
|
p.pigscripts.my_script.rel_path.end_with?('pigscripts').should be_true
|
69
69
|
end
|
70
70
|
end
|
@@ -78,6 +78,17 @@ module Mortar
|
|
78
78
|
p.pigscripts.my_script.rel_path.end_with?("pigscripts/subdir").should be_true
|
79
79
|
end
|
80
80
|
end
|
81
|
+
|
82
|
+
it "throws error on duplicate script stored in a subdirectory" do
|
83
|
+
with_blank_project do |p|
|
84
|
+
pigscript_path = File.join(p.pigscripts_path, "my_script.pig")
|
85
|
+
write_file pigscript_path
|
86
|
+
pigscript_path = File.join(p.pigscripts_path, "subdir", "my_script.pig")
|
87
|
+
write_file pigscript_path
|
88
|
+
|
89
|
+
lambda { p.pigscripts }.should raise_error(Mortar::Project::ProjectError)
|
90
|
+
end
|
91
|
+
end
|
81
92
|
|
82
93
|
it "finds multiple scripts in subdirectories with the same name" do
|
83
94
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -56,6 +56,15 @@ def execute_and_return_command(command_line, project=nil, git=nil)
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
# stub the relative paths which get messed up in tests
|
60
|
+
any_instance_of(Mortar::Project::PigScript) do |s|
|
61
|
+
stub(s).rel_path.returns('pigscripts')
|
62
|
+
end
|
63
|
+
any_instance_of(Mortar::Project::ControlScript) do |s|
|
64
|
+
stub(s).rel_path.returns('controlscripts')
|
65
|
+
end
|
66
|
+
|
67
|
+
|
59
68
|
# stub git
|
60
69
|
if git
|
61
70
|
# stub out any operations that affect remote resources
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mortar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.14
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|