aniero-iphone_data 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +22 -0
- data/README.txt +65 -0
- data/Rakefile +20 -0
- data/bin/iphone_data +5 -0
- data/lib/iphone_data/command.rb +55 -0
- data/lib/iphone_data/iphone.rb +144 -0
- data/lib/iphone_data/sms_message.rb +72 -0
- data/lib/iphone_data.rb +54 -0
- data/spec/iphone_data_spec.rb +5 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +121 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +266 -0
- data/tasks/spec.rake +55 -0
- data/tasks/test.rake +38 -0
- metadata +77 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/iphone_data
|
6
|
+
lib/iphone_data.rb
|
7
|
+
lib/iphone_data/command.rb
|
8
|
+
lib/iphone_data/iphone.rb
|
9
|
+
lib/iphone_data/sms_message.rb
|
10
|
+
spec/iphone_data_spec.rb
|
11
|
+
spec/spec_helper.rb
|
12
|
+
tasks/ann.rake
|
13
|
+
tasks/bones.rake
|
14
|
+
tasks/gem.rake
|
15
|
+
tasks/manifest.rake
|
16
|
+
tasks/notes.rake
|
17
|
+
tasks/post_load.rake
|
18
|
+
tasks/rdoc.rake
|
19
|
+
tasks/rubyforge.rake
|
20
|
+
tasks/setup.rb
|
21
|
+
tasks/spec.rake
|
22
|
+
tasks/test.rake
|
data/README.txt
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
iphone_data
|
2
|
+
by Nathan Witmer
|
3
|
+
http://github.com/aniero/iphone_data
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Script to dump data from an iPhone's sync backup files.
|
8
|
+
|
9
|
+
== THANKS TO:
|
10
|
+
|
11
|
+
* masque /at/ pobox.com for his unravel.perl script, http://calmstorm.net/iphone/unravel.perl
|
12
|
+
* Tim Pease for bones
|
13
|
+
* Ara Howard for main
|
14
|
+
* Ben Bleything and Patrick May for plist
|
15
|
+
|
16
|
+
== FEATURES/PROBLEMS:
|
17
|
+
|
18
|
+
* Dump SMS message logs as a log file or an mbox file
|
19
|
+
* Dump all of the iPhone backup files into a specified directory
|
20
|
+
* Assumes only a single iPhone right now
|
21
|
+
|
22
|
+
== SYNOPSIS:
|
23
|
+
|
24
|
+
iphone_data <command> [options]
|
25
|
+
|
26
|
+
Commands include:
|
27
|
+
|
28
|
+
help - show help
|
29
|
+
sms - show sms messages
|
30
|
+
dump - dump the iphone backup data
|
31
|
+
|
32
|
+
== REQUIREMENTS:
|
33
|
+
|
34
|
+
* plist >= 3.0.0
|
35
|
+
* sqlite3-ruby >= 1.2.1
|
36
|
+
* main >= 2.8.0
|
37
|
+
|
38
|
+
== INSTALL:
|
39
|
+
|
40
|
+
* sudo gem install aniero-iphone_data --source=http://gems.github.com/
|
41
|
+
|
42
|
+
== LICENSE:
|
43
|
+
|
44
|
+
(The MIT License)
|
45
|
+
|
46
|
+
Copyright (c) 2008 Nathan Witmer
|
47
|
+
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
49
|
+
a copy of this software and associated documentation files (the
|
50
|
+
'Software'), to deal in the Software without restriction, including
|
51
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
52
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
53
|
+
permit persons to whom the Software is furnished to do so, subject to
|
54
|
+
the following conditions:
|
55
|
+
|
56
|
+
The above copyright notice and this permission notice shall be
|
57
|
+
included in all copies or substantial portions of the Software.
|
58
|
+
|
59
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
60
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
61
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
62
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
63
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
64
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
65
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
load 'tasks/setup.rb'
|
6
|
+
|
7
|
+
ensure_in_path 'lib'
|
8
|
+
require 'iphone_data'
|
9
|
+
|
10
|
+
task :default => 'spec:run'
|
11
|
+
|
12
|
+
PROJ.name = 'iphone_data'
|
13
|
+
PROJ.authors = 'Nathan Witmer'
|
14
|
+
PROJ.email = 'nwitmer@gmail.com'
|
15
|
+
PROJ.url = 'http://github.com'
|
16
|
+
PROJ.rubyforge.name = ''
|
17
|
+
|
18
|
+
PROJ.spec.opts << '--color --format specdoc'
|
19
|
+
|
20
|
+
# EOF
|
data/bin/iphone_data
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module IPhoneData
|
2
|
+
|
3
|
+
Command = ::Main.create do
|
4
|
+
|
5
|
+
examples <<-txt
|
6
|
+
iphone_data sms
|
7
|
+
iphone_data dump where/to/dump/the/files
|
8
|
+
txt
|
9
|
+
|
10
|
+
run { help! }
|
11
|
+
|
12
|
+
mode "sms" do
|
13
|
+
|
14
|
+
description "Dumps the iPhone's SMS transcripts to stdout"
|
15
|
+
|
16
|
+
option("format", "f") do
|
17
|
+
argument_optional
|
18
|
+
description "Format in which to dump the sms messages, One of 'log' or 'mbox'"
|
19
|
+
default "log"
|
20
|
+
validate { |a| %w(log mbox).include? a }
|
21
|
+
end
|
22
|
+
|
23
|
+
run do
|
24
|
+
case params['format'].value
|
25
|
+
when "log"
|
26
|
+
IPhoneData::IPhone.iphones.first.sms_messages.each { |m| puts m.to_s(:log) }
|
27
|
+
when "mbox"
|
28
|
+
IPhoneData::IPhone.iphones.first.sms_messages.each { |m| puts m.to_s(:mbox) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
mode "dump" do
|
34
|
+
|
35
|
+
description "Decode and dump the entire contents of the iPhone backup into the specified directory"
|
36
|
+
|
37
|
+
argument("dir") do
|
38
|
+
required
|
39
|
+
description "Where to put the files (creates the directory if it doesn't exist)"
|
40
|
+
attribute # puts it in local scope
|
41
|
+
end
|
42
|
+
|
43
|
+
run do
|
44
|
+
where = Pathname.new(File.expand_path(dir)) # assigning to dir causes problems?
|
45
|
+
phone = IPhoneData::IPhone.iphones.first
|
46
|
+
puts "dumping #{phone.name.inspect} to #{where}"
|
47
|
+
phone.dump_data(where)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
module IPhoneData
|
2
|
+
|
3
|
+
class IPhone
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def iphones
|
8
|
+
@iphones ||= base_dir.children.map do |child|
|
9
|
+
next unless child.directory?
|
10
|
+
new(child)
|
11
|
+
end.compact
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def base_dir
|
17
|
+
Pathname.new(File.expand_path("~/Library/Application Support/MobileSync/Backup/"))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_reader :path
|
23
|
+
|
24
|
+
def initialize(path)
|
25
|
+
@path = path
|
26
|
+
end
|
27
|
+
|
28
|
+
def name
|
29
|
+
@name ||= data["Info.plist"]["Display Name"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def number
|
33
|
+
@number ||= data["Info.plist"]["Phone Number"]
|
34
|
+
end
|
35
|
+
|
36
|
+
def sms_messages
|
37
|
+
sms_message_groups.map do |group_id, group_name|
|
38
|
+
sms_messages_for_group(group_id, group_name)
|
39
|
+
end.flatten.sort
|
40
|
+
end
|
41
|
+
|
42
|
+
# dumps all of the raw backup data to the specified directory
|
43
|
+
def dump_data(to)
|
44
|
+
data.keys.each do |key|
|
45
|
+
FileUtils.mkdir_p(to + File.dirname(key))
|
46
|
+
File.open(to + key, "wb") do |out|
|
47
|
+
case data[key]
|
48
|
+
when IO
|
49
|
+
out.write data[key].read # .mbackup file data
|
50
|
+
when Hash
|
51
|
+
out.write Plist::Emit.dump(data[key]) # Info.plist, etc.
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def data
|
60
|
+
@data ||= load_data_from_backup_files
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_data_from_backup_files
|
64
|
+
data = {}
|
65
|
+
path.children.each do |file|
|
66
|
+
next unless file.to_s =~ /\.(mdbackup|plist)/
|
67
|
+
file_data = plist_from_file(file)
|
68
|
+
if file_data["Path"] && file_data["Data"]
|
69
|
+
data[file_data["Path"]] = file_data["Data"] # mdbackups
|
70
|
+
else
|
71
|
+
data[File.basename(file)] = file_data # straight plists
|
72
|
+
end
|
73
|
+
end
|
74
|
+
data
|
75
|
+
end
|
76
|
+
|
77
|
+
def plist_from_file(file)
|
78
|
+
case file.to_s
|
79
|
+
when /\.plist/
|
80
|
+
Plist::parse_xml(file)
|
81
|
+
when /\.mdbackup/
|
82
|
+
Plist::parse_xml(%x[plutil -convert xml1 -o - "#{file}"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def address_book
|
87
|
+
@address_book ||= sqlite_database("Library/AddressBook/AddressBook.sqlitedb")
|
88
|
+
end
|
89
|
+
|
90
|
+
def sms_database
|
91
|
+
@sms_database ||= sqlite_database("Library/SMS/sms.db")
|
92
|
+
end
|
93
|
+
|
94
|
+
def sqlite_database(path)
|
95
|
+
db_file = Tempfile.new(File.basename(path), "/tmp")
|
96
|
+
db_file.write data[path].read
|
97
|
+
db_file.close
|
98
|
+
db = SQLite3::Database.new(db_file.path, :type_translation => true)
|
99
|
+
end
|
100
|
+
|
101
|
+
def sms_message_groups
|
102
|
+
sms_database.execute("select msg_group.ROWID as group_id, address from msg_group " +
|
103
|
+
"inner join group_member on msg_group.ROWID = group_member.group_id").map do |row|
|
104
|
+
[row[0], name_for_number(row[1])]
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def name_for_number(number)
|
109
|
+
alternate = number[0].chr == "1" ? number[1..-1] : "1" + number
|
110
|
+
names_by_phone_number[number] || names_by_phone_number[alternate] || number
|
111
|
+
end
|
112
|
+
|
113
|
+
def names_by_phone_number
|
114
|
+
@names_by_phone_number ||= address_book.execute("select p.first, p.last, mv.value from ABPerson p " +
|
115
|
+
"join ABMultiValue mv on p.ROWID = mv.record_id where property = 3;").inject({}) do |numbers, row|
|
116
|
+
number = row[2].gsub(/\D/,"")
|
117
|
+
numbers[number] = [row[0], row[1]].compact.join(" ")
|
118
|
+
numbers
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def sms_messages_for_group(group_id, group_name)
|
123
|
+
messages = sms_database.execute("select ROWID, flags, date, text, address " +
|
124
|
+
"from message where group_id = #{group_id} " +
|
125
|
+
"order by date asc").map do |row|
|
126
|
+
SMSMessage.new(self, group_name, *row)
|
127
|
+
end
|
128
|
+
threadify(messages)
|
129
|
+
end
|
130
|
+
|
131
|
+
# associate messages into a thread. assumes the messages are only between two people, and there cannot
|
132
|
+
# be any variation in from/to address names (i ignore the numbers, since sometimes they change slightly)
|
133
|
+
def threadify(messages)
|
134
|
+
last_id = {}
|
135
|
+
messages.map do |message|
|
136
|
+
last_id[message.from[0]] = message.message_id
|
137
|
+
message.in_reply_to = last_id[message.to[0]]
|
138
|
+
message
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module IPhoneData
|
2
|
+
|
3
|
+
class SMSMessage
|
4
|
+
|
5
|
+
attr_reader :to, :from, :date, :text
|
6
|
+
attr_accessor :in_reply_to
|
7
|
+
|
8
|
+
def initialize(iphone, group_name, msg_id, flags, date, text, address)
|
9
|
+
@date = convert_iphone_date(date)
|
10
|
+
@text = text
|
11
|
+
@message_id = msg_id
|
12
|
+
|
13
|
+
# Yeah, so this is ugly. maybe replace with a Struct?
|
14
|
+
phone = [iphone.name, iphone.number]
|
15
|
+
message = [group_name, address]
|
16
|
+
@from, @to = case flags
|
17
|
+
when 0, 2
|
18
|
+
[message, phone]
|
19
|
+
when 3
|
20
|
+
[phone, message]
|
21
|
+
else
|
22
|
+
raise "uh oh, don't know how to handle the sms message flag #{flags}, file a bug and/or patch!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def message_id
|
27
|
+
"<iphone_data-#{@message_id}@#{from[1]}>" # mutt doesn't like short message_id prefixes before the @
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s(format = :log)
|
31
|
+
case format
|
32
|
+
when :log
|
33
|
+
"#{date.strftime('%Y-%m-%d %H:%M:%S')} [#{to[0]} -> #{from[0]}] #{text.inspect}"
|
34
|
+
when :mbox
|
35
|
+
[ "From #{from[1]} #{date.strftime('%a %b %d %H:%M:%S %Y')}", # mbox message header (?)
|
36
|
+
"From: #{format_address(from)}",
|
37
|
+
"To: #{format_address(to)}",
|
38
|
+
"Date: #{date.rfc2822}",
|
39
|
+
"Message-ID: #{message_id}",
|
40
|
+
in_reply_to ? "In-Reply-To: #{in_reply_to}" : nil,
|
41
|
+
"",
|
42
|
+
text,
|
43
|
+
"\n" # puts won't put a second trailing newline. force it.
|
44
|
+
].compact.join("\n")
|
45
|
+
else
|
46
|
+
raise "unrecognized format #{format.inspect}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def <=>(other)
|
51
|
+
if date == other.date
|
52
|
+
to_s <=> other.to_s # compare everything else if the dates match
|
53
|
+
else
|
54
|
+
date <=> other.date
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
include Comparable
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def format_address(address)
|
63
|
+
"#{address[0].inspect} <#{address[1]}>"
|
64
|
+
end
|
65
|
+
|
66
|
+
def convert_iphone_date(date)
|
67
|
+
(Time.gm(1970, 1, 1) + date).localtime
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/lib/iphone_data.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
$KCODE='u'
|
2
|
+
|
3
|
+
module IPhoneData
|
4
|
+
|
5
|
+
# :stopdoc:
|
6
|
+
VERSION = '0.1.0'
|
7
|
+
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
8
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
9
|
+
# :startdoc:
|
10
|
+
|
11
|
+
# Returns the version string for the library.
|
12
|
+
#
|
13
|
+
def self.version
|
14
|
+
VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the library path for the module. If any arguments are given,
|
18
|
+
# they will be joined to the end of the libray path using
|
19
|
+
# <tt>File.join</tt>.
|
20
|
+
#
|
21
|
+
def self.libpath( *args )
|
22
|
+
args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns the lpath for the module. If any arguments are given,
|
26
|
+
# they will be joined to the end of the path using
|
27
|
+
# <tt>File.join</tt>.
|
28
|
+
#
|
29
|
+
def self.path( *args )
|
30
|
+
args.empty? ? PATH : ::File.join(PATH, *args)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Utility method used to rquire all files ending in .rb that lie in the
|
34
|
+
# directory below this file that has the same name as the filename passed
|
35
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
36
|
+
# the _filename_ does not have to be equivalent to the directory.
|
37
|
+
#
|
38
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
39
|
+
dir ||= ::File.basename(fname, '.*')
|
40
|
+
search_me = ::File.expand_path(
|
41
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
42
|
+
|
43
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
require "rubygems"
|
49
|
+
gem "plist", ">= 3.0.0"
|
50
|
+
gem "sqlite3-ruby", ">= 1.2.1"
|
51
|
+
gem "main", ">= 2.8.0"
|
52
|
+
%w(plist sqlite3 main pathname tempfile).each { |lib| require lib }
|
53
|
+
|
54
|
+
IPhoneData.require_all_libs_relative_to __FILE__
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path(
|
2
|
+
File.join(File.dirname(__FILE__), %w[.. lib iphone_data]))
|
3
|
+
|
4
|
+
Spec::Runner.configure do |config|
|
5
|
+
# == Mock Framework
|
6
|
+
#
|
7
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
8
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
9
|
+
#
|
10
|
+
# config.mock_with :mocha
|
11
|
+
# config.mock_with :flexmock
|
12
|
+
# config.mock_with :rr
|
13
|
+
end
|
data/tasks/ann.rake
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bones/smtp_tls'
|
5
|
+
rescue LoadError
|
6
|
+
require 'net/smtp'
|
7
|
+
end
|
8
|
+
require 'time'
|
9
|
+
|
10
|
+
namespace :ann do
|
11
|
+
|
12
|
+
# A prerequisites task that all other tasks depend upon
|
13
|
+
task :prereqs
|
14
|
+
|
15
|
+
file PROJ.ann.file do
|
16
|
+
ann = PROJ.ann
|
17
|
+
puts "Generating #{ann.file}"
|
18
|
+
File.open(ann.file,'w') do |fd|
|
19
|
+
fd.puts("#{PROJ.name} version #{PROJ.version}")
|
20
|
+
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
|
21
|
+
fd.puts(" #{PROJ.url}") if PROJ.url.valid?
|
22
|
+
fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
|
23
|
+
fd.puts
|
24
|
+
fd.puts("== DESCRIPTION")
|
25
|
+
fd.puts
|
26
|
+
fd.puts(PROJ.description)
|
27
|
+
fd.puts
|
28
|
+
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
|
29
|
+
fd.puts
|
30
|
+
ann.paragraphs.each do |p|
|
31
|
+
fd.puts "== #{p.upcase}"
|
32
|
+
fd.puts
|
33
|
+
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
|
34
|
+
fd.puts
|
35
|
+
end
|
36
|
+
fd.puts ann.text if ann.text
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Create an announcement file"
|
41
|
+
task :announcement => ['ann:prereqs', PROJ.ann.file]
|
42
|
+
|
43
|
+
desc "Send an email announcement"
|
44
|
+
task :email => ['ann:prereqs', PROJ.ann.file] do
|
45
|
+
ann = PROJ.ann
|
46
|
+
from = ann.email[:from] || PROJ.email
|
47
|
+
to = Array(ann.email[:to])
|
48
|
+
|
49
|
+
### build a mail header for RFC 822
|
50
|
+
rfc822msg = "From: #{from}\n"
|
51
|
+
rfc822msg << "To: #{to.join(',')}\n"
|
52
|
+
rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
|
53
|
+
rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
|
54
|
+
rfc822msg << "\n"
|
55
|
+
rfc822msg << "Date: #{Time.new.rfc822}\n"
|
56
|
+
rfc822msg << "Message-Id: "
|
57
|
+
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
|
58
|
+
rfc822msg << File.read(ann.file)
|
59
|
+
|
60
|
+
params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
|
61
|
+
ann.email[key]
|
62
|
+
end
|
63
|
+
|
64
|
+
params[3] = PROJ.email if params[3].nil?
|
65
|
+
|
66
|
+
if params[4].nil?
|
67
|
+
STDOUT.write "Please enter your e-mail password (#{params[3]}): "
|
68
|
+
params[4] = STDIN.gets.chomp
|
69
|
+
end
|
70
|
+
|
71
|
+
### send email
|
72
|
+
Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
|
73
|
+
end
|
74
|
+
end # namespace :ann
|
75
|
+
|
76
|
+
desc 'Alias to ann:announcement'
|
77
|
+
task :ann => 'ann:announcement'
|
78
|
+
|
79
|
+
CLOBBER << PROJ.ann.file
|
80
|
+
|
81
|
+
# EOF
|
data/tasks/bones.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if HAVE_BONES
|
4
|
+
|
5
|
+
namespace :bones do
|
6
|
+
|
7
|
+
desc 'Show the PROJ open struct'
|
8
|
+
task :debug do |t|
|
9
|
+
atr = if t.application.top_level_tasks.length == 2
|
10
|
+
t.application.top_level_tasks.pop
|
11
|
+
end
|
12
|
+
|
13
|
+
if atr then Bones::Debug.show_attr(PROJ, atr)
|
14
|
+
else Bones::Debug.show PROJ end
|
15
|
+
end
|
16
|
+
|
17
|
+
end # namespace :bones
|
18
|
+
|
19
|
+
end # HAVE_BONES
|
20
|
+
|
21
|
+
# EOF
|
data/tasks/gem.rake
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
|
5
|
+
namespace :gem do
|
6
|
+
|
7
|
+
PROJ.gem._spec = Gem::Specification.new do |s|
|
8
|
+
s.name = PROJ.name
|
9
|
+
s.version = PROJ.version
|
10
|
+
s.summary = PROJ.summary
|
11
|
+
s.authors = Array(PROJ.authors)
|
12
|
+
s.email = PROJ.email
|
13
|
+
s.homepage = Array(PROJ.url).first
|
14
|
+
s.rubyforge_project = PROJ.rubyforge.name
|
15
|
+
|
16
|
+
s.description = PROJ.description
|
17
|
+
|
18
|
+
PROJ.gem.dependencies.each do |dep|
|
19
|
+
s.add_dependency(*dep)
|
20
|
+
end
|
21
|
+
|
22
|
+
s.files = PROJ.gem.files
|
23
|
+
s.executables = PROJ.gem.executables.map {|fn| File.basename(fn)}
|
24
|
+
s.extensions = PROJ.gem.files.grep %r/extconf\.rb$/
|
25
|
+
|
26
|
+
s.bindir = 'bin'
|
27
|
+
dirs = Dir["{#{PROJ.libs.join(',')}}"]
|
28
|
+
s.require_paths = dirs unless dirs.empty?
|
29
|
+
|
30
|
+
incl = Regexp.new(PROJ.rdoc.include.join('|'))
|
31
|
+
excl = PROJ.rdoc.exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
|
32
|
+
excl = Regexp.new(excl.join('|'))
|
33
|
+
rdoc_files = PROJ.gem.files.find_all do |fn|
|
34
|
+
case fn
|
35
|
+
when excl; false
|
36
|
+
when incl; true
|
37
|
+
else false end
|
38
|
+
end
|
39
|
+
s.rdoc_options = PROJ.rdoc.opts + ['--main', PROJ.rdoc.main]
|
40
|
+
s.extra_rdoc_files = rdoc_files
|
41
|
+
s.has_rdoc = true
|
42
|
+
|
43
|
+
if test ?f, PROJ.test.file
|
44
|
+
s.test_file = PROJ.test.file
|
45
|
+
else
|
46
|
+
s.test_files = PROJ.test.files.to_a
|
47
|
+
end
|
48
|
+
|
49
|
+
# Do any extra stuff the user wants
|
50
|
+
PROJ.gem.extras.each do |msg, val|
|
51
|
+
case val
|
52
|
+
when Proc
|
53
|
+
val.call(s.send(msg))
|
54
|
+
else
|
55
|
+
s.send "#{msg}=", val
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end # Gem::Specification.new
|
59
|
+
|
60
|
+
# A prerequisites task that all other tasks depend upon
|
61
|
+
task :prereqs
|
62
|
+
|
63
|
+
desc 'Show information about the gem'
|
64
|
+
task :debug => 'gem:prereqs' do
|
65
|
+
puts PROJ.gem._spec.to_ruby
|
66
|
+
end
|
67
|
+
|
68
|
+
pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
|
69
|
+
pkg.need_tar = PROJ.gem.need_tar
|
70
|
+
pkg.need_zip = PROJ.gem.need_zip
|
71
|
+
pkg.package_files += PROJ.gem._spec.files
|
72
|
+
end
|
73
|
+
Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
|
74
|
+
|
75
|
+
gem_file = if PROJ.gem._spec.platform == Gem::Platform::RUBY
|
76
|
+
"#{pkg.package_name}.gem"
|
77
|
+
else
|
78
|
+
"#{pkg.package_name}-#{PROJ.gem._spec.platform}.gem"
|
79
|
+
end
|
80
|
+
|
81
|
+
desc "Build the gem file #{gem_file}"
|
82
|
+
task :package => ['gem:prereqs', "#{pkg.package_dir}/#{gem_file}"]
|
83
|
+
|
84
|
+
file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.gem._spec.files do
|
85
|
+
when_writing("Creating GEM") {
|
86
|
+
Gem::Builder.new(PROJ.gem._spec).build
|
87
|
+
verbose(true) {
|
88
|
+
mv gem_file, "#{pkg.package_dir}/#{gem_file}"
|
89
|
+
}
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
desc 'Install the gem'
|
94
|
+
task :install => [:clobber, :package] do
|
95
|
+
sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
|
96
|
+
|
97
|
+
# use this version of the command for rubygems > 1.0.0
|
98
|
+
#sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{PROJ.gem._spec.full_name}"
|
99
|
+
end
|
100
|
+
|
101
|
+
desc 'Uninstall the gem'
|
102
|
+
task :uninstall do
|
103
|
+
installed_list = Gem.source_index.find_name(PROJ.name)
|
104
|
+
if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
|
105
|
+
sh "#{SUDO} #{GEM} uninstall --version '#{PROJ.version}' --ignore-dependencies --executables #{PROJ.name}"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
desc 'Reinstall the gem'
|
110
|
+
task :reinstall => [:uninstall, :install]
|
111
|
+
|
112
|
+
end # namespace :gem
|
113
|
+
|
114
|
+
desc 'Alias to gem:package'
|
115
|
+
task :gem => 'gem:package'
|
116
|
+
|
117
|
+
task :clobber => 'gem:clobber_package'
|
118
|
+
|
119
|
+
remove_desc_for_task %w(gem:clobber_package)
|
120
|
+
|
121
|
+
# EOF
|
data/tasks/manifest.rake
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'find'
|
4
|
+
|
5
|
+
namespace :manifest do
|
6
|
+
|
7
|
+
desc 'Verify the manifest'
|
8
|
+
task :check do
|
9
|
+
fn = PROJ.manifest_file + '.tmp'
|
10
|
+
files = manifest_files
|
11
|
+
|
12
|
+
File.open(fn, 'w') {|fp| fp.puts files}
|
13
|
+
lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
|
14
|
+
if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
|
15
|
+
lines.map! do |line|
|
16
|
+
case line
|
17
|
+
when %r/^(-{3}|\+{3})/; nil
|
18
|
+
when %r/^@/; Console::ANSICode.blue line
|
19
|
+
when %r/^\+/; Console::ANSICode.green line
|
20
|
+
when %r/^\-/; Console::ANSICode.red line
|
21
|
+
else line end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
puts lines.compact
|
25
|
+
rm fn rescue nil
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Create a new manifest'
|
29
|
+
task :create do
|
30
|
+
files = manifest_files
|
31
|
+
unless test(?f, PROJ.manifest_file)
|
32
|
+
files << PROJ.manifest_file
|
33
|
+
files.sort!
|
34
|
+
end
|
35
|
+
File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
|
36
|
+
end
|
37
|
+
|
38
|
+
task :assert do
|
39
|
+
files = manifest_files
|
40
|
+
manifest = File.read(PROJ.manifest_file).split($/)
|
41
|
+
raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
|
42
|
+
end
|
43
|
+
|
44
|
+
end # namespace :manifest
|
45
|
+
|
46
|
+
desc 'Alias to manifest:check'
|
47
|
+
task :manifest => 'manifest:check'
|
48
|
+
|
49
|
+
# EOF
|
data/tasks/notes.rake
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if HAVE_BONES
|
4
|
+
|
5
|
+
desc "Enumerate all annotations"
|
6
|
+
task :notes do |t|
|
7
|
+
id = if t.application.top_level_tasks.length > 1
|
8
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
9
|
+
end
|
10
|
+
Bones::AnnotationExtractor.enumerate(
|
11
|
+
PROJ, PROJ.notes.tags.join('|'), id, :tag => true)
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :notes do
|
15
|
+
PROJ.notes.tags.each do |tag|
|
16
|
+
desc "Enumerate all #{tag} annotations"
|
17
|
+
task tag.downcase.to_sym do |t|
|
18
|
+
id = if t.application.top_level_tasks.length > 1
|
19
|
+
t.application.top_level_tasks.slice!(1..-1).join(' ')
|
20
|
+
end
|
21
|
+
Bones::AnnotationExtractor.enumerate(PROJ, tag, id)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end # if HAVE_BONES
|
27
|
+
|
28
|
+
# EOF
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
# This file does not define any rake tasks. It is used to load some project
|
4
|
+
# settings if they are not defined by the user.
|
5
|
+
|
6
|
+
PROJ.rdoc.exclude << "^#{Regexp.escape(PROJ.manifest_file)}$"
|
7
|
+
PROJ.exclude << ["^#{Regexp.escape(PROJ.ann.file)}$",
|
8
|
+
"^#{Regexp.escape(PROJ.rdoc.dir)}/",
|
9
|
+
"^#{Regexp.escape(PROJ.rcov.dir)}/"]
|
10
|
+
|
11
|
+
flatten_arrays = lambda do |this,os|
|
12
|
+
os.instance_variable_get(:@table).each do |key,val|
|
13
|
+
next if key == :dependencies
|
14
|
+
case val
|
15
|
+
when Array; val.flatten!
|
16
|
+
when OpenStruct; this.call(this,val)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
flatten_arrays.call(flatten_arrays,PROJ)
|
21
|
+
|
22
|
+
PROJ.changes ||= paragraphs_of(PROJ.history_file, 0..1).join("\n\n")
|
23
|
+
|
24
|
+
PROJ.description ||= paragraphs_of(PROJ.readme_file, 'description').join("\n\n")
|
25
|
+
|
26
|
+
PROJ.summary ||= PROJ.description.split('.').first
|
27
|
+
|
28
|
+
PROJ.gem.files ||=
|
29
|
+
if test(?f, PROJ.manifest_file)
|
30
|
+
files = File.readlines(PROJ.manifest_file).map {|fn| fn.chomp.strip}
|
31
|
+
files.delete ''
|
32
|
+
files
|
33
|
+
else [] end
|
34
|
+
|
35
|
+
PROJ.gem.executables ||= PROJ.gem.files.find_all {|fn| fn =~ %r/^bin/}
|
36
|
+
|
37
|
+
PROJ.rdoc.main ||= PROJ.readme_file
|
38
|
+
|
39
|
+
# EOF
|
data/tasks/rdoc.rake
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
namespace :doc do
|
6
|
+
|
7
|
+
desc 'Generate RDoc documentation'
|
8
|
+
Rake::RDocTask.new do |rd|
|
9
|
+
rdoc = PROJ.rdoc
|
10
|
+
rd.main = rdoc.main
|
11
|
+
rd.rdoc_dir = rdoc.dir
|
12
|
+
|
13
|
+
incl = Regexp.new(rdoc.include.join('|'))
|
14
|
+
excl = Regexp.new(rdoc.exclude.join('|'))
|
15
|
+
files = PROJ.gem.files.find_all do |fn|
|
16
|
+
case fn
|
17
|
+
when excl; false
|
18
|
+
when incl; true
|
19
|
+
else false end
|
20
|
+
end
|
21
|
+
rd.rdoc_files.push(*files)
|
22
|
+
|
23
|
+
title = "#{PROJ.name}-#{PROJ.version} Documentation"
|
24
|
+
|
25
|
+
rf_name = PROJ.rubyforge.name
|
26
|
+
title = "#{rf_name}'s " + title if rf_name.valid? and rf_name != title
|
27
|
+
|
28
|
+
rd.options << "-t #{title}"
|
29
|
+
rd.options.concat(rdoc.opts)
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Generate ri locally for testing'
|
33
|
+
task :ri => :clobber_ri do
|
34
|
+
sh "#{RDOC} --ri -o ri ."
|
35
|
+
end
|
36
|
+
|
37
|
+
task :clobber_ri do
|
38
|
+
rm_r 'ri' rescue nil
|
39
|
+
end
|
40
|
+
|
41
|
+
end # namespace :doc
|
42
|
+
|
43
|
+
desc 'Alias to doc:rdoc'
|
44
|
+
task :doc => 'doc:rdoc'
|
45
|
+
|
46
|
+
desc 'Remove all build products'
|
47
|
+
task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
|
48
|
+
|
49
|
+
remove_desc_for_task %w(doc:clobber_rdoc)
|
50
|
+
|
51
|
+
# EOF
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if PROJ.rubyforge.name.valid? && HAVE_RUBYFORGE
|
4
|
+
|
5
|
+
require 'rubyforge'
|
6
|
+
require 'rake/contrib/sshpublisher'
|
7
|
+
|
8
|
+
namespace :gem do
|
9
|
+
desc 'Package and upload to RubyForge'
|
10
|
+
task :release => [:clobber, :package] do |t|
|
11
|
+
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
12
|
+
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
|
13
|
+
pkg = "pkg/#{PROJ.gem._spec.full_name}"
|
14
|
+
|
15
|
+
if $DEBUG then
|
16
|
+
puts "release_id = rf.add_release #{PROJ.rubyforge.name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
|
17
|
+
puts "rf.add_file #{PROJ.rubyforge.name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
|
18
|
+
end
|
19
|
+
|
20
|
+
rf = RubyForge.new
|
21
|
+
puts 'Logging in'
|
22
|
+
rf.login
|
23
|
+
|
24
|
+
c = rf.userconfig
|
25
|
+
c['release_notes'] = PROJ.description if PROJ.description
|
26
|
+
c['release_changes'] = PROJ.changes if PROJ.changes
|
27
|
+
c['preformatted'] = true
|
28
|
+
|
29
|
+
files = [(PROJ.gem.need_tar ? "#{pkg}.tgz" : nil),
|
30
|
+
(PROJ.gem.need_zip ? "#{pkg}.zip" : nil),
|
31
|
+
"#{pkg}.gem"].compact
|
32
|
+
|
33
|
+
puts "Releasing #{PROJ.name} v. #{PROJ.version}"
|
34
|
+
rf.add_release PROJ.rubyforge.name, PROJ.name, PROJ.version, *files
|
35
|
+
end
|
36
|
+
end # namespace :gem
|
37
|
+
|
38
|
+
|
39
|
+
namespace :doc do
|
40
|
+
desc "Publish RDoc to RubyForge"
|
41
|
+
task :release => %w(doc:clobber_rdoc doc:rdoc) do
|
42
|
+
config = YAML.load(
|
43
|
+
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
44
|
+
)
|
45
|
+
|
46
|
+
host = "#{config['username']}@rubyforge.org"
|
47
|
+
remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge.name}/"
|
48
|
+
remote_dir << PROJ.rdoc.remote_dir if PROJ.rdoc.remote_dir
|
49
|
+
local_dir = PROJ.rdoc.dir
|
50
|
+
|
51
|
+
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
52
|
+
end
|
53
|
+
end # namespace :doc
|
54
|
+
|
55
|
+
end # if HAVE_RUBYFORGE
|
56
|
+
|
57
|
+
# EOF
|
data/tasks/setup.rb
ADDED
@@ -0,0 +1,266 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
class OpenStruct; undef :gem; end
|
10
|
+
|
11
|
+
PROJ = OpenStruct.new(
|
12
|
+
# Project Defaults
|
13
|
+
:name => nil,
|
14
|
+
:summary => nil,
|
15
|
+
:description => nil,
|
16
|
+
:changes => nil,
|
17
|
+
:authors => nil,
|
18
|
+
:email => nil,
|
19
|
+
:url => "\000",
|
20
|
+
:version => ENV['VERSION'] || '0.0.0',
|
21
|
+
:exclude => %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^data .tmproj .git/ .DS_Store),
|
22
|
+
:release_name => ENV['RELEASE'],
|
23
|
+
|
24
|
+
# System Defaults
|
25
|
+
:ruby_opts => %w(-w),
|
26
|
+
:libs => [],
|
27
|
+
:history_file => 'History.txt',
|
28
|
+
:manifest_file => 'Manifest.txt',
|
29
|
+
:readme_file => 'README.txt',
|
30
|
+
|
31
|
+
# Announce
|
32
|
+
:ann => OpenStruct.new(
|
33
|
+
:file => 'announcement.txt',
|
34
|
+
:text => nil,
|
35
|
+
:paragraphs => [],
|
36
|
+
:email => {
|
37
|
+
:from => nil,
|
38
|
+
:to => %w(ruby-talk@ruby-lang.org),
|
39
|
+
:server => 'localhost',
|
40
|
+
:port => 25,
|
41
|
+
:domain => ENV['HOSTNAME'],
|
42
|
+
:acct => nil,
|
43
|
+
:passwd => nil,
|
44
|
+
:authtype => :plain
|
45
|
+
}
|
46
|
+
),
|
47
|
+
|
48
|
+
# Gem Packaging
|
49
|
+
:gem => OpenStruct.new(
|
50
|
+
:dependencies => [],
|
51
|
+
:executables => nil,
|
52
|
+
:extensions => FileList['ext/**/extconf.rb'],
|
53
|
+
:files => nil,
|
54
|
+
:need_tar => true,
|
55
|
+
:need_zip => false,
|
56
|
+
:extras => {}
|
57
|
+
),
|
58
|
+
|
59
|
+
# File Annotations
|
60
|
+
:notes => OpenStruct.new(
|
61
|
+
:exclude => %w(^tasks/setup.rb$),
|
62
|
+
:extensions => %w(.txt .rb .erb) << '',
|
63
|
+
:tags => %w(FIXME OPTIMIZE TODO)
|
64
|
+
),
|
65
|
+
|
66
|
+
# Rcov
|
67
|
+
:rcov => OpenStruct.new(
|
68
|
+
:dir => 'coverage',
|
69
|
+
:opts => %w[--sort coverage -T],
|
70
|
+
:threshold => 90.0,
|
71
|
+
:threshold_exact => false
|
72
|
+
),
|
73
|
+
|
74
|
+
# Rdoc
|
75
|
+
:rdoc => OpenStruct.new(
|
76
|
+
:opts => [],
|
77
|
+
:include => %w(^lib/ ^bin/ ^ext/ .txt$),
|
78
|
+
:exclude => %w(extconf.rb$),
|
79
|
+
:main => nil,
|
80
|
+
:dir => 'doc',
|
81
|
+
:remote_dir => nil
|
82
|
+
),
|
83
|
+
|
84
|
+
# Rubyforge
|
85
|
+
:rubyforge => OpenStruct.new(
|
86
|
+
:name => "\000"
|
87
|
+
),
|
88
|
+
|
89
|
+
# Rspec
|
90
|
+
:spec => OpenStruct.new(
|
91
|
+
:files => FileList['spec/**/*_spec.rb'],
|
92
|
+
:opts => []
|
93
|
+
),
|
94
|
+
|
95
|
+
# Subversion Repository
|
96
|
+
:svn => OpenStruct.new(
|
97
|
+
:root => nil,
|
98
|
+
:path => '',
|
99
|
+
:trunk => 'trunk',
|
100
|
+
:tags => 'tags',
|
101
|
+
:branches => 'branches'
|
102
|
+
),
|
103
|
+
|
104
|
+
# Test::Unit
|
105
|
+
:test => OpenStruct.new(
|
106
|
+
:files => FileList['test/**/test_*.rb'],
|
107
|
+
:file => 'test/all.rb',
|
108
|
+
:opts => []
|
109
|
+
)
|
110
|
+
)
|
111
|
+
|
112
|
+
# Load the other rake files in the tasks folder
|
113
|
+
rakefiles = Dir.glob('tasks/*.rake').sort
|
114
|
+
rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
|
115
|
+
import(*rakefiles)
|
116
|
+
|
117
|
+
# Setup the project libraries
|
118
|
+
%w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
|
119
|
+
|
120
|
+
# Setup some constants
|
121
|
+
WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
|
122
|
+
|
123
|
+
DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
|
124
|
+
|
125
|
+
def quiet( &block )
|
126
|
+
io = [STDOUT.dup, STDERR.dup]
|
127
|
+
STDOUT.reopen DEV_NULL
|
128
|
+
STDERR.reopen DEV_NULL
|
129
|
+
block.call
|
130
|
+
ensure
|
131
|
+
STDOUT.reopen io.first
|
132
|
+
STDERR.reopen io.last
|
133
|
+
$stdout, $stderr = STDOUT, STDERR
|
134
|
+
end
|
135
|
+
|
136
|
+
DIFF = if WIN32 then 'diff.exe'
|
137
|
+
else
|
138
|
+
if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
|
139
|
+
else 'diff' end
|
140
|
+
end unless defined? DIFF
|
141
|
+
|
142
|
+
SUDO = if WIN32 then ''
|
143
|
+
else
|
144
|
+
if quiet {system 'which sudo'} then 'sudo'
|
145
|
+
else '' end
|
146
|
+
end
|
147
|
+
|
148
|
+
RCOV = WIN32 ? 'rcov.bat' : 'rcov'
|
149
|
+
RDOC = WIN32 ? 'rdoc.bat' : 'rdoc'
|
150
|
+
GEM = WIN32 ? 'gem.bat' : 'gem'
|
151
|
+
|
152
|
+
%w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
|
153
|
+
begin
|
154
|
+
require lib
|
155
|
+
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
|
156
|
+
rescue LoadError
|
157
|
+
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
|
158
|
+
end
|
159
|
+
end
|
160
|
+
HAVE_SVN = (Dir.entries(Dir.pwd).include?('.svn') and
|
161
|
+
system("svn --version 2>&1 > #{DEV_NULL}"))
|
162
|
+
|
163
|
+
# Reads a file at +path+ and spits out an array of the +paragraphs+
|
164
|
+
# specified.
|
165
|
+
#
|
166
|
+
# changes = paragraphs_of('History.txt', 0..1).join("\n\n")
|
167
|
+
# summary, *description = paragraphs_of('README.txt', 3, 3..8)
|
168
|
+
#
|
169
|
+
def paragraphs_of( path, *paragraphs )
|
170
|
+
title = String === paragraphs.first ? paragraphs.shift : nil
|
171
|
+
ary = File.read(path).delete("\r").split(/\n\n+/)
|
172
|
+
|
173
|
+
result = if title
|
174
|
+
tmp, matching = [], false
|
175
|
+
rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
|
176
|
+
paragraphs << (0..-1) if paragraphs.empty?
|
177
|
+
|
178
|
+
ary.each do |val|
|
179
|
+
if val =~ rgxp
|
180
|
+
break if matching
|
181
|
+
matching = true
|
182
|
+
rgxp = %r/^=+/i
|
183
|
+
elsif matching
|
184
|
+
tmp << val
|
185
|
+
end
|
186
|
+
end
|
187
|
+
tmp
|
188
|
+
else ary end
|
189
|
+
|
190
|
+
result.values_at(*paragraphs)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Adds the given gem _name_ to the current project's dependency list. An
|
194
|
+
# optional gem _version_ can be given. If omitted, the newest gem version
|
195
|
+
# will be used.
|
196
|
+
#
|
197
|
+
def depend_on( name, version = nil )
|
198
|
+
spec = Gem.source_index.find_name(name).last
|
199
|
+
version = spec.version.to_s if version.nil? and !spec.nil?
|
200
|
+
|
201
|
+
PROJ.gem.dependencies << case version
|
202
|
+
when nil; [name]
|
203
|
+
when %r/^\d/; [name, ">= #{version}"]
|
204
|
+
else [name, version] end
|
205
|
+
end
|
206
|
+
|
207
|
+
# Adds the given arguments to the include path if they are not already there
|
208
|
+
#
|
209
|
+
def ensure_in_path( *args )
|
210
|
+
args.each do |path|
|
211
|
+
path = File.expand_path(path)
|
212
|
+
$:.unshift(path) if test(?d, path) and not $:.include?(path)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# Find a rake task using the task name and remove any description text. This
|
217
|
+
# will prevent the task from being displayed in the list of available tasks.
|
218
|
+
#
|
219
|
+
def remove_desc_for_task( names )
|
220
|
+
Array(names).each do |task_name|
|
221
|
+
task = Rake.application.tasks.find {|t| t.name == task_name}
|
222
|
+
next if task.nil?
|
223
|
+
task.instance_variable_set :@comment, nil
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# Change working directories to _dir_, call the _block_ of code, and then
|
228
|
+
# change back to the original working directory (the current directory when
|
229
|
+
# this method was called).
|
230
|
+
#
|
231
|
+
def in_directory( dir, &block )
|
232
|
+
curdir = pwd
|
233
|
+
begin
|
234
|
+
cd dir
|
235
|
+
return block.call
|
236
|
+
ensure
|
237
|
+
cd curdir
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# Scans the current working directory and creates a list of files that are
|
242
|
+
# candidates to be in the manifest.
|
243
|
+
#
|
244
|
+
def manifest_files
|
245
|
+
files = []
|
246
|
+
exclude = Regexp.new(PROJ.exclude.join('|'))
|
247
|
+
Find.find '.' do |path|
|
248
|
+
path.sub! %r/^(\.\/|\/)/o, ''
|
249
|
+
next unless test ?f, path
|
250
|
+
next if path =~ exclude
|
251
|
+
files << path
|
252
|
+
end
|
253
|
+
files.sort!
|
254
|
+
end
|
255
|
+
|
256
|
+
# We need a "valid" method thtat determines if a string is suitable for use
|
257
|
+
# in the gem specification.
|
258
|
+
#
|
259
|
+
class Object
|
260
|
+
def valid?
|
261
|
+
return !(self.empty? or self == "\000") if self.respond_to?(:to_str)
|
262
|
+
return false
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
# EOF
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
if HAVE_SPEC_RAKE_SPECTASK
|
4
|
+
require 'spec/rake/verify_rcov'
|
5
|
+
|
6
|
+
namespace :spec do
|
7
|
+
|
8
|
+
desc 'Run all specs with basic output'
|
9
|
+
Spec::Rake::SpecTask.new(:run) do |t|
|
10
|
+
t.ruby_opts = PROJ.ruby_opts
|
11
|
+
t.spec_opts = PROJ.spec.opts
|
12
|
+
t.spec_files = PROJ.spec.files
|
13
|
+
t.libs += PROJ.libs
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Run all specs with text output'
|
17
|
+
Spec::Rake::SpecTask.new(:specdoc) do |t|
|
18
|
+
t.ruby_opts = PROJ.ruby_opts
|
19
|
+
t.spec_opts = PROJ.spec.opts + ['--format', 'specdoc']
|
20
|
+
t.spec_files = PROJ.spec.files
|
21
|
+
t.libs += PROJ.libs
|
22
|
+
end
|
23
|
+
|
24
|
+
if HAVE_RCOV
|
25
|
+
desc 'Run all specs with RCov'
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
27
|
+
t.ruby_opts = PROJ.ruby_opts
|
28
|
+
t.spec_opts = PROJ.spec.opts
|
29
|
+
t.spec_files = PROJ.spec.files
|
30
|
+
t.libs += PROJ.libs
|
31
|
+
t.rcov = true
|
32
|
+
t.rcov_dir = PROJ.rcov.dir
|
33
|
+
t.rcov_opts = PROJ.rcov.opts + ['--exclude', 'spec']
|
34
|
+
end
|
35
|
+
|
36
|
+
RCov::VerifyTask.new(:verify) do |t|
|
37
|
+
t.threshold = PROJ.rcov.threshold
|
38
|
+
t.index_html = File.join(PROJ.rcov.dir, 'index.html')
|
39
|
+
t.require_exact_threshold = PROJ.rcov.threshold_exact
|
40
|
+
end
|
41
|
+
|
42
|
+
task :verify => :rcov
|
43
|
+
remove_desc_for_task %w(spec:clobber_rcov)
|
44
|
+
end
|
45
|
+
|
46
|
+
end # namespace :spec
|
47
|
+
|
48
|
+
desc 'Alias to spec:run'
|
49
|
+
task :spec => 'spec:run'
|
50
|
+
|
51
|
+
task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
|
52
|
+
|
53
|
+
end # if HAVE_SPEC_RAKE_SPECTASK
|
54
|
+
|
55
|
+
# EOF
|
data/tasks/test.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
namespace :test do
|
6
|
+
|
7
|
+
Rake::TestTask.new(:run) do |t|
|
8
|
+
t.libs = PROJ.libs
|
9
|
+
t.test_files = if test(?f, PROJ.test.file) then [PROJ.test.file]
|
10
|
+
else PROJ.test.files end
|
11
|
+
t.ruby_opts += PROJ.ruby_opts
|
12
|
+
t.ruby_opts += PROJ.test.opts
|
13
|
+
end
|
14
|
+
|
15
|
+
if HAVE_RCOV
|
16
|
+
desc 'Run rcov on the unit tests'
|
17
|
+
task :rcov => :clobber_rcov do
|
18
|
+
opts = PROJ.rcov.opts.dup << '-o' << PROJ.rcov.dir
|
19
|
+
opts = opts.join(' ')
|
20
|
+
files = if test(?f, PROJ.test.file) then [PROJ.test.file]
|
21
|
+
else PROJ.test.files end
|
22
|
+
files = files.join(' ')
|
23
|
+
sh "#{RCOV} #{files} #{opts}"
|
24
|
+
end
|
25
|
+
|
26
|
+
task :clobber_rcov do
|
27
|
+
rm_r 'coverage' rescue nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end # namespace :test
|
32
|
+
|
33
|
+
desc 'Alias to test:run'
|
34
|
+
task :test => 'test:run'
|
35
|
+
|
36
|
+
task :clobber => 'test:clobber_rcov' if HAVE_RCOV
|
37
|
+
|
38
|
+
# EOF
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aniero-iphone_data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nathan Witmer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-11 00:00:00 -07:00
|
13
|
+
default_executable: iphone_data
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Script to dump data from an iPhone's sync backup files.
|
17
|
+
email: nwitmer@gmail.com
|
18
|
+
executables:
|
19
|
+
- iphone_data
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- History.txt
|
24
|
+
- README.txt
|
25
|
+
- bin/iphone_data
|
26
|
+
files:
|
27
|
+
- History.txt
|
28
|
+
- Manifest.txt
|
29
|
+
- README.txt
|
30
|
+
- Rakefile
|
31
|
+
- bin/iphone_data
|
32
|
+
- lib/iphone_data.rb
|
33
|
+
- lib/iphone_data/command.rb
|
34
|
+
- lib/iphone_data/iphone.rb
|
35
|
+
- lib/iphone_data/sms_message.rb
|
36
|
+
- spec/iphone_data_spec.rb
|
37
|
+
- spec/spec_helper.rb
|
38
|
+
- tasks/ann.rake
|
39
|
+
- tasks/bones.rake
|
40
|
+
- tasks/gem.rake
|
41
|
+
- tasks/manifest.rake
|
42
|
+
- tasks/notes.rake
|
43
|
+
- tasks/post_load.rake
|
44
|
+
- tasks/rdoc.rake
|
45
|
+
- tasks/rubyforge.rake
|
46
|
+
- tasks/setup.rb
|
47
|
+
- tasks/spec.rake
|
48
|
+
- tasks/test.rake
|
49
|
+
has_rdoc: true
|
50
|
+
homepage: http://github.com
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --main
|
54
|
+
- README.txt
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "0"
|
62
|
+
version:
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: ""
|
72
|
+
rubygems_version: 1.0.1
|
73
|
+
signing_key:
|
74
|
+
specification_version: 2
|
75
|
+
summary: Script to dump data from an iPhone's sync backup files
|
76
|
+
test_files: []
|
77
|
+
|