-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
56 lines (48 loc) · 1.54 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
require 'rubygems'
# RSpec 2.0
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new do |spec|
#spec.pattern = 'spec/**/*_spec.rb'
spec.rspec_opts = ['--backtrace']
end
# Code stats
require 'code_stats'
CodeStats::Tasks.new
# RDocs
require 'rdoc/task'
desc "Generate documentation"
Rake::RDocTask.new do |rd|
rd.main = "README.rdoc"
rd.rdoc_files.include("README.rdoc", "lib/**/*.rb")
rd.rdoc_dir = 'rdoc'
end
# Bundler gem tasks
require 'bundler'
Bundler::GemHelper.install_tasks
# Custom tasks... we problaby don't need these.
desc "Prints out the list of carriers that have add_carrier_mapping directives but no corresponding registered carrier"
task :find_orphaned_mappings do
require './lib/message_gateway/phone_number'
require './lib/message_gateway/util/carrier'
Dir.glob("lib/message_gateway/parser/*.rb") do |ruby_file|
File.open(ruby_file) do |f|
f.each do |line|
if line =~ /add_carrier_mapping\W+?:(.+?),/
carrier_declaration = $+
#puts ruby_file, carrier_declaration
unless MessageGateway::Util::Carrier::CarrierInfo.lookup carrier_declaration
puts "**WARNING: FILE #{ruby_file} declares orphan carrier mapping #{carrier_declaration}"
end
end
end
end
end
end
desc "Prints the known carrier codes - their symbol and their name"
task :print_known_carriers do
require './lib/message_gateway/phone_number'
require './lib/message_gateway/util/carrier'
MessageGateway::Util::Carrier::CarrierInfo.carrier_mapping.each_pair do |key, value|
puts "#{key}\t#{value.name}"
end
end