cake 0.2.3 → 0.2.5

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.
Files changed (5) hide show
  1. data/bin/cake +78 -17
  2. data/cake.gemspec +1 -1
  3. data/lib/bake.jar +0 -0
  4. data/lib/cake.jar +0 -0
  5. metadata +5 -4
data/bin/cake CHANGED
@@ -1,32 +1,93 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Save your fork, there's cake!"
3
-
3
+ require 'ftools'
4
4
  require 'open-uri'
5
+ require 'rexml/document'
6
+
7
+ $repo = "http://clojars.org/repo/cake/cake"
8
+ $file = File.readlink(__FILE__) rescue __FILE__
9
+ $root = File.dirname(File.dirname($file))
10
+
11
+ def have_cake(version, dest)
12
+ jar = version =~ /(.*)-SNAPSHOT/ ? "cake-#{$1}-#{snapshot(version)}.jar" : "cake-#{version}.jar"
13
+ dest = File.expand_path(dest)
14
+ path = "#{dest}/#{jar}"
15
+
16
+ if not File.exists?(path)
17
+ puts "fetching cake libraries. this may take a moment..."
18
+ url = "#{$repo}/#{version}/#{jar}"
19
+ File.makedirs(dest)
20
+ open(url) do |jar|
21
+ open(path, "wb") do |file|
22
+ while (buf = jar.read(8192))
23
+ file.write buf
24
+ end
25
+ end
26
+ end
27
+ end
28
+ path
29
+ rescue OpenURI::HTTPError => e
30
+ puts "unable to find cake version #{version} on clojars."
31
+ puts "please check http://github.com/ninjudd/cake for latest install instructions."
32
+ exit
33
+ end
34
+
35
+ def eat_cake(*args)
36
+ opts = %{ -d32 -cp #{$classpath} -Dbakepath="#{$bakepath}" }
37
+ system %{ java #{opts} clojure.main -e "(use 'cake)(-main)" /dev/null #{args.join(' ')} }
38
+ end
5
39
 
6
- def get(url, dest)
7
- open("#{dest}/#{File.basename(url)}", "wb").write(open(url))
40
+ def current_version
41
+ open("#{$repo}/maven-metadata.xml") do |file|
42
+ doc = REXML::Document.new file
43
+ doc.elements['metadata'].elements['versioning'].elements['versions'].elements.to_a('version').last.get_text.to_s
44
+ end
8
45
  end
9
46
 
10
- def cake(*args)
11
- system %Q( java -cp #{$classpath} clojure.main -e "(use 'cake)(-main)" /dev/null #{args.join(' ')} )
47
+ def snapshot(version)
48
+ open("#{$repo}/#{version}/maven-metadata.xml") do |file|
49
+ doc = REXML::Document.new file
50
+ snapshot = doc.elements['metadata'].elements['versioning'].elements['snapshot'].elements
51
+ timestamp = snapshot['timestamp'].get_text
52
+ build_num = snapshot['buildNumber'].get_text
53
+ "#{timestamp}-#{build_num}"
54
+ end
12
55
  end
13
56
 
14
- file = File.readlink(__FILE__) rescue __FILE__
15
- root = File.dirname(File.dirname(file))
16
- lib = "#{root}/lib"
17
- jar = "#{root}/lib/cake.jar"
18
- $classpath = File.exists?(jar) ? jar : "#{root}/src/:#{root}/lib/*"
57
+ def extract(jar, file)
58
+ dest = File.dirname(jar)
59
+ system %{ jar xf #{jar} -C #{dest} #{file} }
60
+ "#{dest}/#{file}"
61
+ end
19
62
 
20
63
  # Bootstap cake dependencies.
21
- if not File.exists?(lib)
22
- url ="http://github.com/downloads/ninjudd/cake-standalone/cake.jar"
23
- echo "fetching cake standalone jar from #{url}..."
24
- File.makedirs(lib)
25
- get(url, lib)
64
+ lib = "#{$root}/lib"
65
+ if File.exists?("#{$root}/.gitignore")
66
+ if Dir["#{lib}/*.jar"].empty?
67
+ # In a new git checkout, need to fetch dependencies.
68
+ version = IO.read("#{$root}/project.clj").first.match(/defproject cake \"(.*)\"/)[1]
69
+ have_cake(version, lib)
70
+ end
71
+ $classpath = "#{$root}/src/:#{lib}/*"
72
+ $bakepath = "#{$root}/bake"
73
+ else
74
+ cake_jar = "#{lib}/cake.jar"
75
+ bake_jar = "#{lib}/bake.jar"
76
+ if File.exists?(cake_jar) and File.exists?(bake_jar)
77
+ # Inside a gem install.
78
+ $classpath = cake_jar
79
+ $bakepath = bake_jar
80
+ else
81
+ # Naked script.
82
+ version = current_version
83
+ dest = "~/.m2/repository/cake/cake/#{version}"
84
+ $classpath = have_cake(version, dest)
85
+ $bakepath = extract($classpath, "bake-#{version}.jar")
86
+ end
26
87
  end
27
88
 
28
89
  if not File.exists?("pom.xml") or test(?>, "project.clj", "pom.xml") and ARGV.first != "deps"
29
- cake("deps")
90
+ eat_cake("deps")
30
91
  end
31
92
 
32
- cake(*ARGV)
93
+ eat_cake(*ARGV)
@@ -9,6 +9,6 @@ Gem::Specification.new do |s|
9
9
  s.description = "Save your fork, there's cake!"
10
10
  s.email = 'code@justinbalthrop.com'
11
11
  s.executables = ['cake']
12
- s.files = ['cake.gemspec', 'bin/cake', 'lib/cake.jar']
12
+ s.files = ['cake.gemspec', 'bin/cake', 'lib/cake.jar', 'lib/bake.jar']
13
13
  s.homepage = 'http://github.com/ninjudd/cake'
14
14
  end
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: 17
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 5
10
+ version: 0.2.5
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-03 00:00:00 -07:00
19
+ date: 2010-06-05 00:00:00 -07:00
20
20
  default_executable: cake
21
21
  dependencies: []
22
22
 
@@ -32,6 +32,7 @@ files:
32
32
  - cake.gemspec
33
33
  - bin/cake
34
34
  - lib/cake.jar
35
+ - lib/bake.jar
35
36
  has_rdoc: true
36
37
  homepage: http://github.com/ninjudd/cake
37
38
  licenses: []