Skip to content

Commit

Permalink
More clean up for move to thor
Browse files Browse the repository at this point in the history
  • Loading branch information
quirkey committed Nov 14, 2010
1 parent 3e01e43 commit b62f8f1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -22,3 +22,4 @@ tmp
## PROJECT::SPECIFIC
*.rbc
.bundle
.gem
5 changes: 3 additions & 2 deletions Rakefile
Expand Up @@ -16,9 +16,10 @@ begin
gem.homepage = "http://github.com/quirkey/jim"
gem.authors = ["Aaron Quint"]

gem.add_dependency "downlow", ">= 0.1.3"
gem.add_dependency "downlow", "~> 0.1.3"
gem.add_dependency "thor", "~> 0.14.4"
gem.add_dependency "yajl-ruby"
gem.add_dependency "version_sorter", ">= 1.1.0"
gem.add_dependency "version_sorter", "~> 1.1.0"

gem.add_development_dependency "shoulda", ">= 0"
gem.add_development_dependency "fakeweb", ">= 1.2.8"
Expand Down
18 changes: 10 additions & 8 deletions jim.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aaron Quint"]
s.date = %q{2010-09-26}
s.date = %q{2010-11-14}
s.default_executable = %q{jim}
s.description = %q{jim is your friendly javascript library manager. He downloads, stores, bundles, vendors and compresses.}
s.email = %q{aaron@quirkey.com}
Expand All @@ -34,7 +34,6 @@ Gem::Specification.new do |s|
"lib/jim/index.rb",
"lib/jim/installer.rb",
"lib/jim/rack.rb",
"lib/jim/templates/commands",
"lib/jim/templates/jimfile",
"lib/jim/version_parser.rb",
"test/fixtures/infoincomments.js",
Expand Down Expand Up @@ -127,26 +126,29 @@ Gem::Specification.new do |s|
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<downlow>, [">= 0.1.3"])
s.add_runtime_dependency(%q<downlow>, ["~> 0.1.3"])
s.add_runtime_dependency(%q<thor>, ["~> 0.14.4"])
s.add_runtime_dependency(%q<yajl-ruby>, [">= 0"])
s.add_runtime_dependency(%q<version_sorter>, [">= 1.1.0"])
s.add_runtime_dependency(%q<version_sorter>, ["~> 1.1.0"])
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
s.add_development_dependency(%q<mocha>, [">= 0"])
s.add_development_dependency(%q<leftright>, [">= 0"])
else
s.add_dependency(%q<downlow>, [">= 0.1.3"])
s.add_dependency(%q<downlow>, ["~> 0.1.3"])
s.add_dependency(%q<thor>, ["~> 0.14.4"])
s.add_dependency(%q<yajl-ruby>, [">= 0"])
s.add_dependency(%q<version_sorter>, [">= 1.1.0"])
s.add_dependency(%q<version_sorter>, ["~> 1.1.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
s.add_dependency(%q<mocha>, [">= 0"])
s.add_dependency(%q<leftright>, [">= 0"])
end
else
s.add_dependency(%q<downlow>, [">= 0.1.3"])
s.add_dependency(%q<downlow>, ["~> 0.1.3"])
s.add_dependency(%q<thor>, ["~> 0.14.4"])
s.add_dependency(%q<yajl-ruby>, [">= 0"])
s.add_dependency(%q<version_sorter>, [">= 1.1.0"])
s.add_dependency(%q<version_sorter>, ["~> 1.1.0"])
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
s.add_dependency(%q<mocha>, [">= 0"])
Expand Down
9 changes: 5 additions & 4 deletions lib/jim/bundler.rb
Expand Up @@ -57,7 +57,7 @@ def bundle!(to = nil)
resolve! if paths.empty?
to = options[:bundled_path] if to.nil? && options[:bundled_path]
io_for_path(to) do |io|
logger.info "Bundling to #{to}" if to
logger.debug "Bundling to #{to}" if to
paths.each do |path, name, version|
io << path.read << "\n"
end
Expand All @@ -70,23 +70,24 @@ def bundle!(to = nil)
def compress!(to = nil)
to = options[:compressed_path] if to.nil? && options[:compressed_path]
io_for_path(to) do |io|
logger.info "Compressing to #{to}"
logger.debug "Compressing to #{to}"
io << compress_js(bundle!(false))
end
end

# copy each of the requirements into the dir specified with `dir` or the path
# specified with the :vendor_dir option
# specified with the :vendor_dir option. Returns the dir it was vendored to.
def vendor!(dir = nil, force = false)
resolve! if paths.empty?
dir ||= options[:vendor_dir]
dir ||= 'vendor' # default
logger.info "Vendoring to #{dir}"
logger.debug "Vendoring #{paths.length} files to #{dir}"
paths.each do |path, name, version|
if index.in_jimhome?(path)
Jim::Installer.new(path, dir, :shallow => true, :force => force).install
end
end
dir
end

# Run the uncompressed test through a JS compressor (closure-compiler) by
Expand Down
45 changes: 30 additions & 15 deletions lib/jim/cli.rb
Expand Up @@ -50,7 +50,8 @@ def initialize(*)
logger.level = Logger::DEBUG if debug
end

desc 'init [APPDIR]', 'Create an example Jimfile at path or the current directory if path is omitted'
desc 'init [APPDIR]',
'Create an example Jimfile at path or the current directory if path is omitted'
def init(dir = nil)
dir = Pathname.new(dir || '')
jimfile_path = dir + 'Jimfile'
Expand All @@ -60,7 +61,7 @@ def init(dir = nil)
File.open(jimfile_path, 'w') do |f|
f << template('jimfile')
end
logger.info "wrote Jimfile to #{jimfile_path}"
say "Wrote Jimfile to #{jimfile_path}", :green
end
end

Expand Down Expand Up @@ -93,11 +94,12 @@ def install(url, name = false, version = false)
def bundle(to = nil)
to = STDOUT if stdout
io = bundler.bundle!(to)
say("Wrote #{File.size(io.path) / 1024}kb", :green) if io.respond_to? :path
say("Wrote #{io.path} #{File.size(io.path) / 1024}kb", :green) if io.respond_to? :path
end

desc "compress [COMPRESSED_PATH]",
"Bundle all the files listed in a Jimfile, run through the google closure compiler and save them to [COMPRESSED_PATH]."
"Bundle all the files listed in a Jimfile, run through the google closure " +
"compiler and save them to [COMPRESSED_PATH]."
long_desc <<-EOT
Bundle all the files listed in a Jimfile, run through the google closure
compiler and save them to [compressed_path].
Expand All @@ -114,22 +116,28 @@ def compress(to = nil)
say("Wrote #{File.size(io.path) / 1024}kb", :green) if io.respond_to? :path
end

desc "vendor [VENDOR_DIR]", "Copy all the files listed in Jimfile to the vendor_dir"
desc "vendor [VENDOR_DIR]",
"Copy all the files listed in Jimfile to the vendor_dir"
def vendor(dir = nil)
bundler.vendor!(dir, force)
dir = bundler.vendor!(dir, force)
say("Vendored files to #{dir}", :green)
end

desc "list [SEARCH]", "List all the installed packages and their versions, optionally limiting by [SEARCH]"
desc "list [SEARCH]",
"List all the installed packages and their versions, optionally limiting by [SEARCH]"
def list(search = nil)
say "Getting list of installed files in\n#{installed_index.directories.join(':')}"
say "Searching for '#{search}'" if search
say "Getting list of installed files in"
say("#{installed_index.directories.join(':')}", :yellow)
say("Searching for '#{search}'", :yellow) if search
list = installed_index.list(search)
say "Installed:"
print_version_list(list)
end
map "installed" => "list"

desc "available [SEARCH]" ,"List all available projects and versions including those in the local path, or paths specified in a Jimfile"
desc "available [SEARCH]",
"List all available projects and versions " +
"including those in the local path, or paths specified in a Jimfile"
def available(search = nil)
say "Getting list of all available files in\n#{index.directories.join("\n")}"
say "Searching for '#{search}'" if search
Expand All @@ -138,7 +146,9 @@ def available(search = nil)
print_version_list(list)
end

desc "remove <NAME> [VERSION]", "Iterate through the install files and prompt for the removal of those matching the supplied NAME and VERSION"
desc "remove <NAME> [VERSION]",
"Iterate through the install files and prompt for the removal of those " +
"matching the supplied NAME and VERSION"
def remove(name, version = nil)
say "Looking for files matching #{name} #{version}"
files = installed_index.find_all(name, version)
Expand All @@ -162,7 +172,9 @@ def remove(name, version = nil)
end
map "uninstall" => "remove"

desc "resolve", "Resolve all the paths listed in a Jimfile and print them to STDOUT. If no Jimfile is set in the options, assumes ./Jimfile."
desc "resolve",
"Resolve all the paths listed in a Jimfile and print them to STDOUT. " +
"If no Jimfile is set in the options, assumes ./Jimfile."
def resolve
resolved = bundler.resolve!
say "Files:"
Expand All @@ -172,9 +184,12 @@ def resolve
resolved
end

desc "pack [DIR]", "Runs in order, vendor, bundle, compress. This command simplifies the common workflow of vendoring and re-bundling before committing or deploying changes to a project"
desc "pack [DIR]",
"Runs in order, vendor, bundle, compress. This command " +
"simplifies the common workflow of vendoring and re-bundling " +
"before committing or deploying changes to a project"
def pack(dir = nil)
say "packing the Jimfile for this project"
say "Packing the Jimfile for this project"
invoke :vendor, [dir]
invoke :bundle
invoke :compress
Expand Down Expand Up @@ -207,7 +222,7 @@ def logger

def print_version_list(list)
list.each do |file, versions|
logger.info "#{file} (#{VersionSorter.rsort(versions.collect {|v| v[0] }).join(', ')})"
say"#{file} (#{VersionSorter.rsort(versions.collect {|v| v[0] }).join(', ')})"
end
end

Expand Down

0 comments on commit b62f8f1

Please sign in to comment.