geoffrey 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,32 +39,7 @@ what a pain it is to install them every time. Now you can do so with the next pi
39
39
  options :sudo => true, :unless => Proc.new{ File.exists?("/Library/LaunchAgents/net.culater.SIMBL.Agent.plist") }
40
40
  end
41
41
 
42
- Geoffrey will take care of downloading the zip file, and install whatever .pkg
43
- file is in the zip. The possible options are:
44
-
45
- * `:sudo` => in case it needs to be executed as sudo to install (it does if the installer would ever ask for your password)
46
- * `:unless` => in order to make running this idempotent.
47
- * `:file` => specify which of the files contained in the zip has to be installed. If it's not specified it uses the first .pkg it finds.
48
-
49
- With that you'll have SIMBL installed and working. Now suppose you want to install a bundle.
50
- You'd have to download a file, and move it to a directory. Geoffrey can help you a little,
51
- basically downloading and uncompressing the zip, and you just have to define the install
52
- method.
53
-
54
- require 'geoffrey'
55
- Geoffrey.package do
56
- url "http://github.com/dabeeeenster/terminaltabswitching/raw/master/TerminalTabSwitching.bundle.zip"
57
- options :file => "TerminalTabSwitching.bundle"
58
-
59
- def install
60
- plugins_dir = "#{ENV["HOME"]}/Library/Application Support/SIMBL/Plugins"
61
- FileUtils.mkdir_p plugins_dir
62
- FileUtils.mv file_to_install, plugins_dir, :force => true
63
- end
64
-
65
- end
66
-
67
- `file_to_install` is provided by geoffrey poiting to the automatically downloaded/uncompressed file.
42
+ Check the [documentation](http://rdoc.info/albertllop/geoffrey) for more detailed documentation.
68
43
 
69
44
  ## Application Configuration
70
45
 
@@ -87,26 +62,7 @@ up and running with Pro scheme, Menlo Font 14pt, and a size 520x100.
87
62
  options["Window Settings"]["Pro"]["rowCount"] = 100
88
63
  end
89
64
 
90
- * `file` => Geoffrey knows of a few files in your system you can specify with symbols. If you want to work with a different one, just write the full path.
91
- * `affects` => When you close Terminal.app, it'll dump its otions into the plist. So you have to stop it, change the plist file, then reopen it. Geoffrey does this automatically if you tell him what must be rebooted.
92
- * `options` => Its the plist has per se. Using the fantastic [plist4r](http://github.com/dreamcat4/plist4r) gem, you can modify it.
93
-
94
- You might have seen something peculiar:
95
-
96
- options["Window Settings"]["Pro"]["Font"].blob = true
97
-
98
- Some values in plist files are of type "Data", which is just binary stuff. Plist4r handles
99
- these as strings with a special flag.
100
-
101
- The best way to know what to put in every value, is to just go to the file and take a
102
- look. They all tend to make sense. For data values, however, you might have more work. The
103
- way I do it is opening the file with Plist4r, and reading the value:
104
-
105
- require 'plist4r'
106
- plist = Plist4r.open("the/file.plist")
107
- plist["whatever"]["option"] # => copy whatever it returns
108
-
109
- Just make sure that when you set it in your geoffrey you put the flag blog true. Otherwise you might see some really weird system errors.
65
+ Check the [documentation](http://rdoc.info/albertllop/geoffrey) for more detailed documentation.
110
66
 
111
67
  ## A few words
112
68
 
@@ -7,13 +7,14 @@ module Geoffrey
7
7
 
8
8
  # Define a package installation from the URL specified. It will download
9
9
  # the file, and if it's compressed, it will decompress it.It currently
10
- # supports zip and tar.gz files. Once extracted it will look for a .pkg
10
+ # supports zip, tar.gz and .gz files. Once extracted it will look for a .pkg
11
11
  # file and try to install it.
12
12
  #
13
13
  # Some options can be defined:
14
14
  #
15
15
  # * +:sudo+ if it has to be executed as sudo.
16
16
  # * +:unless+ a Proc defining if it doesn't have to try to install it.
17
+ # * +:if+ inverse of inverse
17
18
  # * +:file+ what file has to be installed from all of the ones that came in
18
19
  # the compressed file.
19
20
  #
@@ -66,10 +66,30 @@ module Geoffrey
66
66
  execute command
67
67
  end
68
68
 
69
+ # If it was specified through options, then get that, otherwise
70
+ # get the first file with .pkg extension
71
+ #--
72
+ # TODO Also use .dmg when support is added
73
+ def file_to_install
74
+ return @file_to_install if defined?(@file_to_install)
75
+ @file_to_install = if @options[:file]
76
+ "#{@dir}/#{@options[:file]}"
77
+ else
78
+ files = Dir.glob("#{@dir}/**/*.pkg").first
79
+ files ||= Dir.glob("#{@dir}/**/*").first
80
+ end
81
+ end
82
+
69
83
  private
70
84
 
71
85
  def shouldnt_install
72
- @options[:unless] && @options[:unless].respond_to?(:call) && @options[:unless].call
86
+ if @options[:unless] && @options[:unless].respond_to?(:call)
87
+ @options[:unless].call
88
+ elsif @options[:if] && @options[:if].respond_to?(:call)
89
+ !@options[:if].call
90
+ else
91
+ false
92
+ end
73
93
  end
74
94
 
75
95
  # Simple wrapper to execute things, using sudo or not as per defiend in the
@@ -81,30 +101,15 @@ module Geoffrey
81
101
  system command
82
102
  end
83
103
 
84
- # If it was specified through options, then get that, otherwise
85
- # get the first file with .pkg extension
86
- #--
87
- # TODO Also use .dmg when support is added
88
- def file_to_install
89
- if @options[:file]
90
- "#{@dir}/#{@options[:file]}"
91
- else
92
- files = Dir.glob("#{@dir}/**/*.pkg")
93
- files.first
94
- end
95
- end
96
-
97
104
  def get_format
98
105
  @format = case File.extname @url
99
106
  when '.zip' then :zip
100
107
  when '.tar' then :tar
101
108
  when '.tgz' then :tgz
102
109
  when '.gz'
103
- if @filename =~ /\.tar\.gz/
104
- :tgz
105
- else
106
- :gz
107
- end
110
+ @filename =~ /\.tar\.gz/ ? :tgz : :gz
111
+ else
112
+ :unknown
108
113
  end
109
114
  end
110
115
 
@@ -123,6 +128,8 @@ module Geoffrey
123
128
  "tar xzf #{file.path} -C #{target}"
124
129
  when :gz
125
130
  "cp #{file.path} #{target}/#{filename}.gz; gunzip #{target}/*"
131
+ when :unknown
132
+ "cp #{file.path} #{target}/#{filename}"
126
133
  end
127
134
  execute command, :sudo => false
128
135
  end
@@ -1,3 +1,3 @@
1
1
  module Geoffrey
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  require 'geoffrey/package'
3
3
 
4
4
  describe Geoffrey::Package do
5
+
5
6
  it "allows for the url to be specified" do
6
7
  package = Geoffrey::Package.new
7
8
  package.url 'http://localhost/crappy.zip'
@@ -17,48 +18,56 @@ describe Geoffrey::Package do
17
18
  context "package installation" do
18
19
 
19
20
  it "installs basic package stuff" do
20
-
21
21
  end
22
22
 
23
23
  it "doesnt install the thing if a :unless option is provided" do
24
-
24
+ package = Geoffrey::Package.new
25
+ package.url("whatever")
26
+ package.options :unless => Proc.new { true }
27
+ package.download_and_decompress.should == nil
28
+ package.install.should == nil
25
29
  end
26
30
 
27
31
  it "inverse if passed a :if option" do
28
-
32
+ package = Geoffrey::Package.new
33
+ package.url("whatever")
34
+ package.options :if => Proc.new { false }
35
+ package.download_and_decompress.should == nil
36
+ package.install.should == nil
29
37
  end
30
38
 
31
39
  end
32
40
 
33
- context 'package downloading/unzipping' do
34
- # Things should be uncompressed into a temporary folder, and the
35
- # method should return where it is.
41
+ # Things should be uncompressed into a temporary folder, and the
42
+ # method should return where it is.
43
+ context 'package downloading/uncompressing' do
44
+
45
+ it "doesn't do anything if it's an unknown format" do
46
+ package = Geoffrey::Package.new
47
+ package.url(File.dirname(__FILE__) + "/static/test.txt")
48
+ package.download_and_decompress
49
+ File.read(package.file_to_install).chomp.should == "foo"
50
+ end
36
51
 
37
52
  it "smartly unzips the file if it's a zip" do
38
53
  package = Geoffrey::Package.new
39
54
  package.url(File.dirname(__FILE__) + "/static/test.txt.zip")
40
- dir = package.download_and_decompress
41
- files = Dir.glob("#{dir}/*")
42
- files.size.should == 1
43
- files.last.split("/").last.should == "test.txt"
55
+ package.download_and_decompress
56
+ File.read(package.file_to_install).chomp.should == "foo"
44
57
  end
45
58
 
46
59
  it "smartly untars the tar if it's a tar" do
47
60
  package = Geoffrey::Package.new
48
61
  package.url(File.dirname(__FILE__) + "/static/test.tar.gz")
49
- dir = package.download_and_decompress
50
- files = Dir.glob("#{dir}/*")
51
- files.size.should == 1
52
- files.last.split("/").last.should == "test.txt"
62
+ package.download_and_decompress
63
+ File.read(package.file_to_install).chomp.should == "foo"
53
64
  end
54
65
 
55
- # it "smartly ungzips if its a gzip" do
56
- # package = Geoffrey::Package.new
57
- # package.url(File.dirname(__FILE__) + "/static/test.txt.gz")
58
- # dir = package.download_and_decompress
59
- # files = Dir.glob("#{dir}/*")
60
- # files.size.should == 1
61
- # files.last.split("/").last.should == "test.txt"
62
- # end
66
+ it "smartly ungzips if its a gzip" do
67
+ package = Geoffrey::Package.new
68
+ package.url(File.dirname(__FILE__) + "/static/test.txt.gz")
69
+ package.download_and_decompress
70
+ File.read(package.file_to_install).chomp.should == "foo"
71
+ end
63
72
  end
64
73
  end
@@ -0,0 +1 @@
1
+ foo
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
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-08-28 00:00:00 +02:00
17
+ date: 2010-08-29 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -133,9 +133,9 @@ files:
133
133
  - spec/static/example.plist
134
134
  - spec/static/test.tar.gz
135
135
  - spec/static/test.tgz
136
+ - spec/static/test.txt
136
137
  - spec/static/test.txt.gz
137
138
  - spec/static/test.txt.zip
138
- - spec/template_spec.rb
139
139
  has_rdoc: true
140
140
  homepage:
141
141
  licenses: []
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
- require 'geoffrey/template'
3
-
4
- class SimpleTest < Geoffrey::Template
5
- title "Simple template test"
6
- description "It does really nice stuff"
7
- end
8
-
9
- class ExtraTest < Geoffrey::Template
10
- title "A more advanced test"
11
- description "It does even nicer stuff"
12
- end
13
-
14
- describe Geoffrey::Template do
15
-
16
- it "globally knows of all the described templates" do
17
- Geoffrey::Template.all.should == [SimpleTest, ExtraTest]
18
- end
19
-
20
- it "provides a basic way to describe actions" do
21
- SimpleTest.title.should == "Simple template test"
22
- ExtraTest.title.should == "A more advanced test"
23
- SimpleTest.description.should == "It does really nice stuff"
24
- ExtraTest.description.should == "It does even nicer stuff"
25
- end
26
- end