Repository navigation
Expand file tree
/
Copy pathRakefile
More file actions
155 lines (132 loc) · 4.17 KB
/
Copy pathRakefile
File metadata and controls
155 lines (132 loc) · 4.17 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
warn e.message
warn 'Run `bundle install` to install missing gems'
exit e.status_code
end
require 'psych'
if defined?(Psych::ClassLoader) && defined?(Psych::ClassLoader::ALLOWED_CLASSES)
Psych::ClassLoader::ALLOWED_CLASSES << 'Gem::Specification'
end
#require 'juwelier'
#Juwelier::Tasks.new do |gem|
# # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
# gem.name = 'rubyXL'
# gem.homepage = 'http://github.com/gilt/rubyXL'
# gem.license = 'MIT'
# gem.summary = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
# gem.description = %q{rubyXL is a gem which allows the parsing, creation, and manipulation of Microsoft Excel (.xlsx/.xlsm) Documents}
# gem.email = 'bhagwat.vivek@gmail.com'
# gem.authors = ['Vivek Bhagwat', 'Wesha']
## gem.required_ruby_version = '>2.1'
# dependencies defined in Gemfile
#end
#Juwelier::RubygemsDotOrgTasks.new
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
test.warning = true
end
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:rspec)
task :default => :rspec
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ''
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "rubyXL #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
task :preload_library do
$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib' # Make Ruby aware of load path
require './lib/rubyXL'
end
desc 'Dump profiling data with stackprof'
task :stackprof => :preload_library do
require 'benchmark'
require 'stackprof'
spreadsheets = Dir.glob(File.join('test', 'input', '*.xls?')).sort!
spreadsheets.each { |input|
puts "<<<--- Profiling parsing of #{input}..."
doc = nil
StackProf.run(:mode => :cpu, :interval => 100,
:out => "tmp/stackprof-cpu-parse-#{File.basename(input)}.dump") {
doc = RubyXL::Parser.parse(input)
}
output = File.join('test', 'output', File.basename(input))
puts "--->>> Profiling writing of #{output}..."
StackProf.run(:mode => :cpu, :interval => 100,
:out => "tmp/stackprof-cpu-write-#{File.basename(input)}.dump") {
doc.write(output)
}
}
end
desc 'Dump profiling data with ruby-prof'
task :rubyprof => :preload_library do
require 'ruby-prof'
spreadsheets = Dir.glob(File.join('test', 'input', '*.xls?')).sort!
spreadsheets.each { |input|
puts "<<<--- Profiling parsing of #{input}..."
doc = nil
result = RubyProf::Profile.profile {
doc = RubyXL::Parser.parse(input)
}
printer = RubyProf::CallStackPrinter.new(result)
File.open("tmp/ruby-prof-parse-#{File.basename(input)}.html", 'w') { |f| printer.print(f) }
output = File.join('test', 'output', File.basename(input))
puts "--->>> Profiling writing of #{output}..."
result = RubyProf::Profile.profile {
doc.write(output)
}
printer = RubyProf::CallStackPrinter.new(result)
File.open("tmp/ruby-prof-write-#{File.basename(input)}.html", 'w') { |f| printer.print(f) }
}
end
desc 'Start IRB with all runtime dependencies loaded'
task :console => :preload_library do
require "irb"
::ARGV.pop # Do not allow IRB to grab Rake's parameter
IRB.start
end
desc 'Build gem into pkg'
task :build do
`gem build`
end
desc 'Displays the current version'
task :version => :preload_library do
puts RubyXL::VERSION
end
desc 'Releases the current version'
task :release => :preload_library do
`gem release`
end
namespace :version do
namespace :bump do
desc 'Bump the major version by 1'
task :major do
`gem bump major --no-commit`
end
end
end
namespace :version do
namespace :bump do
desc 'Bump the minor version by 1'
task :minor do
`gem bump minor --no-commit`
end
end
end
namespace :version do
namespace :bump do
desc 'Bump the patch version by 1'
task :patch do
`gem bump patch --no-commit`
end
end
end