jim 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ pkg
20
20
  tmp
21
21
 
22
22
  ## PROJECT::SPECIFIC
23
+ *.rbc
data/HISTORY CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.1 [07-06-10]
2
+
3
+ * Local (non JIMHOME) files specified in the Jimfiles are not copied into vendor
4
+ * jim list and available now take an option search param
5
+
1
6
  == 0.2.0 [03-16-10]
2
7
 
3
8
  * Major rewrite of the installer and version parser
data/jim.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jim}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = %q{2010-03-16}
12
+ s.date = %q{2010-07-06}
13
13
  s.default_executable = %q{jim}
14
14
  s.description = %q{jim is your friendly javascript library manager. He downloads, stores, bundles, vendors and compresses.}
15
15
  s.email = %q{aaron@quirkey.com}
@@ -40,6 +40,7 @@ Gem::Specification.new do |s|
40
40
  "test/fixtures/jquery-1.4.1.js",
41
41
  "test/fixtures/jquery.color.js",
42
42
  "test/fixtures/jquery.metadata-2.0.zip",
43
+ "test/fixtures/localfile.js",
43
44
  "test/fixtures/mustache.js/mustache.js",
44
45
  "test/fixtures/mustache.js/package.json",
45
46
  "test/fixtures/noversion.js",
data/lib/jim/bundler.rb CHANGED
@@ -83,7 +83,9 @@ module Jim
83
83
  dir ||= 'vendor' # default
84
84
  logger.info "Vendoring to #{dir}"
85
85
  paths.each do |path, name, version|
86
- Jim::Installer.new(path, dir, :shallow => true, :force => force).install
86
+ if index.in_jimhome?(path)
87
+ Jim::Installer.new(path, dir, :shallow => true, :force => force).install
88
+ end
87
89
  end
88
90
  end
89
91
 
data/lib/jim/cli.rb CHANGED
@@ -94,20 +94,24 @@ module Jim
94
94
  bundler.vendor!(dir, force)
95
95
  end
96
96
 
97
- # list the only the _installed_ projects and versions
98
- def list
97
+ # list the only the _installed_ projects and versions.
98
+ # Match names against `search` if supplied.
99
+ def list(search = nil)
99
100
  logger.info "Getting list of installed files in\n#{installed_index.directories.join(':')}"
100
- list = installed_index.list
101
+ logger.info "Searching for '#{search}'" if search
102
+ list = installed_index.list(search)
101
103
  logger.info "Installed:"
102
104
  print_version_list(list)
103
105
  end
104
106
  alias :installed :list
105
107
 
106
108
  # list all available projects and versions including those in the local path, or
107
- # paths specified in a jimfile
108
- def available
109
+ # paths specified in a Jimfile.
110
+ # Match names against `search` if supplied.
111
+ def available(search = nil)
109
112
  logger.info "Getting list of all available files in\n#{index.directories.join("\n")}"
110
- list = index.list
113
+ logger.info "Searching for '#{search}'" if search
114
+ list = index.list(search)
111
115
  logger.info "Available:"
112
116
  print_version_list(list)
113
117
  end
@@ -226,7 +230,7 @@ module Jim
226
230
 
227
231
  def print_version_list(list)
228
232
  list.each do |file, versions|
229
- logger.info "#{file} (#{VersionSorter.rsort(versions.collect {|v| v[0] }).join(',')})"
233
+ logger.info "#{file} (#{VersionSorter.rsort(versions.collect {|v| v[0] }).join(', ')})"
230
234
  end
231
235
  end
232
236
 
data/lib/jim/index.rb CHANGED
@@ -4,14 +4,15 @@ module Jim
4
4
  attr_reader :directories
5
5
 
6
6
  def initialize(*directories)
7
- @directories = directories.flatten.compact
7
+ @directories = [directories].flatten.compact
8
+ @jimhome_re = /#{Pathname.new(@directories.first).expand_path.to_s}/
8
9
  end
9
10
 
10
11
  def add(directory)
11
12
  @directories.unshift directory
12
13
  end
13
14
 
14
- def list
15
+ def list(search = nil)
15
16
  list = {}
16
17
  each_file_in_index('.js') do |filename|
17
18
  if /lib\/([^\/\-]+)-([\d\w\.\-]+)\/.+/.match filename
@@ -25,6 +26,10 @@ module Jim
25
26
  list[name] << [version, filename]
26
27
  end
27
28
  end
29
+ if search
30
+ search = /#{search}/i
31
+ list = list.find_all {|lib| lib[0] =~ search }
32
+ end
28
33
  list.sort
29
34
  end
30
35
 
@@ -56,6 +61,10 @@ module Jim
56
61
  final
57
62
  end
58
63
 
64
+ def in_jimhome?(path)
65
+ !!(path.to_s =~ @jimhome_re)
66
+ end
67
+
59
68
  def find_all(name, version = nil)
