cake 0.2.10 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/cake +52 -21
  2. data/lib/bake.jar +0 -0
  3. data/lib/cake.jar +0 -0
  4. metadata +5 -5
data/bin/cake CHANGED
@@ -6,9 +6,22 @@ require 'open-uri'
6
6
  require 'rexml/document'
7
7
  require 'socket'
8
8
  require 'timeout'
9
- require 'readline'
10
9
  require 'fileutils'
11
- require 'pp'
10
+
11
+ begin
12
+ require 'readline'
13
+ rescue LoadError => e
14
+ module Readline
15
+ HISTORY = []
16
+ attr_accessor :completer_word_break_characters, :completion_proc
17
+ def readline(prompt)
18
+ $stdout.print prompt
19
+ $stdout.flush
20
+ $stdin.gets
21
+ end
22
+ extend Readline
23
+ end
24
+ end
12
25
 
13
26
  PATH_SEP = ':'
14
27
  file = File.readlink(__FILE__) rescue __FILE__
@@ -18,24 +31,29 @@ $repo = "http://clojars.org/repo/cake/cake"
18
31
  $confdir = ".cake"
19
32
  File.makedirs($confdir)
20
33
 
21
- def get_cake(version, dest)
34
+ def get_cake(version, dest = nil)
22
35
  jar = version =~ /(.*)-SNAPSHOT/ ? "cake-#{$1}-#{snapshot(version)}.jar" : "cake-#{version}.jar"
23
- dest = File.expand_path(dest)
24
- path = "#{dest}/#{jar}"
36
+ repo = File.expand_path("~/.m2/repository/cake/cake/#{version}")
37
+ path = "#{repo}/#{jar}"
25
38
 
26
39
  if not File.exists?(path)
27
40
  log(:deps, "fetching cake libraries. this may take a moment...")
28
41
  url = "#{$repo}/#{version}/#{jar}"
29
- File.makedirs(dest)
30
- open(url) do |jar|
42
+ File.makedirs(repo)
43
+ open(url) do |jarfile|
31
44
  open(path, "wb") do |file|
32
- while (buf = jar.read(8192))
45
+ while (buf = jarfile.read(8192))
33
46
  file.write buf
34
47
  end
35
48
  end
36
49
  end
37
50
  end
38
- path
51
+ return path unless dest
52
+
53
+ dest = File.expand_path(dest)
54
+ File.makedirs(dest)
55
+ File.copy(path, dest)
56
+ "#{dest}/#{jar}"
39
57
  rescue OpenURI::HTTPError => e
40
58
  log(:deps, "unable to find cake version #{version} on clojars.")
41
59
  log(:deps, "please check http://github.com/ninjudd/cake for latest install instructions.")
@@ -60,11 +78,13 @@ def snapshot(version)
60
78
  end
61
79
 
62
80
  def extract(jar, file, dest = File.dirname(jar))
63
- log(:deps, "extracting #{file} from #{jar}") if verbose?
64
- system %{ jar xf #{jar} #{file} }
65
-
66
- File.makedirs(dest)
67
- File.move(file, dest)
81
+ if not File.exists?("#{dest}/#{file}")
82
+ log(:deps, "extracting #{file} from #{jar}") if verbose?
83
+ ret = system %{ jar xf #{jar} #{file} }
84
+ raise "cannot find jar command" unless ret
85
+ File.makedirs(dest)
86
+ File.move(file, dest)
87
+ end
68
88
  "#{dest}/#{file}"
69
89
  end
70
90
 
@@ -204,7 +224,9 @@ class JVM
204
224
  end
205
225
 
206
226
  def java_opts
207
- "-cp #{classpath} -Djava.library.path=#{libpath}"
227
+ opts = "-cp #{classpath} -Djava.library.path=#{libpath}"
228
+ opts << " -Djava.home=#{ENV['JAVA_HOME']} -Djava.ext.dirs=#{ENV['JAVA_HOME']}/lib" if ENV['JAVA_HOME']
229
+ opts
208
230
  end
209
231
 
210
232
  MIN_PORT = 2**13
@@ -214,7 +236,7 @@ class JVM
214
236
  return if not enabled? or running?
215
237
  @port = rand(MAX_PORT - MIN_PORT) + MIN_PORT
216
238
  log(:start, "starting #{type} jvm on port #{port}") if debug?
217
- @pid = daemon %{ java #{java_opts} clojure.main -e "(use '#{type})(start-server #{port})" /dev/null }
239
+ @pid = daemon %{ java -Dcake.project=#{$bakedir} #{java_opts} clojure.main -e "(use '#{type})(start-server #{port})" /dev/null }
218
240
  File.open(pidfile, 'w') {|f| f.write("#{pid}\n#{port}\n") }
219
241
  log(:start, "#{type} jvm started") if verbose?
220
242
  rescue Errno::EADDRNOTAVAIL => e
@@ -435,12 +457,13 @@ end
435
457
  # Bootstrap cake dependencies.
436
458
  lib = "#{$cakedir}/lib"
437
459
  if File.exists?("#{$cakedir}/.gitignore")
438
- if Dir["#{lib}/*.jar"].empty?
460
+ if Dir["#{lib}/*.jar"].empty? or Dir["#{lib}/dev/*.jar"].empty?
439
461
  # In a new git checkout, need to fetch dependencies.
440
462
  version = IO.read("#{$cakedir}/project.clj").split("\n").first.match(/defproject cake \"(.*)\"/)[1]
441
463
  cakejar = get_cake(version, lib)
442
464
  extract(cakejar, "bake-#{version}.jar", "#{lib}/dev")
443
465
  end
466
+
444
467
  cakepath = ["#{$cakedir}/src", "#{lib}/*:#{lib}/dev/*"].join(PATH_SEP)
445
468
  bakepath = ["#{$cakedir}/bake", "#{lib}/dev/*"].join(PATH_SEP)
446
469
  else
@@ -453,8 +476,7 @@ else
453
476
  else
454
477
  # Naked script.
455
478
  version = current_version
456
- dest = "~/.m2/repository/cake/cake/#{version}"
457
- cakepath = get_cake(version, dest)
479
+ cakepath = get_cake(version)
458
480
  bakepath = extract(cakepath, "bake-#{version}.jar")
459
481
  end
460
482
  end
@@ -469,9 +491,18 @@ bake = Bake.new(
469
491
  )
470
492
 
471
493
  if $command == :kill
472
- cake.kill
473
- bake.kill
494
+ if $opts[:all]
495
+ `jps -v | grep cake.project`.split("\n").each do |line|
496
+ pid = line.split(' ').first.to_i
497
+ Process.kill($opts[:"9"] ? "KILL" : "TERM", pid)
498
+ end
499
+ else
500
+ cake.kill
501
+ bake.kill
502
+ end
474
503
  exit
504
+ elsif $command == :ps
505
+ exec "jps -v | grep cake.project"
475
506
  elsif restart?
476
507
  cake.stop
477
508
  bake.stop
Binary file
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cake
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 10
10
- version: 0.2.10
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Balthrop
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-29 00:00:00 -07:00
19
+ date: 2010-07-06 00:00:00 -07:00
20
20
  default_executable: cake
21
21
  dependencies: []
22
22