jim 0.1.0
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.
- data/.document +5 -0
- data/.gitignore +22 -0
- data/LICENSE +20 -0
- data/README.rdoc +87 -0
- data/Rakefile +59 -0
- data/bin/jim +6 -0
- data/jim.gemspec +83 -0
- data/lib/jim.rb +31 -0
- data/lib/jim/bundler.rb +102 -0
- data/lib/jim/cli.rb +143 -0
- data/lib/jim/index.rb +70 -0
- data/lib/jim/installer.rb +120 -0
- data/lib/jim/rack.rb +44 -0
- data/lib/jim/templates/commands +43 -0
- data/lib/jim/templates/jimfile +6 -0
- data/lib/jim/version_parser.rb +27 -0
- data/test/fixtures/infoincomments.js +4 -0
- data/test/fixtures/jimfile +7 -0
- data/test/fixtures/jquery-1.4.1.js +6078 -0
- data/test/fixtures/jquery.color.js +128 -0
- data/test/fixtures/jquery.metadata-2.0.zip +0 -0
- data/test/fixtures/mustache.js/mustache.js +1 -0
- data/test/fixtures/mustache.js/package.json +7 -0
- data/test/fixtures/noversion.js +1 -0
- data/test/helper.rb +38 -0
- data/test/test_jim_bundler.rb +151 -0
- data/test/test_jim_cli.rb +71 -0
- data/test/test_jim_index.rb +97 -0
- data/test/test_jim_installer.rb +119 -0
- data/test/test_jim_version_parser.rb +48 -0
- metadata +109 -0
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestJimInstaller < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Jim::Installer" do
|
6
|
+
setup do
|
7
|
+
# clear the tmp dir
|
8
|
+
FileUtils.rm_rf(tmp_path) if File.directory?(tmp_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
context "initializing" do
|
12
|
+
setup do
|
13
|
+
@installer = Jim::Installer.new('fetchpath', 'installpath', {:version => '1.1'})
|
14
|
+
end
|
15
|
+
|
16
|
+
should "set fetch path" do
|
17
|
+
assert_equal Pathname.new('fetchpath'), @installer.fetch_path
|
18
|
+
end
|
19
|
+
|
20
|
+
should "set install path" do
|
21
|
+
assert_equal Pathname.new('installpath'), @installer.install_path
|
22
|
+
end
|
23
|
+
|
24
|
+
should "set options" do
|
25
|
+
assert_equal({:version => '1.1'}, @installer.options)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "fetch" do
|
31
|
+
setup do
|
32
|
+
@url = "http://jquery.com/download/jquery-1.4.1.js"
|
33
|
+
FakeWeb.register_uri(:get, @url, :body => fixture('jquery-1.4.1.js'))
|
34
|
+
end
|
35
|
+
|
36
|
+
should "fetch remote file" do
|
37
|
+
installer = Jim::Installer.new(@url, tmp_path)
|
38
|
+
assert installer.fetch
|
39
|
+
end
|
40
|
+
|
41
|
+
should "fetch local file" do
|
42
|
+
installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path)
|
43
|
+
fetched_path = installer.fetch
|
44
|
+
assert_dir fetched_path.dirname
|
45
|
+
assert_equal 'jquery-1.4.1.js', fetched_path.basename.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
context "determine_name_and_version" do
|
51
|
+
|
52
|
+
should "determine from filename" do
|
53
|
+
installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path)
|
54
|
+
assert installer.fetch
|
55
|
+
assert installer.determine_name_and_version
|
56
|
+
assert_equal '1.4.1', installer.version
|
57
|
+
assert_equal 'jquery', installer.name
|
58
|
+
end
|
59
|
+
|
60
|
+
should "determine from package.json" do
|
61
|
+
installer = Jim::Installer.new(fixture_path('mustache.js'), tmp_path)
|
62
|
+
assert installer.fetch
|
63
|
+
assert installer.determine_name_and_version
|
64
|
+
assert_equal "0.2.2", installer.version
|
65
|
+
assert_equal "mustache", installer.name
|
66
|
+
end
|
67
|
+
|
68
|
+
should "determine from file comments" do
|
69
|
+
installer = Jim::Installer.new(fixture_path('infoincomments.js'), tmp_path)
|
70
|
+
assert installer.fetch
|
71
|
+
assert installer.determine_name_and_version
|
72
|
+
assert_equal 'myproject', installer.name
|
73
|
+
assert_equal '1.2.2', installer.version
|
74
|
+
end
|
75
|
+
|
76
|
+
should "determine from options" do
|
77
|
+
installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path, :name => 'myproject', :version => '1.1.1')
|
78
|
+
assert installer.fetch
|
79
|
+
assert installer.determine_name_and_version
|
80
|
+
assert_equal 'myproject', installer.name
|
81
|
+
assert_equal '1.1.1', installer.version
|
82
|
+
end
|
83
|
+
|
84
|
+
should "have default version if version can not be determined" do
|
85
|
+
installer = Jim::Installer.new(fixture_path('noversion.js'), tmp_path)
|
86
|
+
assert installer.fetch
|
87
|
+
assert installer.determine_name_and_version
|
88
|
+
assert_equal 'noversion', installer.name
|
89
|
+
assert_equal '0', installer.version
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
context "install" do
|
95
|
+
|
96
|
+
should "move file into install path at name/version" do
|
97
|
+
installer = Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path)
|
98
|
+
assert installer.install
|
99
|
+
install_path = File.join(tmp_path, 'lib', 'jquery-1.4.1')
|
100
|
+
assert_dir install_path
|
101
|
+
assert_readable install_path, 'jquery.js'
|
102
|
+
assert_equal fixture('jquery-1.4.1.js'), File.read(File.join(install_path, 'jquery.js'))
|
103
|
+
end
|
104
|
+
|
105
|
+
should "install zips" do
|
106
|
+
@url = "http://jquery.com/download/jquery.metadata-2.0.zip"
|
107
|
+
FakeWeb.register_uri(:get, @url, :body => fixture('jquery.metadata-2.0.zip'))
|
108
|
+
installer = Jim::Installer.new(@url, tmp_path)
|
109
|
+
path = installer.install
|
110
|
+
# puts Dir.glob(path + '**/**').inspect
|
111
|
+
assert_dir path
|
112
|
+
assert_dir path + 'jquery.metadata-2.0.zip'
|
113
|
+
assert_readable path + 'jquery.metadata-2.0.zip' + 'jquery.metadata.2.0' +'jquery.metadata.js'
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestJimVersionParser < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Jim::VersionParser" do
|
6
|
+
|
7
|
+
context ".parse_filename" do
|
8
|
+
should "parse filenames'" do
|
9
|
+
[
|
10
|
+
["sammy-0.1.0", ["sammy", "0.1.0"]],
|
11
|
+
["sammy_0.1.0", ["sammy", "0.1.0"]],
|
12
|
+
["sammy-1", ["sammy", "1"]],
|
13
|
+
["sammy_1", ["sammy", "1"]],
|
14
|
+
["sammy.1.0", ["sammy", "1.0"]],
|
15
|
+
["sammy.1.0.1", ["sammy", "1.0.1"]],
|
16
|
+
["sammy.1.0.1.min", ["sammy", "1.0.1.min"]],
|
17
|
+
["sammy-1.0.1.min", ["sammy", "1.0.1.min"]],
|
18
|
+
["sammy.plugin-1.0.1.min", ["sammy.plugin", "1.0.1.min"]],
|
19
|
+
["sammy.plugin.1.0.1", ["sammy.plugin", "1.0.1"]],
|
20
|
+
["sammy.plugin_1.0.1", ["sammy.plugin", "1.0.1"]],
|
21
|
+
["sammy.plugin.1.0.1pre", ["sammy.plugin", "1.0.1pre"]],
|
22
|
+
["sammy.plugin-1.0.1beta", ["sammy.plugin", "1.0.1beta"]],
|
23
|
+
["sammy.plugin.1.0.1.pre", ["sammy.plugin", "1.0.1.pre"]],
|
24
|
+
["sammy.plugin-1.0.1.beta", ["sammy.plugin", "1.0.1.beta"]],
|
25
|
+
["sammy 1.0.1", ["sammy", "1.0.1"]],
|
26
|
+
["sammy.plugin.1.0.1.js", ["sammy.plugin", "1.0.1"]],
|
27
|
+
["sammy.plugin.1.0.1.zip", ["sammy.plugin", "1.0.1"]],
|
28
|
+
["sammy.plugin.1.0.1", ["sammy.plugin", "1.0.1"]],
|
29
|
+
# ["sammy.plugin-a9asb02", ["sammy.plugin", "a9asb02"]],
|
30
|
+
["sammy-9asb02", ["sammy", "9asb02"]],
|
31
|
+
["noversion.js", ["noversion", "0"]]
|
32
|
+
].each do |name, result|
|
33
|
+
assert_equal result, Jim::VersionParser.parse_filename(name), "Should parse #{name} to #{result.inspect}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
context ".parse_package_json" do
|
40
|
+
|
41
|
+
should "parse version and name from file" do
|
42
|
+
assert_equal ["mustache", "0.2.2"], Jim::VersionParser.parse_package_json(fixture('mustache.js/package.json'))
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jim
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Quint
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-19 00:00:00 -05:00
|
13
|
+
default_executable: jim
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: downlow
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.1.1
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: shoulda
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: jim is your friendly javascript library manager. He downloads, stores, bundles, vendors and compresses.
|
36
|
+
email: aaron@quirkey.com
|
37
|
+
executables:
|
38
|
+
- jim
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- bin/jim
|
51
|
+
- jim.gemspec
|
52
|
+
- lib/jim.rb
|
53
|
+
- lib/jim/bundler.rb
|
54
|
+
- lib/jim/cli.rb
|
55
|
+
- lib/jim/index.rb
|
56
|
+
- lib/jim/installer.rb
|
57
|
+
- lib/jim/rack.rb
|
58
|
+
- lib/jim/templates/commands
|
59
|
+
- lib/jim/templates/jimfile
|
60
|
+
- lib/jim/version_parser.rb
|
61
|
+
- test/fixtures/infoincomments.js
|
62
|
+
- test/fixtures/jimfile
|
63
|
+
- test/fixtures/jquery-1.4.1.js
|
64
|
+
- test/fixtures/jquery.color.js
|
65
|
+
- test/fixtures/jquery.metadata-2.0.zip
|
66
|
+
- test/fixtures/mustache.js/mustache.js
|
67
|
+
- test/fixtures/mustache.js/package.json
|
68
|
+
- test/fixtures/noversion.js
|
69
|
+
- test/helper.rb
|
70
|
+
- test/test_jim_bundler.rb
|
71
|
+
- test/test_jim_cli.rb
|
72
|
+
- test/test_jim_index.rb
|
73
|
+
- test/test_jim_installer.rb
|
74
|
+
- test/test_jim_version_parser.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/quirkey/jim
|
77
|
+
licenses: []
|
78
|
+
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options:
|
81
|
+
- --charset=UTF-8
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
version:
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
requirements: []
|
97
|
+
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.3.5
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: jim is your friendly javascript library manager
|
103
|
+
test_files:
|
104
|
+
- test/helper.rb
|
105
|
+
- test/test_jim_bundler.rb
|
106
|
+
- test/test_jim_cli.rb
|
107
|
+
- test/test_jim_index.rb
|
108
|
+
- test/test_jim_installer.rb
|
109
|
+
- test/test_jim_version_parser.rb
|