juretta-ipt 1.0.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.
- data/README.md +221 -0
- data/Rakefile +16 -0
- data/ipt.gemspec +19 -0
- data/tasks/changelog.tmpl +63 -0
- data/tasks/iphone_tools.rake +304 -0
- metadata +57 -0
data/README.md
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
Xcode iPhone Project Tools
|
2
|
+
==========================
|
3
|
+
|
4
|
+
Useful rake tasks and scripts for iPhone development using Xcode.
|
5
|
+
Some tasks rely on external software. Please read the installation instructions.
|
6
|
+
|
7
|
+
The scm related tasks assume that you are using git. You can just ignore those tasks
|
8
|
+
and scripts if you are using a different scm.
|
9
|
+
|
10
|
+
Installation
|
11
|
+
==================
|
12
|
+
|
13
|
+
1. Install the iPhone Project Tools (ipt) gem
|
14
|
+
|
15
|
+
sudo gem install juretta-ipt --source http://gems.github.com
|
16
|
+
2. Adde the following lines to your Rakefile:
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
gem 'ipt'
|
20
|
+
load 'iphone_tools.rake'
|
21
|
+
|
22
|
+
PNGCRUSH
|
23
|
+
--------
|
24
|
+
If you want to use the image optimization task the "pngcrush" binary needs to be available. Check with:
|
25
|
+
stefan@macbook-pro-2:~$ which pngcrush
|
26
|
+
/opt/local/bin/pngcrush
|
27
|
+
|
28
|
+
You can install pngcrush using [Macports](http://www.macports.org/):
|
29
|
+
|
30
|
+
sudo port install pngcrush
|
31
|
+
|
32
|
+
CLANG
|
33
|
+
-----
|
34
|
+
If you want to use the static code analysis task (highly recommended). You have to download the checker binary.
|
35
|
+
|
36
|
+
stefan@macbook-pro-2:~/temp$ curl -OL http://keeda.stanford.edu/~kremenek/checker/checker-107.tar.bz2
|
37
|
+
stefan@macbook-pro-2:~/temp$ tar xjf checker-107.tar.bz2 -C /Users/stefan/dev/iphone/clang
|
38
|
+
|
39
|
+
Add the path to the extracted directory to your PATH environment variable. E.g. in ~/.bash_profile
|
40
|
+
|
41
|
+
export CLANG=/Users/stefan/dev/iphone/clang/checker-107
|
42
|
+
export PATH=$PATH:$CLANG
|
43
|
+
|
44
|
+
Rake tasks
|
45
|
+
==========
|
46
|
+
|
47
|
+
The Rakefile contains tasks that are valueable for iPhone development.
|
48
|
+
It defines tasks to:
|
49
|
+
|
50
|
+
* Minimze PNG image size using [pngcrush][1]
|
51
|
+
* Do static code analysis using the [LLVM/Clang Static Analyzer][2]
|
52
|
+
* Create a XML/HTML changelog using the git commit log.
|
53
|
+
* Generate an HTML README file using an existing markdown, textile or RDoc formatted README.* file
|
54
|
+
* List TODO|FIXME|IMPROVE marker.
|
55
|
+
|
56
|
+
[1]: http://pmt.sourceforge.net/pngcrush/
|
57
|
+
[2]: http://clang.llvm.org/StaticAnalysis.html
|
58
|
+
|
59
|
+
In your Xcode project directory run:
|
60
|
+
rake -T
|
61
|
+
to show the available tasks:
|
62
|
+
|
63
|
+
rake ipt:analyze # Analyze code
|
64
|
+
rake ipt:clean # Clean build artifacts
|
65
|
+
rake ipt:dist:show # Show all bundle identifier
|
66
|
+
rake ipt:git:changelog # Create a changelog (doc/changelog.html and doc/...
|
67
|
+
rake ipt:optimize_images # Reduce image filesize using pngcrush
|
68
|
+
rake ipt:readme # Create README.html from existing README.* text ...
|
69
|
+
rake ipt:todo # List TODO|FIXME|IMPROVE tags
|
70
|
+
|
71
|
+
|
72
|
+
Image size optimization
|
73
|
+
-----------------------
|
74
|
+
pngcrush is an open source, free command line computer program that reduces the size of PNG files.
|
75
|
+
The compression is lossless, meaning that the resulting image will have the same quality as the source image.
|
76
|
+
|
77
|
+
The original files will be saved in a _backup folder inside the project directory.
|
78
|
+
|
79
|
+
To optimize the png images in your Xcode project directory run:
|
80
|
+
rake ipt:optimize_images
|
81
|
+
|
82
|
+
Static code analysis
|
83
|
+
--------------------
|
84
|
+
|
85
|
+
> The LLVM/Clang static analyzer is a standalone tool that find bugs in C and Objective-C programs.
|
86
|
+
|
87
|
+
Run 'rake ipt:analyze' to run the clang checker. The output of the analyzer is
|
88
|
+
a set of html files containing bug descriptions and source code location.
|
89
|
+
If bugs are found the tool will open a web browser with the bug report.
|
90
|
+
If no bugs are found (which doesn't mean there aren't any!) the tool will exit without further action.
|
91
|
+
|
92
|
+
Please visit the [LLVM/Clang homepage](http://clang.llvm.org/StaticAnalysis.html) to learn more
|
93
|
+
about the "Clang checker".
|
94
|
+
You should probably read the [Recommended Usage Guidelines](http://clang.llvm.org/StaticAnalysisUsage.html#RecommendedUsageGuidelines).
|
95
|
+
|
96
|
+
To run the code analysis run:
|
97
|
+
rake ipt:analyze
|
98
|
+
|
99
|
+
|
100
|
+
Generate HTML-Readme files
|
101
|
+
--------------------------
|
102
|
+
|
103
|
+
If your Xcode project directory contains a README.{md,markdown,text,textile,rdoc} file
|
104
|
+
you can run the
|
105
|
+
|
106
|
+
rake ipt:readme
|
107
|
+
|
108
|
+
task to generate HTML Readme files.
|
109
|
+
|
110
|
+
Supported formats:
|
111
|
+
|
112
|
+
* [Markdown][3]: README.md, README.markdown
|
113
|
+
* [Textile][4]: README.text, README.textile
|
114
|
+
* Ruby [RDoc][5]: README.rdoc
|
115
|
+
|
116
|
+
[3]: http://daringfireball.net/projects/markdown/
|
117
|
+
[4]: http://textism.com/tools/textile/
|
118
|
+
[5]: http://rdoc.sourceforge.net/doc/
|
119
|
+
|
120
|
+
Unit testing with rbiphonetest
|
121
|
+
------------------------------
|
122
|
+
|
123
|
+
This is not included in this Rakefile. Have a look at [rbiphonetest][6] if you want to easily test your Foundation classes.
|
124
|
+
The rbiphonetest git repository lives here: (http://github.com/drnic/rbiphonetest/tree/master)
|
125
|
+
|
126
|
+
[6]: http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest/
|
127
|
+
|
128
|
+
|
129
|
+
Xcode and git
|
130
|
+
=============
|
131
|
+
|
132
|
+
Xcode does not directly support git as a SCM but git can still be used to manage the source code of an Xcode project.
|
133
|
+
|
134
|
+
git related Rake tasks
|
135
|
+
----------------------
|
136
|
+
|
137
|
+
Run the
|
138
|
+
rake ipt:git:changelog
|
139
|
+
task to generate an HTML and XMl changelog file in the 'doc' subdirectory in your Xcode project directory.
|
140
|
+
The updated changelog files will be added and commited to your local git repository automatically.
|
141
|
+
|
142
|
+
Xcode git .gitignore
|
143
|
+
--------------------
|
144
|
+
Copy the following lines into your PROJECT_DIR/.gitignore file to ignore Xcode build artifacts and
|
145
|
+
user specific settings:
|
146
|
+
|
147
|
+
build
|
148
|
+
*.mode1v3
|
149
|
+
*.mode2v3
|
150
|
+
*.nib
|
151
|
+
.DS_Store
|
152
|
+
*.swp
|
153
|
+
*.pbxuser
|
154
|
+
*.perspective
|
155
|
+
*.perspectivev3
|
156
|
+
|
157
|
+
Xcode git build number script
|
158
|
+
-----------------------------
|
159
|
+
|
160
|
+
Inspired by: http://www.cimgf.com/2008/04/13/git-and-xcode-a-git-build-number-script/
|
161
|
+
|
162
|
+
[CFBundleVersion](http://developer.apple.com/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/PListKeys.html#//apple_ref/doc/uid/20001431-102364)
|
163
|
+
|
164
|
+
> This key specifies the build version number of the bundle, which identifies an iteration
|
165
|
+
> (released or unreleased) of the bundle. This is a monotonically increased string,
|
166
|
+
> comprised of one or more period-separated integers. This key is not localizable.
|
167
|
+
|
168
|
+
The problem with most "Xcode git versioning scripts" is that they use the git commit id as a CFBundleVersion identifier.
|
169
|
+
The Apple App-Store requires an bundle identifier as describe above (e.g. 1.0 or 2.3.1).
|
170
|
+
|
171
|
+
I use the following workflow to set version numbers for my Xcode project:
|
172
|
+
|
173
|
+
1. tag the current release snapshot using
|
174
|
+
|
175
|
+
git tag 1.0.1
|
176
|
+
|
177
|
+
You can list all you tags using:
|
178
|
+
|
179
|
+
git tag
|
180
|
+
|
181
|
+
To check which tag is going to be used as you version numer use:
|
182
|
+
|
183
|
+
git describe --tags
|
184
|
+
2. run Xcode build with the script that follows (which basically uses 'git describe --tags' to determine the most recent tag that is reachable from a commit)
|
185
|
+
3. check CFBundleVersion value in all build artifacts using the rake task 'dist:show'
|
186
|
+
|
187
|
+
rake ipt:dist:show
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
In Xcode add a new script build phase:
|
192
|
+
Targets > Add > New Build Phase > New Run Script Build Phase
|
193
|
+
|
194
|
+
Messages written to $stdout will end up in the XCode build log (CMD + Shift + B).
|
195
|
+
|
196
|
+
Use /path/to/ruby as the 'Shell' parameter. This is usually /usr/bin/ruby but might
|
197
|
+
be different if you have a custom ruby installation (mine is /opt/local/bin/ruby).
|
198
|
+
Run 'which ruby' in your terminal to determine the correct path to your Ruby
|
199
|
+
executable.
|
200
|
+
|
201
|
+
require 'rubygems'
|
202
|
+
begin
|
203
|
+
require 'Plist'
|
204
|
+
rescue LoadError => e
|
205
|
+
puts "You need to install the 'Plist' gem: [sudo] gem install plist"
|
206
|
+
exit 1
|
207
|
+
end
|
208
|
+
|
209
|
+
raise "Must be run from Xcode" unless ENV['XCODE_VERSION_ACTUAL']
|
210
|
+
|
211
|
+
GIT="/opt/local/bin/git"
|
212
|
+
PLIST_FILE = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['WRAPPER_NAME'], 'Info.plist')
|
213
|
+
|
214
|
+
if File.file?(PLIST_FILE)
|
215
|
+
pl = Plist::parse_xml(PLIST_FILE)
|
216
|
+
if pl
|
217
|
+
pl["CFBundleVersion"] = `#{GIT} git describe --tags`.to_s
|
218
|
+
pl.save_plist(PLIST_FILE)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# Author Stefan Saasen (coravy.com)
|
3
|
+
#
|
4
|
+
# ============== Load rake tasks ================
|
5
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
6
|
+
|
7
|
+
# or (if you've installed the ipt gem)
|
8
|
+
# require 'rubygems'
|
9
|
+
# gem 'ipt'
|
10
|
+
# load 'iphone_tools.rake'
|
11
|
+
|
12
|
+
# =========== Your custom rake tasks ============
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
data/ipt.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "ipt"
|
3
|
+
s.version = "1.0.5"
|
4
|
+
s.date = "2008-11-11"
|
5
|
+
s.summary = "iPhone Project Tools"
|
6
|
+
s.email = "s@juretta.com"
|
7
|
+
s.homepage = "http://github.com/juretta/iphone-project-tools"
|
8
|
+
s.description = "Useful rake tasks and scripts for iPhone development using Xcode."
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.require_path = 'tasks'
|
11
|
+
s.authors = ["Stefan Saasen"]
|
12
|
+
s.files = [
|
13
|
+
"README.md",
|
14
|
+
"Rakefile",
|
15
|
+
"ipt.gemspec",
|
16
|
+
"tasks/changelog.tmpl",
|
17
|
+
"tasks/iphone_tools.rake"]
|
18
|
+
s.extra_rdoc_files = ["README.md"]
|
19
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<!-- $Id$ -->
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<meta http-equiv="imagetoolbar" content="no" />
|
8
|
+
<meta http-equiv="content-language" content="en" />
|
9
|
+
<meta name="MSSmartTagsPreventParsing" content="true" />
|
10
|
+
|
11
|
+
<style type="text/css" media="screen">
|
12
|
+
/* <![CDATA[ */
|
13
|
+
:link,:visited {text-decoration:none}
|
14
|
+
ul,ol {list-style:none}
|
15
|
+
h1,h2,h3,h4,h5,h6,pre,code {font-size:1em;}
|
16
|
+
h1 {
|
17
|
+
font-size: 1.4em;
|
18
|
+
}
|
19
|
+
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input
|
20
|
+
{ margin:0; padding:0 }
|
21
|
+
a img,:link img,:visited img {border:none}
|
22
|
+
address {font-style:normal}
|
23
|
+
|
24
|
+
body, h2, h1 {
|
25
|
+
font-family: Monaco,"Courier New",monospace;
|
26
|
+
}
|
27
|
+
|
28
|
+
#wrapper {
|
29
|
+
width: 80%;
|
30
|
+
margin: 10%;
|
31
|
+
}
|
32
|
+
|
33
|
+
div.commit {
|
34
|
+
margin: 1.5em 0;
|
35
|
+
border-bottom: 1px solid silver;
|
36
|
+
}
|
37
|
+
|
38
|
+
span.author, span.date {
|
39
|
+
display: block;
|
40
|
+
margin: 0.2em 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
pre.msg {
|
44
|
+
margin: 1em 0;
|
45
|
+
}
|
46
|
+
|
47
|
+
pre {
|
48
|
+
font-family:Monaco,"Courier New",monospace;
|
49
|
+
font-size:90%;
|
50
|
+
text-align: left;
|
51
|
+
}
|
52
|
+
|
53
|
+
/* ]]> */
|
54
|
+
</style>
|
55
|
+
|
56
|
+
<title>Changelog</title>
|
57
|
+
</head>
|
58
|
+
<body>
|
59
|
+
<div id="wrapper">
|
60
|
+
@html@
|
61
|
+
</div>
|
62
|
+
</body>
|
63
|
+
</html>
|
@@ -0,0 +1,304 @@
|
|
1
|
+
# Author Stefan Saasen (coravy.com)
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
BUILD_DIR = "./build"
|
7
|
+
|
8
|
+
module IPT
|
9
|
+
|
10
|
+
module README
|
11
|
+
|
12
|
+
class AbstractFormatter
|
13
|
+
def self.supports(ext)
|
14
|
+
return supported_formats.include?(ext)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class PlainFormatter < AbstractFormatter
|
19
|
+
def self.supported_formats
|
20
|
+
%w(txt)
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_html(input)
|
24
|
+
input
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class MarkdownFormatter < AbstractFormatter
|
29
|
+
def self.supported_formats
|
30
|
+
%w(md markdown)
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
begin
|
35
|
+
require 'bluecloth'
|
36
|
+
rescue LoadError => e
|
37
|
+
puts "The bluecloth gem is required if you want to create HTML Readme files."
|
38
|
+
puts "Install using: sudo gem install BlueCloth"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_html(input)
|
43
|
+
BlueCloth.new(input).to_html
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class TextileFormatter < AbstractFormatter
|
48
|
+
def self.supported_formats
|
49
|
+
%w(text textile)
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize
|
53
|
+
begin
|
54
|
+
require 'RedCloth'
|
55
|
+
rescue LoadError => e
|
56
|
+
puts "The RedCloth gem is required if you want to create HTML Readme files."
|
57
|
+
puts "Install using: sudo gem install RedCloth"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def to_html(input)
|
62
|
+
RedCloth.new(input).to_html
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class RdocFormatter < AbstractFormatter
|
67
|
+
def self.supported_formats
|
68
|
+
%w(rdoc)
|
69
|
+
end
|
70
|
+
|
71
|
+
def initialize
|
72
|
+
require 'rdoc/markup/simple_markup'
|
73
|
+
require 'rdoc/markup/simple_markup/to_html'
|
74
|
+
end
|
75
|
+
|
76
|
+
def to_html(input)
|
77
|
+
p = SM::SimpleMarkup.new
|
78
|
+
h = SM::ToHtml.new
|
79
|
+
p.convert(input, h)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Formatter
|
84
|
+
PATTERN = "README.{text,textile,rdoc,md,markdown}"
|
85
|
+
FORMATTER = [MarkdownFormatter, TextileFormatter, RdocFormatter]
|
86
|
+
def initialize(root_dir)
|
87
|
+
@dir = root_dir
|
88
|
+
end
|
89
|
+
|
90
|
+
def find_readme
|
91
|
+
Dir["#{@dir}/#{PATTERN}"].first
|
92
|
+
end
|
93
|
+
|
94
|
+
def find_formatter(file)
|
95
|
+
ext = file.split(/\./).last
|
96
|
+
FORMATTER.each do |f|
|
97
|
+
if f.supports(ext)
|
98
|
+
return f
|
99
|
+
end
|
100
|
+
end
|
101
|
+
PlainFormatter # Default formatter
|
102
|
+
end
|
103
|
+
|
104
|
+
def to_html
|
105
|
+
readme_file = find_readme
|
106
|
+
if readme_file && File.file?(readme_file)
|
107
|
+
File.open("readme.html", "w") do |f|
|
108
|
+
f << find_formatter(readme_file).new.to_html(IO.readlines(readme_file).join)
|
109
|
+
end
|
110
|
+
else
|
111
|
+
puts "No #{PATTERN}s file could be found."
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end # class Formatter
|
115
|
+
end # module Formatter
|
116
|
+
|
117
|
+
class TagExtraction
|
118
|
+
def grep(pattern, ignore = /Auto-generated/)
|
119
|
+
formatter = Formatter.new
|
120
|
+
traverse do |file|
|
121
|
+
count, match, buffer = 0, false, []
|
122
|
+
open(file) do |f|
|
123
|
+
while line = f.gets
|
124
|
+
count += 1
|
125
|
+
if line =~ pattern && line !~ ignore
|
126
|
+
match = true
|
127
|
+
buffer << "#{count.to_s.rjust(8)}: #{line.strip}"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
if match
|
131
|
+
puts "\n#{formatter.yellow(file)}"
|
132
|
+
puts buffer.join("\n")
|
133
|
+
puts "\n"
|
134
|
+
formatter.reset!
|
135
|
+
end
|
136
|
+
match = false
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def traverse
|
142
|
+
Dir['**/*.{m,h,txt,md,markdown,rdoc,text}'].each do |fn|
|
143
|
+
yield fn
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end # TagExtraction
|
147
|
+
|
148
|
+
class Formatter
|
149
|
+
def initialize
|
150
|
+
reset!
|
151
|
+
end
|
152
|
+
|
153
|
+
def yellow(txt)
|
154
|
+
@buffer << "\033[33m#{txt}\033[0m"
|
155
|
+
self
|
156
|
+
end
|
157
|
+
|
158
|
+
def clear(txt)
|
159
|
+
@buffer << txt
|
160
|
+
self
|
161
|
+
end
|
162
|
+
|
163
|
+
def reset!
|
164
|
+
@buffer = []
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_s
|
168
|
+
@buffer.join('')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
# Tries to determine the absolute path to the given binary.
|
175
|
+
def find_binary(name)
|
176
|
+
ENV["PATH"].split(":").each do |dir| # we are on a mac anyway
|
177
|
+
path = File.join(dir, name)
|
178
|
+
if File.executable?(path)
|
179
|
+
puts "Found '#{name}' in #{dir}" if $DEBUG
|
180
|
+
return File.expand_path(path)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
raise "Unable to find #{name} in the system PATH. Add /path/to/#{name} to your $PATH"
|
184
|
+
end
|
185
|
+
|
186
|
+
namespace :ipt do
|
187
|
+
|
188
|
+
namespace :dist do
|
189
|
+
desc "Show all bundle identifier"
|
190
|
+
task :show do
|
191
|
+
puts "No build artifacts" unless File.directory?(BUILD_DIR)
|
192
|
+
tag = `#{find_binary('git')} describe --tags`.to_s
|
193
|
+
puts "\nCurrent git tag: #{tag}"
|
194
|
+
Dir["#{BUILD_DIR}/**/Info.plist"].each do |path|
|
195
|
+
if File.file?(path)
|
196
|
+
type = `file #{path}`
|
197
|
+
xml = type =~ /Apple binary property list/ ? `plutil -convert xml1 -o - #{path}` : path
|
198
|
+
pl = Plist::parse_xml(xml)
|
199
|
+
if pl
|
200
|
+
puts "File: #{path}"
|
201
|
+
puts "CFBundleVersion: #{pl['CFBundleVersion']}".strip
|
202
|
+
puts ""
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
desc "Reduce image filesize using pngcrush"
|
212
|
+
task :optimize_images do
|
213
|
+
binary = find_binary("pngcrush")
|
214
|
+
backup = "#{Dir.pwd}/_backup"
|
215
|
+
mkdir backup unless File.directory?(backup)
|
216
|
+
mv Dir['*.png'], backup
|
217
|
+
Dir["#{backup}/*.png"].each do |png|
|
218
|
+
sh "#{binary} -d ./ -l 9 -brute -rem gAMA -rem cHRM -rem iCCP -rem sRGB #{png}"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
desc "List TODO|FIXME|IMPROVE tags"
|
223
|
+
task :todo do
|
224
|
+
IPT::TagExtraction.new.grep(/TODO|FIXME|IMPROVE/i)
|
225
|
+
end
|
226
|
+
|
227
|
+
desc "Create README.html from existing README.* text file (markdown, textile, rdoc support)."
|
228
|
+
task :readme do
|
229
|
+
f = IPT::README::Formatter.new(".")
|
230
|
+
f.to_html
|
231
|
+
end
|
232
|
+
|
233
|
+
desc "Analyze code"
|
234
|
+
task :analyze do
|
235
|
+
# Add to Path: /Users/stefan/dev/iphone/checker-75
|
236
|
+
begin
|
237
|
+
binary = find_binary("scan-build")
|
238
|
+
sh "#{binary} -v -V xcodebuild -configuration Debug" do |ok, res|
|
239
|
+
puts "Failed to run the analyze task (status: #{res.exitstatus})" if !ok
|
240
|
+
end
|
241
|
+
rescue => e
|
242
|
+
puts "Please install the LLVM/Clang checker: http://clang.llvm.org/StaticAnalysis.html"
|
243
|
+
puts "and add the directory containing the 'scan-build' binary to your $PATH"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
desc "Clean build artifacts"
|
248
|
+
task :clean do
|
249
|
+
sh "xcodebuild clean"
|
250
|
+
rm_rf "readme.html"
|
251
|
+
end
|
252
|
+
|
253
|
+
namespace :git do
|
254
|
+
desc "Create a changelog (doc/changelog.html and doc/changelog.xml) based on your git commits."
|
255
|
+
task :changelog do
|
256
|
+
require 'time'
|
257
|
+
require 'rexml/document'
|
258
|
+
|
259
|
+
DOC_DIR = "#{Dir.pwd}/doc"
|
260
|
+
|
261
|
+
# Create commit messages xml as part of the documentation in doc/
|
262
|
+
xml_body=`git log --pretty=format:'<commit id="%H">%n<date>%aD</date>%n<author><![CDATA[%an]]></author><author-email><![CDATA[%ae]]></author-email>%n<subject><![CDATA[%s]]></subject><msg>%n<![CDATA[%n%b%n]]>%n</msg>%n</commit>'`
|
263
|
+
xml = "<?xml version=\"1.0\"?>\n<commits created=\"#{Time.now.iso8601}\">\n#{xml_body}\n</commits>"
|
264
|
+
|
265
|
+
mkdir(DOC_DIR) unless File.directory?(DOC_DIR)
|
266
|
+
|
267
|
+
File.open(File.join(DOC_DIR, "changelog.xml"), 'w') do |f|
|
268
|
+
f << xml
|
269
|
+
end
|
270
|
+
|
271
|
+
HTML_ESCAPE = { '&' => '&', '"' => '"', '>' => '>', '<' => '<' }
|
272
|
+
|
273
|
+
def html_escape(s)
|
274
|
+
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
|
275
|
+
end
|
276
|
+
|
277
|
+
# Create a changelog html in public/
|
278
|
+
doc = REXML::Document.new(xml)
|
279
|
+
html = "<h1>Changelog - #{doc.root.attributes['created']}</h1>\n\n"
|
280
|
+
doc.elements.each('commits/commit') do |ci|
|
281
|
+
date = ci.elements["date"].text
|
282
|
+
author = ci.elements["author"].text
|
283
|
+
subject = ci.elements["subject"].text
|
284
|
+
msg = ci.elements["msg"].cdatas
|
285
|
+
html << "<div class=\"commit\" id=\"#{ci.attributes['id']}\">\n"
|
286
|
+
html << "<span class=\"date\">Date: #{date}</span>\n"
|
287
|
+
html << "<span class=\"author\">Author: #{html_escape(author)}</span>\n"
|
288
|
+
html << "<h2>#{html_escape(subject)}</h2>\n"
|
289
|
+
html << "<pre class=\"msg\">#{html_escape(msg)}</pre>\n"
|
290
|
+
html << "</div>\n"
|
291
|
+
end
|
292
|
+
|
293
|
+
File.open(File.join(DOC_DIR, "changelog.html"), 'w') do |f|
|
294
|
+
f << File.open(File.join(File.dirname(__FILE__), "changelog.tmpl")).read.gsub(/@html@/, html)
|
295
|
+
end
|
296
|
+
|
297
|
+
# Changelog commiten
|
298
|
+
`git add #{DOC_DIR}/changelog.html #{DOC_DIR}/changelog.xml`
|
299
|
+
`git commit -m "Update changelog"`
|
300
|
+
end
|
301
|
+
|
302
|
+
end # end namespace git
|
303
|
+
|
304
|
+
end # end namespace
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: juretta-ipt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Saasen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-11 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Useful rake tasks and scripts for iPhone development using Xcode.
|
17
|
+
email: s@juretta.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.md
|
24
|
+
files:
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- ipt.gemspec
|
28
|
+
- tasks/changelog.tmpl
|
29
|
+
- tasks/iphone_tools.rake
|
30
|
+
has_rdoc: false
|
31
|
+
homepage: http://github.com/juretta/iphone-project-tools
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- tasks
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.2.0
|
53
|
+
signing_key:
|
54
|
+
specification_version: 2
|
55
|
+
summary: iPhone Project Tools
|
56
|
+
test_files: []
|
57
|
+
|