geoffrey 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geoffrey (0.1.1)
4
+ geoffrey (0.1.2)
5
5
  plist4r
6
6
  progressbar
7
7
  thor
data/README.md CHANGED
@@ -40,6 +40,10 @@ provided recipes, and install them.
40
40
  >> Moving file to /Applications
41
41
  >> Install successful
42
42
 
43
+ $ geoffrey install http://www.example.com/template.json --remote
44
+ >> Parsing http://www.example.com/template.json
45
+ ...
46
+
43
47
  $ geoffrey seach jabber
44
48
  >> Adium: Adium is a free instant messaging application for Mac OS X that can connect to AIM, MSN, Jabber, Yahoo, and more.
45
49
 
@@ -27,13 +27,18 @@ module Geoffrey
27
27
  # the compressed file.
28
28
  # * +:filename+ set the name of the file you are downloading.
29
29
  #
30
+ # If what you're going to test to see if you have to install something or
31
+ # not is the existance of a file (most likely), you can just specify the
32
+ # path in a creates statement (see examples).
33
+ #
30
34
  # If you don't want to install a .pkg but do something else, you can just
31
35
  # override the install method. See the examples
32
36
  #
33
37
  # @example
34
38
  # Geoffrey.package do
35
39
  # url 'http://www.culater.net/dl/files/SIMBL-0.9.7a.zip'
36
- # options :sudo => true, :unless => Proc.new{ File.exists?("/Library/LaunchAgents/net.culater.SIMBL.Agent.plist") }
40
+ # creates "/Library/LaunchAgents/net.culater.SIMBL.Agent.plist"
41
+ # options :sudo => true
37
42
  # end
38
43
  #
39
44
  # @example
@@ -15,16 +15,34 @@ module Geoffrey
15
15
  puts names.join(' ')
16
16
  end
17
17
 
18
- desc "install [template]", "install the specified template"
19
- method_options :verbose => :boolean
20
- def install(name)
21
- if file = file_for_template(name)
22
- @package = Geoffrey::Template.new(file).package
23
- @package.verbose(true) if options[:verbose]
24
- @package.process
18
+ desc "install [template] [options]", "install the specified template"
19
+ method_options :verbose => :boolean, :remote => :boolean
20
+ def install(*names)
21
+
22
+ templates_to_install = []
23
+
24
+ # if a remote flag is on, then we'll take the parameter as an url, and will
25
+ # then fetch it directly instead of looking for it in the filesystem
26
+ # templates.
27
+ if options[:remote]
28
+ templates_to_install << names.join
25
29
  else
30
+ names.each do |name|
31
+ if file = file_for_template(name)
32
+ templates_to_install << file
33
+ end
34
+ end
35
+ end
36
+
37
+ if templates_to_install.empty?
26
38
  puts "Template not found"
27
39
  exit 1
40
+ else
41
+ templates_to_install.each do |template|
42
+ package = Geoffrey::Template.new(template).package
43
+ package.verbose(true) if options[:verbose]
44
+ package.process
45
+ end
28
46
  end
29
47
  end
30
48
 
@@ -24,13 +24,13 @@ module Geoffrey
24
24
  include Geoffrey::FileHelper
25
25
 
26
26
  attr_accessor :url, :description, :options, :format, :filename,
27
- :dir, :file, :guessed_name
27
+ :dir, :file, :guessed_name, :creates
28
28
 
29
29
  def initialize
30
30
  @options = {}
31
31
  end
32
32
 
33
- [:url,:description].each do |attrib|
33
+ [:url,:description,:creates].each do |attrib|
34
34
  class_eval <<-GEOF
35
35
  def #{attrib}(val=nil)
36
36
  val.nil? ? @#{attrib} : @#{attrib} = val
@@ -148,7 +148,9 @@ module Geoffrey
148
148
 
149
149
  def should_install
150
150
  ok_to_go = if @url && @url != ""
151
- if @options[:unless] && @options[:unless].respond_to?(:call)
151
+ if @creates
152
+ !File.exists?(@creates)
153
+ elsif @options[:unless] && @options[:unless].respond_to?(:call)
152
154
  !@options[:unless].call
153
155
  elsif @options[:if] && @options[:if].respond_to?(:call)
154
156
  @options[:if].call
@@ -158,8 +160,8 @@ module Geoffrey
158
160
  else
159
161
  false
160
162
  end
161
- echo "#{filename} is already installed." unless ok_to_go
162
- ok_to_go
163
+ echo "#{filename} is already installed." unless ok_to_go
164
+ ok_to_go
163
165
  end
164
166
 
165
167
  # Simple wrapper to execute things, using sudo or not as per defiend in the
@@ -1,3 +1,3 @@
1
1
  module Geoffrey
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -62,6 +62,22 @@ describe Geoffrey::CLI do
62
62
  @app.install("growl")
63
63
  end
64
64
 
65
+ it "can install multiple packages" do
66
+ Geoffrey::Package.any_instance.expects(:install).twice.returns(nil)
67
+ Geoffrey::Package.any_instance.expects(:download_and_decompress).twice.returns(nil)
68
+ @app.install("growl","simbl")
69
+ end
70
+
71
+ it "can take remote packages" do
72
+ Geoffrey::Package.any_instance.expects(:url).with("foo.com")
73
+ Geoffrey::Package.any_instance.expects(:download_and_decompress).once.returns(nil)
74
+ Geoffrey::Package.any_instance.expects(:install).once
75
+ path = File.dirname(__FILE__) + "/static/template1.json"
76
+ @app.stubs(:options).returns(:remote => true)
77
+ @app.stubs(:names).returns([path])
78
+ @app.install(path)
79
+ end
80
+
65
81
  end
66
82
 
67
83
  #--
@@ -90,6 +90,16 @@ describe Geoffrey::Package do
90
90
  end
91
91
  end
92
92
 
93
+ it "allows for the definition of a 'creates' to serve as a shortcut for :unless => File.exists?" do
94
+ capturing_output do
95
+ package = Geoffrey::Package.new
96
+ package.url("whatever")
97
+ package.creates(__FILE__) # It always exists
98
+ package.download_and_decompress.should == nil
99
+ package.install.should == nil
100
+ end
101
+ end
102
+
93
103
  end
94
104
 
95
105
  # Things should be uncompressed into a temporary folder, and the
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "url" : "http://downloads.sourceforge.net/project/burn-osx/Burn/2.4.1/Burn241u.zip?r=http%3A%2F%2Fburn-osx.sourceforge.net%2FPages%2FEnglish%2Fhome.html&ts=1284476617&use_mirror=ovh",
3
- "description" : "Simple but advanced burning for Mac OS X"
3
+ "description" : "Burn: simple but advanced burning for Mac OS X"
4
4
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Albert Llop
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-14 00:00:00 +02:00
17
+ date: 2010-09-19 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency