Permalink
Browse files

module names keep extensions

  • Loading branch information...
Jigish Patel
Jigish Patel committed Apr 26, 2012
1 parent 77797e6 commit 2ea12eaafe6db8e246361fc55dba5058483d9e62
View
@@ -44,7 +44,7 @@ Ruby Quilt is a simple way to stitch files together. [Ruby Quilt on github](http
}
}
-Where each `<module file>` will point to a module to stitch. The filename should be `<module name>.js`
+Where each `<module file>` will point to a module to stitch. The filename should be `<module name>`
The modules will be stitched in the following order:
View
@@ -43,7 +43,7 @@ def log_debug(msg)
def get_module_name(filename)
return nil unless filename
- matches = filename.match(/(^.*\/|^)(.+)\.[^.]+$/)
+ matches = filename.match(/(^.*\/|^)([^\/]+)$/)
return nil unless matches && matches.length >= 3
matches[2]
end
@@ -127,14 +127,14 @@ def load_version(local_path, version_name)
end
if manifest[OPTIONAL_KEY] && manifest[OPTIONAL_KEY].is_a?(Hash)
manifest[OPTIONAL_KEY].each do |filename, dependancies|
- tmp_module = get_module(filename, dependancies, dir)
- if (tmp_module)
- tmp_module_name = get_module_name(filename)
- if (tmp_module_name)
+ tmp_module_name = get_module_name(filename)
+ if (tmp_module_name)
+ tmp_module = get_module(filename, dependancies, dir)
+ if (tmp_module)
new_version[prefix][:optional][tmp_module_name] = tmp_module
- else
- log_error(" Could not extract #{prefix.to_s} module name from: #{filename}")
end
+ else
+ log_error(" Could not extract #{prefix.to_s} module name from: #{filename}")
end
end
end
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'ruby-quilt'
- s.version = '0.0.6'
+ s.version = '0.0.7'
s.summary = "A File stitcher"
s.description = "A file stitcher that maintains versions and can fetch additional versions from a server."
s.authors = ["Jigish Patel"]
@@ -6,9 +6,9 @@
"./common/c2.js"
],
"optional": {
- "./optional/0.js": [ "8" ],
- "./1.js": [ "7", "9" ],
- "2.js": [ "8" ],
+ "./optional/0.js": [ "8.js" ],
+ "./1.js": [ "7.js", "9.js" ],
+ "2.js": [ "8.js" ],
"./3.js": [],
"./4.js": [],
"./5.js": [],
@@ -17,6 +17,6 @@
"./8.js": [],
"./9.js": [],
"./optional.js": [],
- "./badname": []
+ "./": []
}
}
@@ -5,9 +5,9 @@
"./common/c.js"
],
"optional": {
- "./optional/0.js": [ "8" ],
- "./1.js": [ "7", "9" ],
- "2.js": [ "8" ],
+ "./optional/0.js": [ "8.js" ],
+ "./1.js": [ "7.js", "9.js" ],
+ "2.js": [ "8.js" ],
"./3.js": [],
"./4.js": [],
"./5.js": [],
View
Binary file not shown.
Binary file not shown.
View
@@ -94,33 +94,30 @@ class QuiltTest < Scope::TestCase
assert_nil name
name = @quilt.get_module_name("")
assert_nil name
- name = @quilt.get_module_name("hello")
assert_nil name
- name = @quilt.get_module_name("/hello")
+ name = @quilt.get_module_name("/")
assert_nil name
- name = @quilt.get_module_name("./hello")
+ name = @quilt.get_module_name("./")
assert_nil name
- name = @quilt.get_module_name("hello/hello")
+ name = @quilt.get_module_name("/hello/")
assert_nil name
- name = @quilt.get_module_name("/hello/hello")
- assert_nil name
- name = @quilt.get_module_name("./hello/hello")
+ name = @quilt.get_module_name("./hello/")
assert_nil name
end
should "return a valid name for good file names" do
name = @quilt.get_module_name("hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
name = @quilt.get_module_name("/hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
name = @quilt.get_module_name("./hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
name = @quilt.get_module_name("hi/hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
name = @quilt.get_module_name("/hi/hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
name = @quilt.get_module_name("./hi/hello.js")
- assert_equal "hello", name
+ assert_equal "hello.js", name
end
end
@@ -131,9 +128,9 @@ class QuiltTest < Scope::TestCase
end
should "return the module if the module does exist" do
- mod = @quilt.get_module("optional/0.js", ["1"], File.dirname(__FILE__) + "/mock/good_project/1.0.0/")
+ mod = @quilt.get_module("optional/0.js", ["1.js"], File.dirname(__FILE__) + "/mock/good_project/1.0.0/")
assert mod
- assert_equal ["1"], mod[:dependancies]
+ assert_equal ["1.js"], mod[:dependancies]
assert_equal "0\n", mod[:module]
end
@@ -149,9 +146,9 @@ class QuiltTest < Scope::TestCase
end
should "handle a single dependancy as a string" do
- mod = @quilt.get_module("optional/0.js", "1", File.dirname(__FILE__) + "/mock/good_project/1.0.0/")
+ mod = @quilt.get_module("optional/0.js", "1.js", File.dirname(__FILE__) + "/mock/good_project/1.0.0/")
assert mod
- assert_equal ["1"], mod[:dependancies]
+ assert_equal ["1.js"], mod[:dependancies]
assert_equal "0\n", mod[:module]
end
end
@@ -167,16 +164,16 @@ class QuiltTest < Scope::TestCase
assert version
assert_equal "h\nc\n", version[:default][:base]
expected = {
- "0" => { :dependancies => [ "8" ], :module => "0\n" },
- "1" => { :dependancies => [ "7", "9" ], :module => "1\n" },
- "2" => { :dependancies => [ "8" ], :module => "2\n" },
- "3" => { :dependancies => [], :module => "3\n" },
- "4" => { :dependancies => [], :module => "4\n" },
- "5" => { :dependancies => [], :module => "5\n" },
- "6" => { :dependancies => [], :module => "6\n" },
- "7" => { :dependancies => [], :module => "7\n" },
- "8" => { :dependancies => [], :module => "8\n" },
- "9" => { :dependancies => [], :module => "9\n" }
+ "0.js" => { :dependancies => [ "8.js" ], :module => "0\n" },
+ "1.js" => { :dependancies => [ "7.js", "9.js" ], :module => "1\n" },
+ "2.js" => { :dependancies => [ "8.js" ], :module => "2\n" },
+ "3.js" => { :dependancies => [], :module => "3\n" },
+ "4.js" => { :dependancies => [], :module => "4\n" },
+ "5.js" => { :dependancies => [], :module => "5\n" },
+ "6.js" => { :dependancies => [], :module => "6\n" },
+ "7.js" => { :dependancies => [], :module => "7\n" },
+ "8.js" => { :dependancies => [], :module => "8\n" },
+ "9.js" => { :dependancies => [], :module => "9\n" }
}
assert_equal expected, version[:default][:optional]
assert_equal version[:default][:footer], "f1.0.0\n"
@@ -187,16 +184,16 @@ class QuiltTest < Scope::TestCase
assert version
assert_equal "c\n", version[:default][:base]
expected = {
- "0" => { :dependancies => [ "8" ], :module => "0\n" },
- "1" => { :dependancies => [ "7", "9" ], :module => "1\n" },
- "2" => { :dependancies => [ "8" ], :module => "2\n" },
- "3" => { :dependancies => [], :module => "3\n" },
- "4" => { :dependancies => [], :module => "4\n" },
- "5" => { :dependancies => [], :module => "5\n" },
- "6" => { :dependancies => [], :module => "6\n" },
- "7" => { :dependancies => [], :module => "7\n" },
- "8" => { :dependancies => [], :module => "8\n" },
- "9" => { :dependancies => [], :module => "9\n" }
+ "0.js" => { :dependancies => [ "8.js" ], :module => "0\n" },
+ "1.js" => { :dependancies => [ "7.js", "9.js" ], :module => "1\n" },
+ "2.js" => { :dependancies => [ "8.js" ], :module => "2\n" },
+ "3.js" => { :dependancies => [], :module => "3\n" },
+ "4.js" => { :dependancies => [], :module => "4\n" },
+ "5.js" => { :dependancies => [], :module => "5\n" },
+ "6.js" => { :dependancies => [], :module => "6\n" },
+ "7.js" => { :dependancies => [], :module => "7\n" },
+ "8.js" => { :dependancies => [], :module => "8\n" },
+ "9.js" => { :dependancies => [], :module => "9\n" }
}
assert_equal expected, version[:default][:optional]
assert_nil version[:default][:footer]
@@ -209,16 +206,16 @@ class QuiltTest < Scope::TestCase
:default => {
:base => "h\nc\n",
:optional => {
- "0" => { :dependancies => [ "8" ], :module => "0\n" },
- "1" => { :dependancies => [ "7", "9" ], :module => "1\n" },
- "2" => { :dependancies => [ "8" ], :module => "2\n" },
- "3" => { :dependancies => [], :module => "3\n" },
- "4" => { :dependancies => [], :module => "4\n" },
- "5" => { :dependancies => [ "6" ], :module => "5\n" },
- "6" => { :dependancies => [ "5" ], :module => "6\n" },
- "7" => { :dependancies => [], :module => "7\n" },
- "8" => { :dependancies => [ "9" ], :module => "8\n" },
- "9" => { :dependancies => [], :module => "9\n" }
+ "0.js" => { :dependancies => [ "8.js" ], :module => "0\n" },
+ "1.js" => { :dependancies => [ "7.js", "9.js" ], :module => "1\n" },
+ "2.js" => { :dependancies => [ "8.js" ], :module => "2\n" },
+ "3.js" => { :dependancies => [], :module => "3\n" },
+ "4.js" => { :dependancies => [], :module => "4\n" },
+ "5.js" => { :dependancies => [ "6.js" ], :module => "5\n" },
+ "6.js" => { :dependancies => [ "5.js" ], :module => "6\n" },
+ "7.js" => { :dependancies => [], :module => "7\n" },
+ "8.js" => { :dependancies => [ "9.js" ], :module => "8\n" },
+ "9.js" => { :dependancies => [], :module => "9\n" }
}
}
}
@@ -236,17 +233,17 @@ class QuiltTest < Scope::TestCase
end
should "resolve dependancies" do
- out = @quilt.resolve_dependancies([ "0", "1", "2" ], @version[:default]);
+ out = @quilt.resolve_dependancies([ "0.js", "1.js", "2.js" ], @version[:default]);
assert_equal "9\n8\n0\n7\n1\n2\n", out
end
should "gracefully handle circular dependancies" do
- out = @quilt.resolve_dependancies([ "5" ], @version[:default]);
+ out = @quilt.resolve_dependancies([ "5.js" ], @version[:default]);
assert_equal "6\n5\n", out
end
should "gracefully handle non-existant modules" do
- out = @quilt.resolve_dependancies([ "5", "oogabooga" ], @version[:default]);
+ out = @quilt.resolve_dependancies([ "5.js", "oogabooga" ], @version[:default]);
assert_equal "6\n5\n", out
end
end
@@ -262,16 +259,16 @@ class QuiltTest < Scope::TestCase
assert version
assert_equal "h\nc\n", version[:default][:base]
expected = {
- "0" => { :dependancies => [ "8" ], :module => "0\n" },
- "1" => { :dependancies => [ "7", "9" ], :module => "1\n" },
- "2" => { :dependancies => [ "8" ], :module => "2\n" },
- "3" => { :dependancies => [], :module => "3\n" },
- "4" => { :dependancies => [], :module => "4\n" },
- "5" => { :dependancies => [], :module => "5\n" },
- "6" => { :dependancies => [], :module => "6\n" },
- "7" => { :dependancies => [], :module => "7\n" },
- "8" => { :dependancies => [], :module => "8\n" },
- "9" => { :dependancies => [], :module => "9\n" }
+ "0.js" => { :dependancies => [ "8.js" ], :module => "0\n" },
+ "1.js" => { :dependancies => [ "7.js", "9.js" ], :module => "1\n" },
+ "2.js" => { :dependancies => [ "8.js" ], :module => "2\n" },
+ "3.js" => { :dependancies => [], :module => "3\n" },
+ "4.js" => { :dependancies => [], :module => "4\n" },
+ "5.js" => { :dependancies => [], :module => "5\n" },
+ "6.js" => { :dependancies => [], :module => "6\n" },
+ "7.js" => { :dependancies => [], :module => "7\n" },
+ "8.js" => { :dependancies => [], :module => "8\n" },
+ "9.js" => { :dependancies => [], :module => "9\n" }
}
assert_equal expected, version[:default][:optional]
assert_equal "f1.0.0\n", version[:default][:footer]
@@ -282,16 +279,16 @@ class QuiltTest < Scope::TestCase
assert version
assert_equal "h\nc\n", version[:default][:base]
expected = {
- "0" => { :dependancies => [ "8" ], :module => "0\n" },
- "1" => { :dependancies => [ "7", "9" ], :module => "1\n" },
- "2" => { :dependancies => [ "8" ], :module => "2\n" },
- "3" => { :dependancies => [], :module => "3\n" },
- "4" => { :dependancies => [], :module => "4\n" },
- "5" => { :dependancies => [], :module => "5\n" },
- "6" => { :dependancies => [], :module => "6\n" },
- "7" => { :dependancies => [], :module => "7\n" },
- "8" => { :dependancies => [], :module => "8\n" },
- "9" => { :dependancies => [], :module => "9\n" }
+ "0.js" => { :dependancies => [ "8.js" ], :module => "0\n" },
+ "1.js" => { :dependancies => [ "7.js", "9.js" ], :module => "1\n" },
+ "2.js" => { :dependancies => [ "8.js" ], :module => "2\n" },
+ "3.js" => { :dependancies => [], :module => "3\n" },
+ "4.js" => { :dependancies => [], :module => "4\n" },
+ "5.js" => { :dependancies => [], :module => "5\n" },
+ "6.js" => { :dependancies => [], :module => "6\n" },
+ "7.js" => { :dependancies => [], :module => "7\n" },
+ "8.js" => { :dependancies => [], :module => "8\n" },
+ "9.js" => { :dependancies => [], :module => "9\n" }
}
assert_equal expected, version[:default][:optional]
assert_equal "f2.0.0\n", version[:default][:footer]
@@ -317,11 +314,11 @@ class QuiltTest < Scope::TestCase
context "stitch" do
should "return empty for a non-existant version when no remote information exists" do
- assert_equal '', @no_remote_quilt.stitch(['0'], '2.0.0')
+ assert_equal '', @no_remote_quilt.stitch(['0.js'], '2.0.0')
end
should "properly stitch for an existing version with selector array" do
- assert_equal "h\nc\n8\n0\nf1.0.0\n", @no_remote_quilt.stitch(['0'], '1.0.0')
+ assert_equal "h\nc\n8\n0\nf1.0.0\n", @no_remote_quilt.stitch(['0.js'], '1.0.0')
end
should "properly stitch for an existing version with selector function" do
@@ -331,7 +328,7 @@ class QuiltTest < Scope::TestCase
end
should "properly stitch for remote version with selector array" do
- assert_equal "h\nc\n8\n0\nf2.0.0\n", @quilt.stitch(['0'], '2.0.0')
+ assert_equal "h\nc\n8\n0\nf2.0.0\n", @quilt.stitch(['0.js'], '2.0.0')
`rm -rf #{File.join(File.dirname(__FILE__), "mock", "good_project", "2.0.0")}`
end
@@ -343,12 +340,12 @@ class QuiltTest < Scope::TestCase
end
should "properly stitch for debug version" do
- assert_equal "h\nc\n8\n0\nf1.0.0-debug\n", @quilt.stitch(['0'], 'hasdebug', :debug)
+ assert_equal "h\nc\n8\n0\nf1.0.0-debug\n", @quilt.stitch(['0.js'], 'hasdebug', :debug)
`rm -rf #{File.join(File.dirname(__FILE__), "mock", "good_project", "hasdebug")}`
end
should "fallback to non-debug if debug does not exist" do
- assert_equal "h\nc\n8\n0\nf1.0.0\n", @no_remote_quilt.stitch(['0'], '1.0.0', :debug)
+ assert_equal "h\nc\n8\n0\nf1.0.0\n", @no_remote_quilt.stitch(['0.js'], '1.0.0', :debug)
end
end
end

0 comments on commit 2ea12ea

Please sign in to comment.