60
69
  matched = []
61
70
  find(name, version) {|p| matched << p }
@@ -13,16 +13,16 @@ install <url> [name] [version]
13
13
 
14
14
  remove <name> [version]
15
15
  uninstall <name> [version]
16
- Iterate through the install files and prompt for the removal of those matching
17
- the supplied name and version
16
+ Iterate through the install files and prompt for the removal of those
17
+ matching the supplied name and version
18
18
 
19
- list
20
- installed
19
+ list [search]
20
+ installed [search]
21
21
  List all the installed packages and their versions
22
22
 
23
- available
24
- List all available projects and versions including those in the local path, or
25
- paths specified in a Jimfile
23
+ available [search]
24
+ List all available projects and versions including those in the local path,
25
+ or paths specified in a Jimfile
26
26
 
27
27
  resolve
28
28
  Resolve all the paths listed in a Jimfile and print them to STDOUT.
data/lib/jim.rb CHANGED
@@ -5,7 +5,7 @@ require 'version_sorter'
5
5
  require 'digest/md5'
6
6
 
7
7
  module Jim
8
- VERSION = '0.2.0'
8
+ VERSION = '0.2.1'
9
9
 
10
10
  class Error < RuntimeError; end
11
11
  class InstallError < Error; end
@@ -4,4 +4,4 @@
4
4
 
5
5
  jquery 1.4.1
6
6
  myproject
7
-
7
+ localfile
@@ -0,0 +1 @@
1
+ // local file
@@ -7,8 +7,8 @@ class TestJimBundler < Test::Unit::TestCase
7
7
  # clear the tmp dir
8
8
  FileUtils.rm_rf(tmp_path) if File.directory?(tmp_path)
9
9
  root = File.dirname(__FILE__)
10
- @directories = [File.join(root, 'fixtures'), File.join(root, 'tmp', 'lib')]
11
- Jim::Installer.new(fixture_path('infoincomments.js'), tmp_path).install
10
+ @directories = [File.join(root, 'tmp', 'lib'), File.join(root, 'fixtures')]
11
+ Jim::Installer.new(fixture_path('infoincomments.js'), File.join(root, 'tmp', 'lib')).install
12
12
  @bundler = Jim::Bundler.new(fixture('jimfile'), Jim::Index.new(@directories))
13
13
  end
14
14
 
@@ -42,7 +42,7 @@ class TestJimBundler < Test::Unit::TestCase
42
42
  assert @bundler.paths.empty?
43
43
  @bundler.resolve!
44
44
  assert @bundler.paths
45
- assert_equal 2, @bundler.paths.length
45
+ assert_equal 3, @bundler.paths.length
46
46
  @bundler.paths.each do |path, name, version|
47
47
  assert path.is_a?(Pathname)
48
48
  assert name.is_a?(String)
@@ -65,11 +65,11 @@ class TestJimBundler < Test::Unit::TestCase
65
65
 
66
66
  context "vendor!" do
67
67
 
68
- should "copy files in jemfile to path specified" do
68
+ should "copy files in jimfile to path specified" do
69
69
  vendor_dir = Pathname.new(tmp_path) + 'vendor'
70
70
  @bundler.vendor!(vendor_dir)
71
- assert_readable vendor_dir + 'jquery-1.4.1.js'
72
71
  assert_readable vendor_dir + 'myproject-1.2.2.js'
72
+ assert !File.readable?(vendor_dir + 'localfile.js'), "shouldnt vendor local files"
73
73
  end
74
74
 
75
75
  end
@@ -40,6 +40,12 @@ class TestJimIndex < Test::Unit::TestCase
40
40
  assert jquery[1][0][1].is_a?(Pathname), "should include pathname"
41
41
  end
42
42
 
43
+ should "only return files matching search" do
44
+ @list = @index.list('jquery')
45
+ names = @list.collect {|l| l[0] }
46
+ assert names.include?('jquery'), "should include jquery"
47
+ assert !names.include?('infoincomments')
48
+ end
43
49
  end
44
50
 
45
51
  context "find" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 0
9
- version: 0.2.0
8
+ - 1
9
+ version: 0.2.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Quint
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-16 00:00:00 -04:00
17
+ date: 2010-07-06 00:00:00 -07:00
18
18
  default_executable: jim
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -126,6 +126,7 @@ files:
126
126
  - test/fixtures/jquery-1.4.1.js
127
127
  - test/fixtures/jquery.color.js
128
128
  - test/fixtures/jquery.metadata-2.0.zip
129
+ - test/fixtures/localfile.js
129
130
  - test/fixtures/mustache.js/mustache.js
130
131
  - test/fixtures/mustache.js/package.json
131
132
  - test/fixtures/noversion.js