forked from twitter-archive/twitter-text-rb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
115 lines (94 loc) · 3.25 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rubygems/specification'
require 'date'
require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
require 'digest'
spec = Gem::Specification.new do |s|
s.name = "twitter-text"
s.version = "1.0.4"
s.authors = ["Matt Sanford", "Patrick Ewing"]
s.email = ["matt@twitter.com", "patrick.henry.ewing@gmail.com"]
s.homepage = "http://twitter.com"
s.description = s.summary = "A gem that provides text handling for Twitter"
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.summary = "Twitter text handling library"
s.add_dependency "actionpack"
s.require_path = 'lib'
s.autorequire = ''
s.files = %w(LICENSE README.rdoc Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
end
task :default => :spec
desc "Run specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = %w(-fs --color)
end
desc "Run all examples with RCov"
Spec::Rake::SpecTask.new('spec:rcov') do |t|
t.spec_files = FileList['spec/**/*.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec']
end
def conformance_version(dir)
Dir[File.join(dir, '*')].inject(Digest::SHA1.new){|digest, file| digest.update(Digest::SHA1.file(file).hexdigest) }
end
namespace :test do
namespace :conformance do
desc "Update conformance testing data"
task :update do
puts "Updating conformance data ... "
system("git submodule init") || raise("Failed to init submodule")
system("git submodule update") || raise("Failed to update submodule")
puts "Updating conformance data ... DONE"
end
desc "Change conformance test data to the lastest version"
task :latest => ['conformance:update'] do
current_dir = File.dirname(__FILE__)
submodule_dir = File.join(File.dirname(__FILE__), "test", "twitter-text-conformance")
version_before = conformance_version(submodule_dir)
system("cd #{submodule_dir} && git pull origin master") || raise("Failed to pull submodule version")
system("cd #{current_dir}")
if conformance_version(submodule_dir) != version_before
system("cd #{current_dir} && git add #{submodule_dir}") || raise("Failed to add upgrade files")
system("git commit -m \"Upgraded to the latest conformance suite\" #{submodule_dir}") || raise("Failed to commit upgraded conformacne data")
puts "Upgraded conformance suite."
else
puts "No conformance suite changes."
end
end
desc "Run conformance test suite"
task :run do
ruby "test/conformance_test.rb"
end
end
desc "Run conformance test suite"
task :conformance => ['conformance:latest', 'conformance:run'] do
end
end
namespace :doc do
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_dir = 'doc'
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
end
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc "install the gem locally"
task :install => [:package] do
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
end
desc "create a gemspec file"
task :make_spec do
File.open("#{GEM}.gemspec", "w") do |file|
file.puts spec.to_ruby
end
end
desc "runs cruise control build"
task :cruise => [:spec, 'test:conformance'] do
end