Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 98 lines (80 sloc) 2.693 kB
04b8120 - added a basic rakefile
jhealy authored
1 require "rubygems"
4f878b3 @yob modernise packaging
authored
2 require "bundler"
3 Bundler.setup
4
04b8120 - added a basic rakefile
jhealy authored
5 require 'rake'
e05fbd7 @yob Revert "update require for rdoc 2.4"
authored
6 require 'rake/rdoctask'
4f878b3 @yob modernise packaging
authored
7 require 'rspec/core/rake_task'
81ff5da @yob add a roodi rake task
authored
8 require 'roodi'
9 require 'roodi_task'
04b8120 - added a basic rakefile
jhealy authored
10
2d7bf01 @yob another attempt to ensure cane only runs where it's supported
authored
11 # Cane requires ripper, which appears to only work on MRI 1.9
9782966 @yob yet another attempt to ensure cane only runs on supported rubies
authored
12 if RUBY_VERSION >= "1.9" && RUBY_ENGINE == "ruby"
308ebe9 @yob ensure cane isn't loaded on ruby 1.8
authored
13
5c51c40 @yob add cane to the default build
authored
14 desc "Default Task"
15 task :default => [ :quality, :spec ]
308ebe9 @yob ensure cane isn't loaded on ruby 1.8
authored
16
17 require 'cane/rake_task'
ea9cb97 @yob use morecane to gain additional quality checks
authored
18 require 'morecane'
19
308ebe9 @yob ensure cane isn't loaded on ruby 1.8
authored
20 desc "Run cane to check quality metrics"
21 Cane::RakeTask.new(:quality) do |cane|
22 cane.abc_max = 20
23 cane.style_measure = 100
4867c65 @yob long lines
authored
24 cane.max_violations = 76
ea9cb97 @yob use morecane to gain additional quality checks
authored
25
2d1d4a1 @yob 1.8 style hashes so tests pass on all rubies
authored
26 cane.use Morecane::EncodingCheck, :encoding_glob => "{app,lib,spec}/**/*.rb"
308ebe9 @yob ensure cane isn't loaded on ruby 1.8
authored
27 end
28
5c51c40 @yob add cane to the default build
authored
29 else
30 desc "Default Task"
31 task :default => [ :spec ]
32 end
04b8120 - added a basic rakefile
jhealy authored
33
34 desc "Run all rspec files"
4f878b3 @yob modernise packaging
authored
35 RSpec::Core::RakeTask.new("spec") do |t|
36 t.rspec_opts = ["--color", "--format progress"]
37 t.ruby_opts = "-w"
04b8120 - added a basic rakefile
jhealy authored
38 end
39
bef6cdf @2potatocakes Added rake task to remove CRLF characters added by git
2potatocakes authored
40 # Generate the RDoc documentation
04b8120 - added a basic rakefile
jhealy authored
41 desc "Create documentation"
42 Rake::RDocTask.new("doc") do |rdoc|
43 rdoc.title = "pdf-reader"
44 rdoc.rdoc_dir = (ENV['CC_BUILD_ARTIFACTS'] || 'doc') + '/rdoc'
ab8d110 @yob tweak gem spec
authored
45 rdoc.rdoc_files.include('README.rdoc')
36a836c pdf-reader:
jhealy authored
46 rdoc.rdoc_files.include('TODO')
47 rdoc.rdoc_files.include('CHANGELOG')
81f2812 @yob add a project wide copy of the MIT License
authored
48 rdoc.rdoc_files.include('MIT-LICENSE')
04b8120 - added a basic rakefile
jhealy authored
49 rdoc.rdoc_files.include('lib/**/*.rb')
50 rdoc.options << "--inline-source"
51 end
52
81ff5da @yob add a roodi rake task
authored
53 RoodiTask.new 'roodi', ['lib/**/*.rb']
0adb9e1 @yob add a spec to verify the integrity of PDFs in the spec suite
authored
54
bef6cdf @2potatocakes Added rake task to remove CRLF characters added by git
2potatocakes authored
55 desc "Create a YAML file of integrity info for PDFs in the spec suite"
0adb9e1 @yob add a spec to verify the integrity of PDFs in the spec suite
authored
56 task :integrity_yaml do
57 data = {}
58 Dir.glob("spec/data/**/*.*").each do |path|
59 path_without_spec = path.gsub("spec/","")
60 data[path_without_spec] = {
61 :bytes => File.size(path),
62 :md5 => `md5sum "#{path}"`.split.first
63 } if File.file?(path)
64 end
65 File.open("spec/integrity.yml","wb") { |f| f.write YAML.dump(data)}
66 end
bef6cdf @2potatocakes Added rake task to remove CRLF characters added by git
2potatocakes authored
67
68 desc "Remove any CRLF characters added by Git"
69 task :fix_integrity do
70 yaml_path = File.expand_path("spec/integrity.yml",File.dirname(__FILE__))
71 integrity = YAML.load_file(yaml_path)
72
73 Dir.glob("spec/data/**/*.pdf").each do |path|
74 path_relative_to_spec_folder = path[/.+(data\/.+)/,1]
75 item = integrity[path_relative_to_spec_folder]
76
77 if File.file?(path)
78 file_contents = File.open(path, "rb") { |f| f.read }
79 md5 = Digest::MD5.hexdigest(file_contents)
80
81 unless md5 == item[:md5]
82 #file md5 does not match what was checked into Git
83
84 if Digest::MD5.hexdigest(file_contents.gsub(/\r\n/, "\n")) == item[:md5]
85 #pdf file is fixable by swapping CRLF characters
86
87 File.open(path, "wb") do |f|
88 f.write(file_contents.gsub(/\r\n/, "\n"))
89 end
90 puts "Replaced CRLF characters in: #{path}"
91 else
92 puts "Failed to fix: #{path}"
93 end
94 end
95 end
96 end
97 end
Something went wrong with that request. Please try again.