rubytree 1.0.2 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # Rakefile - This file is part of the RubyTree package.
4
4
  #
5
- # Copyright (c) 2006-2021 Anupam Sengupta
5
+ # Copyright (c) 2006-2022 Anupam Sengupta
6
6
  #
7
7
  # All rights reserved.
8
8
  #
@@ -31,9 +31,13 @@
31
31
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32
32
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
33
  #
34
+ #
35
+ # frozen_string_literal: true
34
36
 
35
37
  require 'rubygems'
36
- GEM_SPEC = eval(File.read('./rubytree.gemspec')) # Load the gemspec.
38
+
39
+ # @todo: Check if Bundler needs to be `require`d.
40
+ GEM_SPEC = Bundler.load_gemspec(File.join(__dir__, 'rubytree.gemspec'))
37
41
 
38
42
  PKG_NAME = GEM_SPEC.name
39
43
  PKG_VER = GEM_SPEC.version
@@ -55,6 +59,7 @@ task :version do
55
59
  end
56
60
 
57
61
  require 'rake/clean'
62
+ desc 'Remove all generated files.'
58
63
  task clean: 'gem:clobber_package'
59
64
  CLEAN.include('coverage')
60
65
  task clobber: [:clean, 'doc:clobber_rdoc', 'doc:clobber_yard']
@@ -70,8 +75,8 @@ namespace :doc do # ................................ Documentation
70
75
  require 'rdoc/task'
71
76
  Rake::RDocTask.new do |rdoc|
72
77
  rdoc.rdoc_dir = 'rdoc'
73
- rdoc.title = "#{PKG_NAME}-#{PKG_VER}"
74
- rdoc.main = 'README.rdoc'
78
+ rdoc.title = "RubyTree Documenation: #{PKG_NAME}-#{PKG_VER}"
79
+ rdoc.main = 'README.md'
75
80
  rdoc.rdoc_files.include(GEM_SPEC.extra_rdoc_files)
76
81
  rdoc.rdoc_files.include('./lib/**/*.rb')
77
82
  end
@@ -95,10 +100,14 @@ namespace :doc do # ................................ Documentation
95
100
  end
96
101
  end
97
102
 
98
- desc 'Run the test cases'
99
- task test: 'test:unit'
103
+ desc 'Run the unit tests'
104
+ task test: %w[test:unit]
105
+
106
+ # ................................ Test related
107
+ namespace :test do
108
+ desc 'Run all the tests'
109
+ task all: %w[test:unit test:spec test:examples]
100
110
 
101
- namespace :test do # ................................ Test related
102
111
  require 'rake/testtask'
103
112
  Rake::TestTask.new(:unit) do |test|
104
113
  test.libs << 'lib' << 'test'
@@ -106,6 +115,18 @@ namespace :test do # ................................ Test related
106
115
  test.verbose = false
107
116
  end
108
117
 
118
+ # ................................ rspec tests
119
+ begin
120
+ require 'rspec/core/rake_task'
121
+
122
+ RSpec::Core::RakeTask.new(:spec) do |t|
123
+ t.fail_on_error = false
124
+ t.rspec_opts = ['--color', '--format doc']
125
+ end
126
+ rescue LoadError
127
+ # Cannot load rspec.
128
+ end
129
+
109
130
  desc 'Run the examples'
110
131
  Rake::TestTask.new(:examples) do |example|
111
132
  example.libs << 'lib' << 'examples'
@@ -118,32 +139,10 @@ namespace :test do # ................................ Test related
118
139
  task :coverage do
119
140
  ruby 'test/run_test.rb'
120
141
  end
121
-
122
- begin
123
- require 'rcov/rcovtask'
124
- Rcov::RcovTask.new(:rcov) do |t|
125
- t.libs << 'test'
126
- t.test_files = FileList['test/**/test_*.rb']
127
- t.verbose = true
128
- t.rcov_opts << '--exclude /gems/,/Library/,/usr/,spec,lib/tasks'
129
- end
130
- rescue LoadError
131
- # Oh well. Can't have everything.
132
- end
133
142
  end
134
143
 
135
- begin # ................................ rspec tests
136
- require 'rspec/core/rake_task'
137
-
138
- RSpec::Core::RakeTask.new(:spec) do |t|
139
- t.fail_on_error = false
140
- t.rspec_opts = ['--color', '--format doc']
141
- end
142
- rescue LoadError
143
- # Cannot load rspec.
144
- end
145
-
146
- namespace :tag do # ................................ Emacs Tags
144
+ # ................................ Emacs Tags
145
+ namespace :tag do
147
146
  require 'rtagstask'
148
147
  RTagsTask.new(:tags) do |rd|
149
148
  rd.vi = false
@@ -153,7 +152,8 @@ rescue LoadError
153
152
  # Oh well. Can't have everything.
154
153
  end
155
154
 
156
- namespace :gem do # ................................ Gem related
155
+ # ................................ Gem related
156
+ namespace :gem do
157
157
  require 'rubygems/package_task'
158
158
  Gem::PackageTask.new(GEM_SPEC) do |pkg|
159
159
  pkg.need_zip = true
@@ -165,3 +165,12 @@ namespace :gem do # ................................ Gem related
165
165
  sh "gem push pkg/#{GEM_NAME}"
166
166
  end
167
167
  end
168
+
169
+ # ................................ Ruby linting
170
+ require 'rubocop/rake_task'
171
+
172
+ RuboCop::RakeTask.new(:rubocop) do |t|
173
+ t.options = ['--display-cop-names']
174
+ t.requires << 'rubocop-rake'
175
+ t.requires << 'rubocop-rspec'
176
+ end