jim 0.2.1 → 0.2.2

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/.gitignore CHANGED
@@ -20,4 +20,5 @@ pkg
20
20
  tmp
21
21
 
22
22
  ## PROJECT::SPECIFIC
23
- *.rbc
23
+ *.rbc
24
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "downlow", "~> 0.1.3"
4
+ gem "yajl-ruby"
5
+ gem "version_sorter", "~> 1.1.0"
6
+ gem "leftright"
7
+ gem "shoulda", ">= 0"
8
+ gem "fakeweb", ">= 1.2.8"
9
+ gem "mocha"
10
+ gem "leftright"
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ archive-tar-minitar (0.5.2)
5
+ downlow (0.1.3)
6
+ archive-tar-minitar (>= 0.5.2)
7
+ rubyzip (>= 0.9.4)
8
+ fakeweb (1.3.0)
9
+ leftright (0.9.0)
10
+ mocha (0.9.8)
11
+ rake
12
+ rake (0.8.7)
13
+ rubyzip (0.9.4)
14
+ shoulda (2.11.3)
15
+ version_sorter (1.1.0)
16
+ yajl-ruby (0.7.7)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ downlow (~> 0.1.3)
23
+ fakeweb (>= 1.2.8)
24
+ leftright
25
+ mocha
26
+ shoulda
27
+ version_sorter (~> 1.1.0)
28
+ yajl-ruby
data/HISTORY CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.2 [09-10-10]
2
+
3
+ * Fixed issue where io's passed to bundle not closed properly before returning
4
+ resulting in truncated files
5
+
1
6
  == 0.2.1 [07-06-10]
2
7
 
3
8
  * Local (non JIMHOME) files specified in the Jimfiles are not copied into vendor
@@ -9,14 +14,14 @@
9
14
  * Each file in a package is installed separately
10
15
  * Each file is installed with a package.json file that describes the install
11
16
  and is merged with any existing package.json files
12
- * version parser was rewritten and handles many different formats
17
+ * version parser was rewritten and handles many different formats
13
18
  * Existing JIMHOMEs are probably now invalid (SORRY!!)
14
19
  * The install, specify, vendor, bundle workflow works from start to finish
15
20
  * passing the -o option to bundle or compress outputs to STDOUT
16
21
  * New commands:
17
22
  * available
18
23
  * pack
19
-
24
+
20
25
 
21
26
  == 0.1.2 [02-21-10]
22
27
 
@@ -30,4 +35,4 @@
30
35
 
31
36
  == 0.1.0 [02-19-10]
32
37
 
33
- * Initial release
38
+ * Initial release
data/Rakefile CHANGED
@@ -15,14 +15,15 @@ begin
15
15
  gem.email = "aaron@quirkey.com"
16
16
  gem.homepage = "http://github.com/quirkey/jim"
17
17
  gem.authors = ["Aaron Quint"]
18
-
18
+
19
19
  gem.add_dependency "downlow", ">= 0.1.3"
20
20
  gem.add_dependency "yajl-ruby"
21
21
  gem.add_dependency "version_sorter", ">= 1.1.0"
22
-
22
+
23
23
  gem.add_development_dependency "shoulda", ">= 0"
24
24
  gem.add_development_dependency "fakeweb", ">= 1.2.8"
25
25
  gem.add_development_dependency "mocha"
26
+ gem.add_development_dependency "leftright"
26
27
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
27
28
  end
28
29
  Jeweler::GemcutterTasks.new
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jim}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
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-07-06}
12
+ s.date = %q{2010-09-10}
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}
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
20
20
  ]
