carboy 0.1.2
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.
- data/LICENSE +176 -0
- data/README +181 -0
- data/ROADMAP +19 -0
- data/lib/carboy.rb +249 -0
- metadata +62 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
data/README
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Copyright:
|
|
2
|
+
|
|
3
|
+
Copyright 2012 robert tomb (bikeonastick)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
License:
|
|
7
|
+
|
|
8
|
+
This project is licensed under the Licensed under the Apache License, Version 2.0. See LICENSE in this directory or http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license.
|
|
9
|
+
|
|
10
|
+
Info:
|
|
11
|
+
|
|
12
|
+
Carboy is a library that contains rake tasks you can use to deveop and deliver simple homebrew formulae. It's a homebrew tool. Carboy... get it?
|
|
13
|
+
|
|
14
|
+
To do this, you need to follow some simple steps to put yourself on track for brew-vana.
|
|
15
|
+
|
|
16
|
+
0) buy a mac (homebrew doesn't work on other platforms)
|
|
17
|
+
1) install homebrew (and setup for development)
|
|
18
|
+
2) install the carboy gem
|
|
19
|
+
3) create a directory for your project
|
|
20
|
+
4) create a Rakefile in your project directory
|
|
21
|
+
5) follow our recommended directory structure for the rest of your project files
|
|
22
|
+
6) run the Rakefile
|
|
23
|
+
7) hack, hack, hack
|
|
24
|
+
8) build your brew package
|
|
25
|
+
9) locally install your project via brew
|
|
26
|
+
10) share
|
|
27
|
+
|
|
28
|
+
0) Buy a Mac:
|
|
29
|
+
|
|
30
|
+
Figure this one out for yourself
|
|
31
|
+
|
|
32
|
+
1) Install Homebrew (and set up for development):
|
|
33
|
+
|
|
34
|
+
1.1) Basic
|
|
35
|
+
- Install Homebrew
|
|
36
|
+
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
|
|
37
|
+
- Install git if it's not installed
|
|
38
|
+
brew install git
|
|
39
|
+
- Get the git bits you need to work on homebrew
|
|
40
|
+
brew update
|
|
41
|
+
|
|
42
|
+
1.2) Advanced (for formulae you want to share but don't want to submit to homebrew)
|
|
43
|
+
- Fork homebrew
|
|
44
|
+
- Set your fork as the remote for your local homebrew's git repo
|
|
45
|
+
- cd /usr/local
|
|
46
|
+
- git remote rm origin
|
|
47
|
+
- git remote add origin git@github.com:<yourgithubuser>/homebrew.git
|
|
48
|
+
- Set the real homebrew as an upstream remote for the local repo
|
|
49
|
+
- git remote add upstream https://github.com/mxcl/homebrew.git
|
|
50
|
+
|
|
51
|
+
2) Install the carboy gem
|
|
52
|
+
- Pull it down from github and install it yourself
|
|
53
|
+
sudo rake install
|
|
54
|
+
*note*: you can uninstall with sudo rake uninstall
|
|
55
|
+
- Gem install carboy
|
|
56
|
+
|
|
57
|
+
3) Create a directory for your project
|
|
58
|
+
- Really, you want an example? OK, I'll use my-tools as an example.
|
|
59
|
+
mkdir my-tools
|
|
60
|
+
|
|
61
|
+
4) Create a Rakefile in your project directory
|
|
62
|
+
- Create Rakefile in your directory and, at a minimum, paste in the following:
|
|
63
|
+
|
|
64
|
+
require 'rubygems'
|
|
65
|
+
require 'carboy'
|
|
66
|
+
|
|
67
|
+
Carboy.new() do | c |
|
|
68
|
+
c.version = '0.1'
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
task :default => [:package]
|
|
72
|
+
|
|
73
|
+
5) Follow our recommended directory structure for the rest of your project files
|
|
74
|
+
- Carboy understands a very simple directory structure. Follow it and things will work--don't and it won't. Simple
|
|
75
|
+
my-tools
|
|
76
|
+
|+bin
|
|
77
|
+
|+formula
|
|
78
|
+
|+lib
|
|
79
|
+
|+man
|
|
80
|
+
|-Rakefile
|
|
81
|
+
|
|
82
|
+
- bin is the directory in which you place commands you want to have end up on your path. They'll be symlinked by homebrew to /usr/local/bin,
|
|
83
|
+
e.g., lrwxr-xr-x 1 roberttomb admin 32 Mar 24 10:46 /usr/local/bin/mydev -> ../Cellar/my-tools/0.1/bin/mydev
|
|
84
|
+
- lib the directory for the library code on which your commands depend.
|
|
85
|
+
- man the directory for delivering man pages to be installed with your code
|
|
86
|
+
|
|
87
|
+
With man and lib, you are required to actually deal with them in your formula, but they will be delivered in the right package structure for you to use standard homebrew commands to install them.
|
|
88
|
+
|
|
89
|
+
- formula is the directory for your... waitforit... formula!
|
|
90
|
+
|
|
91
|
+
These are the only directories supported for now. If you have more sophisticated uses for this (I'm sure someone will find a way), fork the Carboy repo and submit a pull request for it to be added.
|
|
92
|
+
|
|
93
|
+
6) run the Rakefile
|
|
94
|
+
- for fun, first run rake --task to see what you get for your six-or-so-line Rakefile
|
|
95
|
+
|
|
96
|
+
rake --task
|
|
97
|
+
rake assemble_formula # Does md5, injects into install script, and co...
|
|
98
|
+
rake assemble_prod_formula # Does md5, injects into install script, and co...
|
|
99
|
+
rake clean # Clean packaging and dist dirs
|
|
100
|
+
rake clean_test # Removes package from website, brew uninstall ...
|
|
101
|
+
rake clean_testfiles # Removes files without brew uninstall, cuz som...
|
|
102
|
+
rake hello # i say hello
|
|
103
|
+
rake package # top level packaging task
|
|
104
|
+
rake prep # Create packging and dist dirs
|
|
105
|
+
rake prep_test # Prepares files for test install: copies formu...
|
|
106
|
+
rake stagefiles # Copies files to packaging dir and injects ver...
|
|
107
|
+
rake tarzip # Tars and gzips file
|
|
108
|
+
|
|
109
|
+
- Yikes! To see more on any task, use rake -D <taskname>
|
|
110
|
+
|
|
111
|
+
7) hack, hack, hack
|
|
112
|
+
- Here's the content of my fake project
|
|
113
|
+
- bin/mydev
|
|
114
|
+
#!/usr/bin/ruby
|
|
115
|
+
require '@CELLAR@/@FORMULA@/@VER@/lib/mylib'
|
|
116
|
+
|
|
117
|
+
cmd = MyTools.new
|
|
118
|
+
cmd.hello
|
|
119
|
+
|
|
120
|
+
- lib/mylib.rb
|
|
121
|
+
class MyTools
|
|
122
|
+
def hello
|
|
123
|
+
puts "hello from #{__FILE__}"
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
- man/mydev.1
|
|
128
|
+
NAME
|
|
129
|
+
mydev -- prints a secret message
|
|
130
|
+
|
|
131
|
+
SYNOPSIS
|
|
132
|
+
mydev
|
|
133
|
+
...
|
|
134
|
+
|
|
135
|
+
- formula/my-tools.rb
|
|
136
|
+
require 'formula'
|
|
137
|
+
|
|
138
|
+
class MyTools < Formula
|
|
139
|
+
url '@URL@/@FORMULA@-@VER@.tar.gz'
|
|
140
|
+
version '@VER@'
|
|
141
|
+
homepage '@URL@'
|
|
142
|
+
md5 '@CHECKSUM@'
|
|
143
|
+
|
|
144
|
+
def install
|
|
145
|
+
bin.install "mydev"
|
|
146
|
+
lib.install "mylib.rb"
|
|
147
|
+
man1.install "mydev.1"
|
|
148
|
+
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
8) build your brew package
|
|
153
|
+
- There's a task for that!
|
|
154
|
+
rake
|
|
155
|
+
- If you want to actually test installing it locally (YES, YOU DO), make sure you have web sharing (the default web server) turned on and run
|
|
156
|
+
rake prep_test
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
FAQ
|
|
161
|
+
Q: Hey, what's with all those @SOMETHINSOMETHIN@ things in all your code?
|
|
162
|
+
A: The following variables are replaced when the packaging step happens:
|
|
163
|
+
- in your bin, lib, and man files
|
|
164
|
+
@CELLAR@ - location for brew's cellar, can be overridden in Rakefile, defaults to standard Homebrew locations
|
|
165
|
+
@NAME@ - name of your project, can be overridden in Rakefile defaults to directory name of project
|
|
166
|
+
@VER@ - value of version as set in your Rakefile
|
|
167
|
+
@FORMULA@ - the name of the formula (alias for name unless overridden in Rakefile)
|
|
168
|
+
- in your formula itself - test
|
|
169
|
+
@CHECKSUM@ - the value of the checksum as injected by the Rakefile
|
|
170
|
+
@FORMULA@ - the name of the formula (alias for name unless overridden in Rakefile)
|
|
171
|
+
@VER@ - value of version as set in your Rakefile
|
|
172
|
+
@URL@ - the value to test_url, which is created by the project
|
|
173
|
+
- in your formula itself - prod
|
|
174
|
+
@CHECKSUM@ - the value of the checksum as injected by the Rakefile
|
|
175
|
+
@FORMULA@ - the name of the formula (alias for name unless overridden in Rakefile)
|
|
176
|
+
@VER@ - value of version as set in your Rakefile
|
|
177
|
+
@URL@ - the value you set to prod_url in your Rakefile
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
data/ROADMAP
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
This project is licensed under the Licensed under the Apache License, Version 2.0.
|
|
2
|
+
See LICENSE in this directory or http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license.
|
|
3
|
+
|
|
4
|
+
Copyright 2012 robert tomb (bikeonastick)
|
|
5
|
+
|
|
6
|
+
Carboy Plans:
|
|
7
|
+
|
|
8
|
+
0.1.1
|
|
9
|
+
* initial delivery to github with minimal documentation in the form of examples
|
|
10
|
+
|
|
11
|
+
0.1.2
|
|
12
|
+
* release to rubygems
|
|
13
|
+
|
|
14
|
+
0.2...
|
|
15
|
+
* fix bug, i'm sure...
|
|
16
|
+
|
|
17
|
+
1.0
|
|
18
|
+
* add carboy scaffold command to the gem to create the shell of a homebrew dev project
|
|
19
|
+
* add the ability to use a git repo to deliver your formulae as well as gzips
|
data/lib/carboy.rb
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/tasklib'
|
|
3
|
+
|
|
4
|
+
#
|
|
5
|
+
# A ruby library of standard rake tasks for building and packaging Homebrew formulae. Find
|
|
6
|
+
# information on homebrew here:
|
|
7
|
+
#
|
|
8
|
+
# * http://mxcl.github.com/homebrew/
|
|
9
|
+
#
|
|
10
|
+
# Find information on creating homebrew formulae:
|
|
11
|
+
#
|
|
12
|
+
# * https://github.com/adamv/homebrew-cookbook/tree/master/topics
|
|
13
|
+
# * https://github.com/mxcl/homebrew/wiki/Formula-Cookbook
|
|
14
|
+
#
|
|
15
|
+
# The idea for creating a library of rake tasks comes from here:
|
|
16
|
+
#
|
|
17
|
+
# * http://rake.rubyforge.org/classes/Rake/PackageTask.html#M000058
|
|
18
|
+
#
|
|
19
|
+
# More documentation on Carboy here:
|
|
20
|
+
# * https://github.com/bikeonastick/Carboy
|
|
21
|
+
# * http://bikeonastick.blogspot.com/p/open-source-projects.html#carboy
|
|
22
|
+
#
|
|
23
|
+
# Author:: robert tomb (mailto: bikeonastick@gmail.com)
|
|
24
|
+
# Copyright:: Copyright 2012 robert tomb (bikeonastick)
|
|
25
|
+
# License:: This project is licensed under the Licensed under the Apache License, Version 2.0. See LICENSE or http://www.apache.org/licenses/LICENSE-2.0 for a copy of the license.
|
|
26
|
+
#
|
|
27
|
+
class Carboy < Rake::TaskLib
|
|
28
|
+
|
|
29
|
+
# the name of your project, which defaults to the name of the project directory (parent dir for the Rakefile) if not set
|
|
30
|
+
attr_accessor :name
|
|
31
|
+
# a way to override the Homebrew location for alternate installs
|
|
32
|
+
attr_accessor :brew
|
|
33
|
+
# Your project version, this is REQUIRED. Can be a string, date, or number sequence. It will be used in filenames. Use filename-safe chars.
|
|
34
|
+
attr_accessor :version
|
|
35
|
+
# The url to where your test site is for installation, defaults to http://localhost/~<username>/
|
|
36
|
+
attr_accessor :test_url
|
|
37
|
+
# The local directory path to your test site, defaults to ~/Sites
|
|
38
|
+
attr_accessor :test_site_dir
|
|
39
|
+
# The production url for where your homebrew package will be accessed by other users.
|
|
40
|
+
attr_accessor :prod_url
|
|
41
|
+
# Assuming you have filesystem access to your production site directory... DON'T USE, RESERVED FOR FUTURE USE.
|
|
42
|
+
attr_accessor :prod_site_dir
|
|
43
|
+
# For future GIT repo support
|
|
44
|
+
attr_accessor :test_repo
|
|
45
|
+
# For future GIT repo support
|
|
46
|
+
attr_accessor :prod_repo
|
|
47
|
+
# For future GIT repo support
|
|
48
|
+
attr_accessor :repo_tag
|
|
49
|
+
|
|
50
|
+
# For future GIT repo support
|
|
51
|
+
attr_reader :is_repo
|
|
52
|
+
# For future GIT repo support
|
|
53
|
+
attr_reader :is_package
|
|
54
|
+
# if, for some reason, you need to know where the cellar is...
|
|
55
|
+
attr_reader :cellar
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# Allows you to call with a block (see examples) and set values. The only required value
|
|
59
|
+
# is @version, all others are set to resonable defaults.
|
|
60
|
+
#
|
|
61
|
+
def initialize()
|
|
62
|
+
@is_repo = false
|
|
63
|
+
@is_package = true
|
|
64
|
+
@name = nil
|
|
65
|
+
@brew = nil
|
|
66
|
+
@version = nil
|
|
67
|
+
|
|
68
|
+
yield self if block_given?
|
|
69
|
+
|
|
70
|
+
usr =`whoami`.chomp
|
|
71
|
+
@test_site_dir = ( @test_site_dir == nil)? "/Users/#{usr}/Sites" : @test_site_dir
|
|
72
|
+
@test_url = ( @test_url == nil)? "http://localhost/~#{usr}" : @test_url
|
|
73
|
+
@brew = (@brew == nil)? '/usr/local' : @brew
|
|
74
|
+
@cellar = (@cellar == nil)? "#{@brew}/Cellar" : @cellar
|
|
75
|
+
@name = (name == nil) ? File.basename(Dir::pwd) : name
|
|
76
|
+
@formula = @name
|
|
77
|
+
unless @version == nil
|
|
78
|
+
define()
|
|
79
|
+
else
|
|
80
|
+
raise "No version set, we can't do anything for you without it."
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
#
|
|
85
|
+
# A vestige of an earlier idea. It's a lot like your appendix.
|
|
86
|
+
#
|
|
87
|
+
def init(name)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def is_repo=(isit)
|
|
91
|
+
@is_repo = isit
|
|
92
|
+
@is_package = !isit
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def is_package=(isit)
|
|
96
|
+
@is_package = isit
|
|
97
|
+
@is_repo = !isit
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
#
|
|
101
|
+
# The predefined tasks you get by instantiating the Carboy class in your Rakefile:
|
|
102
|
+
# * hello: my first test task, it's rather quaint, so I kept it.
|
|
103
|
+
# * package - delegates to assemble_formula
|
|
104
|
+
# * prep - creates packaging and assemply directories
|
|
105
|
+
# * clean - removes packaging directories
|
|
106
|
+
# * stagefiles - copies files for packaging and does some variable substitution
|
|
107
|
+
# * tarzip - tars and zips your file
|
|
108
|
+
# * assemble_prod_formula - inserts prod_url into formula for download, does MD5 on package, injects that into formula
|
|
109
|
+
# * assemble_formula - inserts test_url into formula for download, does MD5 on package, injects that into formula
|
|
110
|
+
# * prep_test - puts the package file into your test_site_dir, and formula into homebrew's dir structure
|
|
111
|
+
# * clean_test - removes package file from test_site_dir and the formula from homebrew
|
|
112
|
+
# * clean_testfiles - cleans all known test files (even hidden homebrew caches)
|
|
113
|
+
#
|
|
114
|
+
def define
|
|
115
|
+
desc "i say hello"
|
|
116
|
+
task :hello do
|
|
117
|
+
puts "hello #{@name} from #{__FILE__}"
|
|
118
|
+
puts "where #{$0}"
|
|
119
|
+
puts "here #{self}"
|
|
120
|
+
puts "here #{Dir::pwd}"
|
|
121
|
+
puts "here #{@name}"
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
desc "top level packaging task"
|
|
125
|
+
task :package => [:assemble_formula] do
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
desc "Create packging and dist dirs"
|
|
129
|
+
task :prep do
|
|
130
|
+
mkdir "dist"
|
|
131
|
+
mkdir_p "assemble/#{@formula}"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
desc "Clean packaging and dist dirs"
|
|
135
|
+
task :clean do
|
|
136
|
+
if(File.exists?("dist"))
|
|
137
|
+
rm_r "dist"
|
|
138
|
+
end
|
|
139
|
+
if(File.exists?("assemble"))
|
|
140
|
+
rm_r "assemble"
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
desc "Copies files to packaging dir and injects version"
|
|
145
|
+
task :stagefiles => [:prep] do
|
|
146
|
+
fn = "mydev"
|
|
147
|
+
toSub = {"@NAME@" => @name, "@CELLAR@" => @cellar, "@VER@" => @version, "@FORMULA@" => @formula}
|
|
148
|
+
d = "assemble/#{@formula}/#{fn}"
|
|
149
|
+
s = "bin/#{fn}"
|
|
150
|
+
copyFileReplVars(s,d,toSub)
|
|
151
|
+
copy("lib/mylib.rb","assemble/#{@formula}/mylib.rb")
|
|
152
|
+
copy("man/#{fn}.1","assemble/#{@formula}/#{fn}.1")
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
desc "Tars and gzips file"
|
|
156
|
+
task :tarzip => [:stagefiles] do
|
|
157
|
+
tf_name = "../dist/#{@formula}-#{@version}.tar"
|
|
158
|
+
cd "assemble"
|
|
159
|
+
`tar -cvf #{tf_name} #{@formula}`
|
|
160
|
+
cd ".."
|
|
161
|
+
`gzip dist/#{tf_name}`
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
desc "Does md5, injects into install script, and copies to dist for PRODUCTION"
|
|
165
|
+
task :assemble_prod_formula => [:tarzip] do
|
|
166
|
+
md5 = `md5 -q dist/#{@formula}-#{@version}.tar.gz`
|
|
167
|
+
checksum = md5.chomp
|
|
168
|
+
fn = "#{@formula}.rb"
|
|
169
|
+
to = "dist/#{fn}"
|
|
170
|
+
from = "formula/#{fn}"
|
|
171
|
+
toSub = { "@CHECKSUM@" => checksum,
|
|
172
|
+
"@FORMULA@" => @formula,
|
|
173
|
+
"@VER@" => @version,
|
|
174
|
+
"@URL@" => @prod_url
|
|
175
|
+
}
|
|
176
|
+
copyFileReplVars(from,to,toSub)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
desc "Does md5, injects into install script, and copies to dist for TEST"
|
|
180
|
+
task :assemble_formula => [:tarzip] do
|
|
181
|
+
md5 = `md5 -q dist/#{@formula}-#{@version}.tar.gz`
|
|
182
|
+
checksum = md5.chomp
|
|
183
|
+
fn = "#{@formula}.rb"
|
|
184
|
+
to = "dist/#{fn}"
|
|
185
|
+
from = "formula/#{fn}"
|
|
186
|
+
toSub = { "@CHECKSUM@" => checksum,
|
|
187
|
+
"@FORMULA@" => @formula,
|
|
188
|
+
"@VER@" => @version,
|
|
189
|
+
"@URL@" => @test_url
|
|
190
|
+
}
|
|
191
|
+
copyFileReplVars(from,to,toSub)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
desc "Prepares files for test install: copies formula to /usr/local/Library/Formula and tarball to ~/Sites"
|
|
195
|
+
task :prep_test => [:clean, :assemble_formula] do
|
|
196
|
+
copy("dist/#{@formula}.rb","#{@brew}/Library/Formula/#{@formula}.rb")
|
|
197
|
+
copy("dist/#{@formula}-#{@version}.tar.gz","#{@test_site_dir}")
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
desc "Removes package from website, brew uninstall formula, removes formula.rb"
|
|
201
|
+
task :clean_test do
|
|
202
|
+
out = `brew uninstall #{@formula}`
|
|
203
|
+
puts out
|
|
204
|
+
Rake::Task["clean_testfiles"].invoke
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
desc "Removes files without brew uninstall, cuz sometimes the install goes terribly wrong."
|
|
208
|
+
task :clean_testfiles do
|
|
209
|
+
begin
|
|
210
|
+
rm "#{@brew}/Library/Formula/#{@formula}.rb"
|
|
211
|
+
rescue
|
|
212
|
+
end
|
|
213
|
+
begin
|
|
214
|
+
rm "#{@test_site_dir}/#{@formula}-#{@version}.tar.gz"
|
|
215
|
+
rescue
|
|
216
|
+
end
|
|
217
|
+
begin
|
|
218
|
+
usr = `whoami`.chomp
|
|
219
|
+
rm "/Users/#{usr}/Library/Caches/Homebrew/#{@formula}-#{@version}.tar.gz"
|
|
220
|
+
rescue
|
|
221
|
+
end
|
|
222
|
+
begin
|
|
223
|
+
rm "/Library/Caches/Homebrew/#{@formula}-#{@version}.tar.gz"
|
|
224
|
+
rescue
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
#
|
|
232
|
+
# Copies a file from one location to another and replaces values in the file
|
|
233
|
+
# based on the contents of the map. It just does a straight search for the key
|
|
234
|
+
# and replaces it with the value.
|
|
235
|
+
#
|
|
236
|
+
def copyFileReplVars(relPathFromFn,relPathToFn,submap)
|
|
237
|
+
destination = File.new(relPathToFn, "w+")
|
|
238
|
+
from = File.open(relPathFromFn)
|
|
239
|
+
lines = from.readlines
|
|
240
|
+
lines.each {|ln|
|
|
241
|
+
submap.each_pair{|key,value|
|
|
242
|
+
ln.gsub!(/#{key}/,value)
|
|
243
|
+
}
|
|
244
|
+
destination.puts ln
|
|
245
|
+
}
|
|
246
|
+
destination.close
|
|
247
|
+
from.close
|
|
248
|
+
end
|
|
249
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: carboy
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- robert tomb
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2012-03-24 00:00:00 -05:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: When building homebrew formulae, there's a process needed to build and deliver them. Add this to your rakefile and you'll automatically get the standard rake targets needed to deliver. These targets expect a standard directory structure and two collections to drive the process.
|
|
17
|
+
email: bikeonastick@gmail.com
|
|
18
|
+
executables: []
|
|
19
|
+
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
|
|
24
|
+
files:
|
|
25
|
+
- lib/carboy.rb
|
|
26
|
+
- LICENSE
|
|
27
|
+
- README
|
|
28
|
+
- ROADMAP
|
|
29
|
+
has_rdoc: true
|
|
30
|
+
homepage: http://bikeonastick.blogspot.com/p/open-source-projects.html#carboy
|
|
31
|
+
licenses:
|
|
32
|
+
- Apache License, Version 2.0
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options:
|
|
35
|
+
- --title
|
|
36
|
+
- "carboy: a tool for homebrew formulae"
|
|
37
|
+
- --main
|
|
38
|
+
- README
|
|
39
|
+
- --line-numbers
|
|
40
|
+
require_paths:
|
|
41
|
+
- lib
|
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: "0"
|
|
47
|
+
version:
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 1.3.5
|
|
53
|
+
version:
|
|
54
|
+
requirements: []
|
|
55
|
+
|
|
56
|
+
rubyforge_project:
|
|
57
|
+
rubygems_version: 1.3.5
|
|
58
|
+
signing_key:
|
|
59
|
+
specification_version: 3
|
|
60
|
+
summary: A gem to be used in rakefiles for simplified homebrew packaging.
|
|
61
|
+
test_files: []
|
|
62
|
+
|