21
21
  s.files = [
22
22
  ".gitignore",
23
+ "Gemfile",
24
+ "Gemfile.lock",
23
25
  "HISTORY",
24
26
  "LICENSE",
25
27
  "README.rdoc",
@@ -107,7 +109,7 @@ Gem::Specification.new do |s|
107
109
  s.homepage = %q{http://github.com/quirkey/jim}
108
110
  s.rdoc_options = ["--charset=UTF-8"]
109
111
  s.require_paths = ["lib"]
110
- s.rubygems_version = %q{1.3.6}
112
+ s.rubygems_version = %q{1.3.7}
111
113
  s.summary = %q{jim is your friendly javascript library manager}
112
114
  s.test_files = [
113
115
  "test/fixtures/sammy-0.5.0/examples/backend/app.rb",
@@ -124,13 +126,14 @@ Gem::Specification.new do |s|
124
126
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
125
127
  s.specification_version = 3
126
128
 
127
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
129
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
128
130
  s.add_runtime_dependency(%q<downlow>, [">= 0.1.3"])
129
131
  s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
130
132
  s.add_runtime_dependency(%q<version_sorter>, [">= 1.1.0"])
131
133
  s.add_development_dependency(%q<shoulda>, [">= 0"])
132
134
  s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
133
135
  s.add_development_dependency(%q<mocha>, [">= 0"])
136
+ s.add_development_dependency(%q<leftright>, [">= 0"])
134
137
  else
135
138
  s.add_dependency(%q<downlow>, [">= 0.1.3"])
136
139
  s.add_dependency(%q<yajl-ruby>, [">= 0"])
@@ -138,6 +141,7 @@ Gem::Specification.new do |s|
138
141
  s.add_dependency(%q<shoulda>, [">= 0"])
139
142
  s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
140
143
  s.add_dependency(%q<mocha>, [">= 0"])
144
+ s.add_dependency(%q<leftright>, [">= 0"])
141
145
  end
142
146
  else
143
147
  s.add_dependency(%q<downlow>, [">= 0.1.3"])
@@ -146,6 +150,7 @@ Gem::Specification.new do |s|
146
150
  s.add_dependency(%q<shoulda>, [">= 0"])
147
151
  s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
148
152
  s.add_dependency(%q<mocha>, [">= 0"])
153
+ s.add_dependency(%q<leftright>, [">= 0"])
149
154
  end
150
155
  end
151
156
 
data/lib/jim.rb CHANGED
@@ -5,16 +5,16 @@ require 'version_sorter'
5
5
  require 'digest/md5'
6
6
 
7
7
  module Jim
8
- VERSION = '0.2.1'
9
-
8
+ VERSION = '0.2.2'
9
+
10
10
  class Error < RuntimeError; end
11
11
  class InstallError < Error; end
12
12
  class FileExists < Error; end
13
-
13
+
14
14
  def self.logger=(logger)
15
15
  @logger = logger
16
16
  end
17
-
17
+
18
18
  def self.logger
19
19
  @logger ||= LOGGER if defined?(LOGGER)
20
20
  if !@logger
@@ -25,7 +25,7 @@ module Jim
25
25
  end
26
26
  @logger
27
27
  end
28
-
28
+
29
29
  def self.each_path_in_directories(directories, ext, ignore_directories = [], &block)
30
30
  ignore_regexp = ignore_directories.empty? ? false : /(\/|^)(#{ignore_directories.join('|')})\//
31
31
  directories.each do |dir|
@@ -40,10 +40,10 @@ module Jim
40
40
  end
41
41
  end
42
42
  end
43
-
43
+
44
44
  autoload :Installer, 'jim/installer'
45
45
  autoload :Index, 'jim/index'
46
46
  autoload :Bundler, 'jim/bundler'
47
47
  autoload :VersionParser, 'jim/version_parser'
48
48
  autoload :CLI, 'jim/cli'
49
- end
49
+ end
@@ -1,5 +1,5 @@
1
1
  module Jim
2
- # Bundler takes parses a Jimfile that specifies requirements as names and
2
+ # Bundler takes parses a Jimfile that specifies requirements as names and
3
3
  # versions and then can bundle, compress, or copy those files into specific dirs
4
4
  # or files.
5
5
  #
@@ -15,12 +15,12 @@ module Jim
15
15
  # jquery.color
16
16
  # sammy 0.5.0
17
17
  #
18
- #
18
+ #
19
19
  class Bundler
20
20
  class MissingFile < Jim::Error; end
21
21
 
22
- attr_accessor :jimfile, :index, :requirements, :paths, :options
23
-
22
+ attr_accessor :jimfile, :index, :requirements, :paths, :options
23
+
24
24
  # create a new bundler instance passing in the Jimfile as a `Pathname` or a
25
25
  # string. `index` is a Jim::Index
26
26
  def initialize(jimfile, index = nil, extra_options = {})
@@ -33,7 +33,7 @@ module Jim
33
33
  self.paths = []
34
34
  if options[:vendor_dir]
35
35
  logger.debug "adding vendor dir to index #{options[:vendor_dir]}"
36
- self.index.add(options[:vendor_dir])
36
+ self.index.add(options[:vendor_dir])
37
37
  end
38
38
  end
39
39
 
@@ -43,7 +43,7 @@ module Jim
43
43
  name, version = search.strip.split(/\s+/)
44
44
  path = self.index.find(name, version)
45
45
  if !path
46
- raise(MissingFile,
46
+ raise(MissingFile,
47
47
  "Could not find #{name} #{version} in any of these paths #{index.directories.join(':')}")
48
48
  end
49
49
  self.paths << [path, name, version]
@@ -55,24 +55,24 @@ module Jim
55
55
  # path specified in the :bundled_path option
56
56
  def bundle!(to = nil)
57
57
  resolve! if paths.empty?
58
- to = options[:bundled_path] if to.nil? && options[:bundled_path]
59
- io = io_for_path(to)
60
- logger.info "Bundling to #{to}" if to
61
- paths.each do |path, name, version|
62
- io << path.read << "\n"
58
+ to = options[:bundled_path] if to.nil? && to != false && options[:bundled_path]
59
+ io_for_path(to) do |io|
60
+ logger.info "Bundling to #{to}" if to
61
+ paths.each do |path, name, version|
62
+ io << path.read << "\n"
63
+ end
63
64
  end
64
- io
65
65
  end
66
66
 
67
- # concatenate all the requirements into a single file then run through a JS
67
+ # concatenate all the requirements into a single file then run through a JS
68
68
  # then write to `to` or to the path specified in the :bundled_path option.
69
69
  # You can also use the YUI compressor by setting the option :compressor to 'yui'
70
70
  def compress!(to = nil)
71
71
  to = options[:compressed_path] if to.nil? && options[:compressed_path]
72
- io = io_for_path(to)
73
- logger.info "Compressing to #{to}"
74
- io << compress_js(bundle!(false))
75
- io
72
+ io_for_path(to) do |io|
73
+ logger.info "Compressing to #{to}"
74
+ io << compress_js(bundle!(false))
75
+ end
76
76
  end
77
77
 
78
78
  # copy each of the requirements into the dir specified with `dir` or the path
@@ -92,6 +92,10 @@ module Jim
92
92
  # Run the uncompressed test through a JS compressor (closure-compiler) by
93
93
  # default. Setting options[:compressor] == 'yui' will force the YUI JS Compressor
94
94
  def compress_js(uncompressed)
95
+ # if uncompressed.is_a?(File) && uncompressed.closed?
96
+ # puts "uncompressed is a file"
97
+ # uncompressed = File.read(uncompressed.path)
98
+ # end
95
99
  if options[:compressor] == 'yui'
96
100
  begin
97
101
  require "yui/compressor"
@@ -99,7 +103,7 @@ module Jim
99
103
  raise "You must install the yui compressor gem to use the compressor\ngem install yui-compressor"
100
104
  end
101
105
  compressor = ::YUI::JavaScriptCompressor.new
102
- else
106
+ else
103
107
  begin
104
108
  require 'closure-compiler'
105
109
  rescue LoadError
@@ -111,18 +115,22 @@ module Jim
111
115
  end
112
116
 
113
117
  private
114
- def io_for_path(to)
118
+ def io_for_path(to, &block)
115
119
  case to
116
120
  when IO
121
+ yield to
122
+ to.close
117
123
  to
118
124
  when Pathname
119
125
  to.dirname.mkpath
120
- to.open('w')
126
+ io = to.open('w') {|f| yield f }
121
127
  when String
122
128
  to = Pathname.new(to)
123
- io_for_path(to)
129
+ io_for_path(to, &block)
124
130
  else
125
- ""
131
+ io = ""
132
+ yield io
133
+ io
126
134
  end
127
135
  end
128
136
 
@@ -135,10 +143,10 @@ module Jim
135
143
  end
136
144
  end
137
145
  end
138
-
146
+
139
147
  def logger
140
148
  Jim.logger
141
149
  end
142
150
 
143
151
  end
144
- end
152
+ end
@@ -2,14 +2,14 @@ require 'optparse'
2
2
  require 'readline'
3
3
 
4
4
  module Jim
5
-
6
- # CLI handles the command line interface for the `jim` binary.
7
- # The layout is farily simple. Options are parsed using optparse.rb and
5
+
6
+ # CLI handles the command line interface for the `jim` binary.
7
+ # The layout is farily simple. Options are parsed using optparse.rb and
8
8
  # the different public methods represent 1-1 the commands provided by the bin.
9
9
  class CLI
10
-
10
+
11
11
  attr_accessor :jimfile, :jimhome, :force, :stdout
12
-
12
+
13
13
  # create a new instance with the args passed from the command line i.e. ARGV
14
14
  def initialize(args)
15
15
  @output = ""
@@ -20,33 +20,36 @@ module Jim
20
20
  @args = parse_options(args)
21
21
  ## try to run based on args
22
22
  end
23
-
24
- # method called by the bin directly after initialization.
25
- def run
23
+
24
+ # method called by the bin directly after initialization.
25
+ def run(reraise = false)
26
26
  command = @args.shift
27
27
  if command && respond_to?(command)
28
28
  self.send(command, *@args)
29
29
  elsif command.nil? || command.strip == ''
30
30
  cheat
31
- else
31
+ else
32
32
  @output << "No action found for #{command}. Run -h for help."
33
33
  end
34
34
  @output
35
35
  rescue ArgumentError => e
36
36
  @output << "#{e.message} for #{command}"
37
+ raise e if reraise
37
38
  rescue Jim::FileExists => e
38
39
  @output << "#{e.message} already exists, bailing. Use --force if you're sure"
40
+ raise e if reraise
39
41
  rescue => e
40
42
  @output << e.message + " (#{e.class})"
43
+ raise e if reraise
41
44
  end
42
-
45
+
43
46
  # list the possible commands to the logger
44
47
  def commands
45
48
  logger.info "Usage: jim [options] [command] [args]\n"
46
49
  logger.info "Commands:"
47
50
  logger.info template('commands')
48
51
  end
49
-
52
+
50
53
  # list the possible commands without detailed descriptions
51
54
  def cheat
52
55
  logger.info "Usage: jim [options] [command] [args]\n"
@@ -55,7 +58,7 @@ module Jim
55
58
  logger.info "run commands for details"
56
59
  end
57
60
  alias :help :cheat
58
-
61
+
59
62
  # initialize the current dir with a new Jimfile
60
63
  def init(dir = nil)
61
64
  dir = Pathname.new(dir || '')
@@ -69,31 +72,31 @@ module Jim
69
72
  logger.info "wrote Jimfile to #{jimfile_path}"
70
73
  end
71
74
  end
72
-
75
+
73
76
  # install the file/project `url` into `jimhome`
74
77
  def install(url, name = false, version = false)
75
78
  Jim::Installer.new(url, jimhome, :force => force, :name => name, :version => version).install
76
79
  end
77
-
80
+
78
81
  # bundle the files specified in Jimfile into `to`
79
82
  def bundle(to = nil)
80
83
  to = STDOUT if stdout
81
- path = bundler.bundle!(to)
82
- logger.info "Wrote #{File.size(path) / 1024}kb"
84
+ io = bundler.bundle!(to)
85
+ logger.info "Wrote #{File.size(io.path) / 1024}kb" if io.respond_to? :path
83
86
  end
84
-
87
+
85
88
  # compress the files specified in Jimfile into `to`
86
89
  def compress(to = nil)
87
90
  to = STDOUT if stdout
88
- path = bundler.compress!(to)
89
- logger.info "Wrote #{File.size(path) / 1024}kb"
91
+ io = bundler.compress!(to)
92
+ logger.info "Wrote #{File.size(io.path) / 1024}kb" if io.respond_to? :path
90
93
  end
91
-
94
+
92
95
  # copy/vendor all the files specified in Jimfile to `dir`
93
96
  def vendor(dir = nil)
94
97
  bundler.vendor!(dir, force)
95
98
  end
96
-
99
+
97
100
  # list the only the _installed_ projects and versions.
98
101
  # Match names against `search` if supplied.
99
102
  def list(search = nil)
@@ -104,9 +107,9 @@ module Jim
104
107
  print_version_list(list)
105
108
  end
106
109
  alias :installed :list
107
-
108
- # list all available projects and versions including those in the local path, or
109
- # paths specified in a Jimfile.
110
+
111
+ # list all available projects and versions including those in the local path, or
112
+ # paths specified in a Jimfile.
110
113
  # Match names against `search` if supplied.
111
114
  def available(search = nil)
112
115
  logger.info "Getting list of all available files in\n#{index.directories.join("\n")}"
@@ -115,7 +118,7 @@ module Jim
115
118
  logger.info "Available:"
116
119
  print_version_list(list)
117
120
  end
118
-
121
+
119
122
  # Iterates over matching files and prompts for removal
120
123
  def remove(name, version = nil)
121
124
  logger.info "Looking for files matching #{name} #{version}"
@@ -129,17 +132,17 @@ module Jim
129
132
  logger.info "Removing #{filename}"
130
133
  filename.delete
131
134
  removed += 1
132
- else
135
+ else
133
136
  logger.info "Skipping #{filename}"
134
137
  end
135
138
  end
136
139
  logger.info "Removed #{removed} files."
137
- else
140
+ else
138
141
  logger.info "No installed files matched."
139
142
  end
140
143
  end
141
144
  alias :uninstall :remove
142
-
145
+
143
146
  # list the files and their resolved paths specified in the Jimfile
144
147
  def resolve
145
148
  resolved = bundler.resolve!
@@ -149,7 +152,7 @@ module Jim
149
152
  end
150
153
  resolved
151
154
  end
152
-
155
+
153
156
  # vendor to dir, then bundle and compress the Jimfile contents
154
157
  def pack(dir = nil)
155
158
  logger.info "packing the Jimfile for this project"
@@ -157,7 +160,7 @@ module Jim
157
160
  bundle
158
161
  compress
159
162
  end
160
-
163
+
161
164
  private
162
165
  def parse_options(runtime_args)
163
166
  OptionParser.new("", 24, ' ') do |opts|
@@ -165,34 +168,34 @@ module Jim
165
168
 
166
169
  opts.separator ""
167
170
  opts.separator "jim options:"
168
-
169
- opts.on("--jimhome path/to/home", "set the install path/JIMHOME dir (default ~/.jim)") {|h|
171
+
172
+ opts.on("--jimhome path/to/home", "set the install path/JIMHOME dir (default ~/.jim)") {|h|
170
173
  self.jimhome = Pathname.new(h)
171
174
  }
172
175
 
173
176
  opts.on("-j", "--jimfile path/to/jimfile", "load specific Jimfile at path (default ./Jimfile)") { |j|
174
177
  self.jimfile = Pathname.new(j)
175
178
  }
176
-
179
+
177
180
  opts.on("-f", "--force", "force file creation/overwrite") {|f|
178
181
  self.force = true
179
182
  }
180
-
183
+
181
184
  opts.on("-d", "--debug", "set log level to debug") {|d|
182
185
  logger.level = Logger::DEBUG
183
186
  }
184
-
185
- opts.on("-o", "--stdout", "write output of commands (like bundle and compress to STDOUT)") {|o|
187
+
188
+ opts.on("-o", "--stdout", "write output of commands (like bundle and compress to STDOUT)") {|o|
186
189
  logger.level = Logger::ERROR
187
190
  self.stdout = true
188
191
  }
189
-
192
+
190
193
  opts.on("-v", "--version", "print version") {|d|
191
194
  puts "jim #{Jim::VERSION}"
192
195
  exit
193
196
  }
194
-
195
-
197
+
198
+
196
199
  opts.on_tail("-h", "--help", "Show this message. Run jim commands for list of commands.") do
197
200
  puts opts.help
198
201
  exit
@@ -203,36 +206,36 @@ module Jim
203
206
  logger.warn "#{e}, run -h for options"
204
207
  exit
205
208
  end
206
-
209
+
207
210
  def index
208
211
  @index ||= Jim::Index.new(install_dir, Dir.pwd)
209
212
  end
210
-
211
- def installed_index
213
+
214
+ def installed_index
212
215
  @installed_index ||= Jim::Index.new(install_dir)
213
216
  end
214
-
217
+
215
218
  def bundler
216
219
  @bundler ||= Jim::Bundler.new(jimfile, index)
217
220
  end
218
-
221
+
219
222
  def install_dir
220
223
  jimhome + 'lib'
221
224
  end
222
-
225
+
223
226
  def template(path)
224
227
  (Pathname.new(__FILE__).dirname + 'templates' + path).read
225
228
  end
226
-
229
+
227
230
  def logger
228
231
  Jim.logger
229
232
  end
230
-
233
+
231
234
  def print_version_list(list)
232
235
  list.each do |file, versions|
233
236
  logger.info "#{file} (#{VersionSorter.rsort(versions.collect {|v| v[0] }).join(', ')})"
234
237
  end
235
238
  end
236
-
239
+
237
240
  end
238
- end
241
+ end
@@ -3,6 +3,7 @@ require 'test/unit'
3
3
  require 'shoulda'
4
4
  require 'fakeweb'
5
5
  require 'mocha'
6
+ require 'leftright'
6
7
  # require 'test_benchmark'
7
8
 
8
9
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -10,8 +11,8 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
10
11
  require 'jim'
11
12
 
12
13
  unless !!ENV['PRINT']
13
- Jim.logger = Logger.new('/dev/null')
14
- else
14
+ Jim.logger = Logger.new('/dev/null')
15
+ else
15
16
  logger = Logger.new(STDOUT)
16
17
  logger.level = Logger::DEBUG
17
18
  logger.formatter = Proc.new {|s, t, n, msg| "\n* #{s}: #{msg}\n"}
@@ -22,38 +23,38 @@ JIM_TMP_ROOT = File.join(File.dirname(__FILE__), 'tmp', 'jimtmproot')
22
23
  Jim::Installer.tmp_root = JIM_TMP_ROOT
23
24
 
24
25
  class Test::Unit::TestCase
25
-
26
+
26
27
  def fixture_path(path)
27
28
  full_path = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', path))
28
29
  end
29
-
30
+
30
31
  def fixture(path)
31
32
  File.read(fixture_path(path))
32
33
  end
33
-
34
+
34
35
  def tmp_path
35
36
  Pathname.new(File.join(File.dirname(__FILE__), 'tmp')).expand_path
36
37
  end
37
-
38
+
38
39
  def assert_readable(*args)
39
40
  full_path = File.join(*args)
40
41
  assert File.readable?(full_path), "Expected #{full_path} to be a readable file"
41
42
  end
42
-
43
+
43
44
  def assert_file_contents(match, *args)
44
45
  full_path = File.join(*args)
45
46
  file_contents = File.read(full_path)
46
47
  assert_match(match, file_contents, "Expected file at #{full_path} with content #{file_contents} to match #{match.inspect}")
47
48
  end
48
-
49
+
49
50
  def assert_dir(*args)
50
51
  full_path = File.join(*args)
51
52
  assert File.directory?(full_path), "Expected #{full_path} to be a directory"
52
53
  end
53
-
54
+
54
55
  def assert_not_readable(*args)
55
56
  full_path = File.join(*args)
56
57
  assert !File.readable?(full_path), "Expected #{full_path} to not be a readable file"
57
58
  end
58
-
59
+
59
60
  end
@@ -10,53 +10,54 @@ class TestJimCLI < Test::Unit::TestCase
10
10
  Jim::Installer.new(fixture_path('infoincomments.js'), tmp_path).install
11
11
  Jim::Installer.new(fixture_path('jquery-1.4.1.js'), tmp_path).install
12
12
  end
13
-
13
+
14
14
  context "init" do
15
15
  should "write Jimfile to path" do
16
16
  run_cli("init", tmp_path)
17
17
  assert_readable tmp_path, "Jimfile"
18
18
  end
19
19
  end
20
-
20
+
21
21
  context "pack" do
22
22
  should "run vendor, bundle, compress" do
23
+ Jim::CLI.any_instance.expects(:compress).once
23
24
  Jim::Bundler.any_instance.stubs(:compress_js).returns("compressed.js")
24
25
  run_cli("pack", "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
25
26
  assert_readable tmp_path, 'public', 'javascripts', 'vendor', 'jquery-1.4.1.js'
26
27
  assert_readable tmp_path, 'public', 'javascripts', 'vendor', 'myproject-1.2.2.js'
27
28
  assert_readable tmp_path, 'public', 'javascripts', 'bundled.js'
28
- assert_readable tmp_path, 'public', 'javascripts', 'compressed.js'
29
+ # assert_readable tmp_path, 'public', 'javascripts', 'compressed.js'
29
30
  end
30
31
  end
31
-
32
+
32
33
  context "bundle" do
33
34
  should "write bundled Jimfile to path" do
34
35
  run_cli("bundle", tmp_path + 'bundle.js', "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
35
36
  assert_readable tmp_path + 'bundle.js'
36
37
  end
37
-
38
+
38
39
  should "write to bundled_path if no path provided" do
39
40
  run_cli("bundle", "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
40
41
  assert_readable tmp_path, 'public', 'javascripts', 'bundled.js'
41
42
  end
42
43
  end
43
-
44
+
44
45
  context "compress" do
45
46
  setup do
46
47
  Jim::Bundler.any_instance.stubs(:compress_js).returns("compressed.js")
47
48
  end
48
-
49
+
49
50
  should "compress Jimfile to path" do
50
51
  run_cli("compress", tmp_path + 'compressed.js', "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
51
52
  assert_readable tmp_path + 'compressed.js'
52
53
  end
53
-
54
+
54
55
  should "compress to compressed_path if no path provided" do
55
56
  run_cli("compress", "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
56
57
  assert_readable tmp_path, 'public', 'javascripts', 'compressed.js'
57
58
  end
58
59
  end
59
-
60
+
60
61
  context "vendor" do
61
62
  should "vendor Jimfile to vendor dir" do
62
63
  run_cli("vendor", "-j", fixture_path('Jimfile'), "--jimhome", tmp_path)
@@ -64,21 +65,21 @@ class TestJimCLI < Test::Unit::TestCase
64
65
  assert_readable tmp_path, 'public', 'javascripts', 'vendor', 'myproject-1.2.2.js'
65
66
  end
66
67
  end
67
-
68
+
68
69
  context "install" do
69
- should "install url to jim home" do
70
+ should "install url to jim home" do
70
71
  run_cli("install", fixture_path('jquery-1.4.1.js'), "--jimhome", tmp_path)
71
72
  install_path = File.join(tmp_path, 'lib', 'jquery-1.4.1')
72
73
  assert_dir install_path
73
74
  assert_readable install_path, 'jquery.js'
74
75
  assert_equal fixture('jquery-1.4.1.js'), File.read(File.join(install_path, 'jquery.js'))
75
- end
76
+ end
76
77
  end
77
-
78
+
78
79
  end
79
-
80
+
80
81
  def run_cli(*args)
81
- Jim::CLI.new(args.collect {|a| a.to_s }).run
82
+ Jim::CLI.new(args.collect {|a| a.to_s }).run(true)
82
83
  end
83
-
84
- end
84
+
85
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Quint
@@ -14,13 +14,14 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-06 00:00:00 -07:00
17
+ date: 2010-09-10 00:00:00 -07:00
18
18
  default_executable: jim
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: downlow
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
@@ -35,6 +36,7 @@ dependencies:
35
36
  name: yajl-ruby
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
@@ -47,6 +49,7 @@ dependencies:
47
49
  name: version_sorter
48
50
  prerelease: false
49
51
  requirement: &id003 !ruby/object:Gem::Requirement
52
+ none: false
50
53
  requirements:
51
54
  - - ">="
52
55
  - !ruby/object:Gem::Version
@@ -61,6 +64,7 @@ dependencies:
61
64
  name: shoulda
62
65
  prerelease: false
63
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
+ none: false
64
68
  requirements:
65
69
  - - ">="
66
70
  - !ruby/object:Gem::Version
@@ -73,6 +77,7 @@ dependencies:
73
77
  name: fakeweb
74
78
  prerelease: false
75
79
  requirement: &id005 !ruby/object:Gem::Requirement
80
+ none: false
76
81
  requirements:
77
82
  - - ">="
78
83
  - !ruby/object:Gem::Version
@@ -87,6 +92,7 @@ dependencies:
87
92
  name: mocha
88
93
  prerelease: false
89
94
  requirement: &id006 !ruby/object:Gem::Requirement
95
+ none: false
90
96
  requirements:
91
97
  - - ">="
92
98
  - !ruby/object:Gem::Version
@@ -95,6 +101,19 @@ dependencies:
95
101
  version: "0"
96
102
  type: :development
97
103
  version_requirements: *id006
104
+ - !ruby/object:Gem::Dependency
105
+ name: leftright
106
+ prerelease: false
107
+ requirement: &id007 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ type: :development
116
+ version_requirements: *id007
98
117
  description: jim is your friendly javascript library manager. He downloads, stores, bundles, vendors and compresses.
99
118
  email: aaron@quirkey.com
100
119
  executables:
@@ -106,6 +125,8 @@ extra_rdoc_files:
106
125
  - README.rdoc
107
126
  files:
108
127
  - .gitignore
128
+ - Gemfile
129
+ - Gemfile.lock
109
130
  - HISTORY
110
131
  - LICENSE
111
132
  - README.rdoc
@@ -199,6 +220,7 @@ rdoc_options:
199
220
  require_paths:
200
221
  - lib
201
222
  required_ruby_version: !ruby/object:Gem::Requirement
223
+ none: false
202
224
  requirements:
203
225
  - - ">="
204
226
  - !ruby/object:Gem::Version
@@ -206,6 +228,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
206
228
  - 0
207
229
  version: "0"
208
230
  required_rubygems_version: !ruby/object:Gem::Requirement
231
+ none: false
209
232
  requirements:
210
233
  - - ">="
211
234
  - !ruby/object:Gem::Version
@@ -215,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
238
  requirements: []
216
239
 
217
240
  rubyforge_project:
218
- rubygems_version: 1.3.6
241
+ rubygems_version: 1.3.7
219
242
  signing_key:
220
243
  specification_version: 3
221
244
  summary: jim is your friendly javascript library manager