|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -require 'date' |
4 | | -require 'rake/clean' |
5 | | -require 'rake/extensiontask' |
6 | | -require 'digest/md5' |
| 3 | +require "date" |
| 4 | +require "rake/clean" |
| 5 | +require "rake/extensiontask" |
| 6 | +require "digest/md5" |
7 | 7 |
|
8 | | -host_os = RbConfig::CONFIG['host_os'] |
9 | | -require 'devkit' if host_os == 'mingw32' |
| 8 | +host_os = RbConfig::CONFIG["host_os"] |
| 9 | +require "devkit" if host_os == "mingw32" |
10 | 10 |
|
11 | 11 | task default: [:test] |
12 | 12 |
|
13 | 13 | # Gem Spec |
14 | | -gem_spec = Gem::Specification.load('commonmarker.gemspec') |
| 14 | +gem_spec = Gem::Specification.load("commonmarker.gemspec") |
15 | 15 |
|
16 | 16 | # Ruby Extension |
17 | | -Rake::ExtensionTask.new('commonmarker', gem_spec) do |ext| |
18 | | - ext.lib_dir = File.join('lib', 'commonmarker') |
| 17 | +Rake::ExtensionTask.new("commonmarker", gem_spec) do |ext| |
| 18 | + ext.lib_dir = File.join("lib", "commonmarker") |
19 | 19 | end |
20 | 20 |
|
21 | 21 | # Packaging |
22 | | -require 'bundler/gem_tasks' |
| 22 | +require "bundler/gem_tasks" |
23 | 23 |
|
24 | 24 | # Testing |
25 | | -require 'rake/testtask' |
| 25 | +require "rake/testtask" |
26 | 26 |
|
27 | | -Rake::TestTask.new('test:unit') do |t| |
28 | | - t.libs << 'lib' |
29 | | - t.libs << 'test' |
30 | | - t.pattern = 'test/test_*.rb' |
| 27 | +Rake::TestTask.new("test:unit") do |t| |
| 28 | + t.libs << "lib" |
| 29 | + t.libs << "test" |
| 30 | + t.pattern = "test/test_*.rb" |
31 | 31 | t.verbose = true |
32 | 32 | t.warning = false |
33 | 33 | end |
34 | 34 |
|
35 | | -task 'test:unit' => :compile |
| 35 | +desc "Run unit tests" |
| 36 | +task "test:unit" => :compile |
36 | 37 |
|
37 | | -desc 'Run unit and conformance tests' |
38 | | -task test: %w[test:unit] |
| 38 | +desc "Run unit and conformance tests" |
| 39 | +task test: ["test:unit"] |
39 | 40 |
|
40 | | -require 'rubocop/rake_task' |
| 41 | +require "rubocop/rake_task" |
41 | 42 |
|
42 | 43 | RuboCop::RakeTask.new(:rubocop) |
43 | 44 |
|
44 | | -desc 'Run benchmarks' |
| 45 | +desc "Run benchmarks" |
45 | 46 | task :benchmark do |
46 | | - if ENV['FETCH_PROGIT'] |
47 | | - `rm -rf test/progit` |
48 | | - `git clone https://github.com/progit/progit.git test/progit` |
49 | | - langs = %w[ar az be ca cs de en eo es es-ni fa fi fr hi hu id it ja ko mk nl no-nb pl pt-br ro ru sr th tr uk vi zh zh-tw] |
| 47 | + if ENV["FETCH_PROGIT"] |
| 48 | + %x(rm -rf test/progit) |
| 49 | + %x(git clone https://github.com/progit/progit.git test/progit) |
| 50 | + langs = ["ar", "az", "be", "ca", "cs", "de", "en", "eo", "es", "es-ni", "fa", "fi", "fr", "hi", "hu", "id", "it", "ja", "ko", "mk", "nl", "no-nb", "pl", "pt-br", "ro", "ru", "sr", "th", "tr", "uk", "vi", "zh", "zh-tw"] |
50 | 51 | langs.each do |lang| |
51 | | - `cat test/progit/#{lang}/*/*.markdown >> test/benchinput.md` |
| 52 | + %x(cat test/progit/#{lang}/*/*.markdown >> test/benchinput.md) |
52 | 53 | end |
53 | 54 | end |
54 | | - $LOAD_PATH.unshift 'lib' |
55 | | - load 'test/benchmark.rb' |
| 55 | + $LOAD_PATH.unshift("lib") |
| 56 | + load "test/benchmark.rb" |
56 | 57 | end |
57 | 58 |
|
58 | | -desc 'Match C style of cmark' |
| 59 | +desc "Match C style of cmark" |
59 | 60 | task :format do |
60 | | - sh 'clang-format -style llvm -i ext/commonmarker/*.c ext/commonmarker/*.h' |
| 61 | + sh "clang-format -style llvm -i ext/commonmarker/*.c ext/commonmarker/*.h" |
61 | 62 | end |
62 | 63 |
|
63 | 64 | # Documentation |
64 | | -require 'rdoc/task' |
| 65 | +require "rdoc/task" |
65 | 66 |
|
66 | | -desc 'Generate API documentation' |
| 67 | +desc "Generate API documentation" |
67 | 68 | RDoc::Task.new do |rd| |
68 | | - rd.rdoc_dir = 'docs' |
69 | | - rd.main = 'README.md' |
70 | | - rd.rdoc_files.include 'README.md', 'lib/**/*.rb', 'ext/commonmarker/commonmarker.c' |
71 | | - |
72 | | - rd.options << '--markup tomdoc' |
73 | | - rd.options << '--inline-source' |
74 | | - rd.options << '--line-numbers' |
75 | | - rd.options << '--all' |
76 | | - rd.options << '--fileboxes' |
| 69 | + rd.rdoc_dir = "docs" |
| 70 | + rd.main = "README.md" |
| 71 | + rd.rdoc_files.include("README.md", "lib/**/*.rb", "ext/commonmarker/commonmarker.c") |
| 72 | + |
| 73 | + rd.options << "--markup tomdoc" |
| 74 | + rd.options << "--inline-source" |
| 75 | + rd.options << "--line-numbers" |
| 76 | + rd.options << "--all" |
| 77 | + rd.options << "--fileboxes" |
77 | 78 | end |
78 | 79 |
|
79 | | -desc 'Generate the documentation and run a web server' |
| 80 | +desc "Generate the documentation and run a web server" |
80 | 81 | task serve: [:rdoc] do |
81 | | - require 'webrick' |
| 82 | + require "webrick" |
82 | 83 |
|
83 | | - puts 'Navigate to http://localhost:3000 to see the docs' |
| 84 | + puts "Navigate to http://localhost:3000 to see the docs" |
84 | 85 |
|
85 | | - server = WEBrick::HTTPServer.new Port: 3000 |
86 | | - server.mount '/', WEBrick::HTTPServlet::FileHandler, 'docs' |
87 | | - trap('INT') { server.stop } |
| 86 | + server = WEBrick::HTTPServer.new(Port: 3000) |
| 87 | + server.mount("/", WEBrick::HTTPServlet::FileHandler, "docs") |
| 88 | + trap("INT") { server.stop } |
88 | 89 | server.start |
89 | 90 | end |
90 | 91 |
|
91 | | -desc 'Generate and publish docs to gh-pages' |
| 92 | +desc "Generate and publish docs to gh-pages" |
92 | 93 | task publish: [:rdoc] do |
93 | | - require 'tmpdir' |
94 | | - require 'shellwords' |
| 94 | + require "tmpdir" |
| 95 | + require "shellwords" |
95 | 96 |
|
96 | 97 | Dir.mktmpdir do |tmp| |
97 | 98 | system "mv docs/* #{tmp}" |
98 | | - system 'git checkout origin/gh-pages' |
99 | | - system 'rm -rf *' |
| 99 | + system "git checkout origin/gh-pages" |
| 100 | + system "rm -rf *" |
100 | 101 | system "mv #{tmp}/* ." |
101 | 102 | message = Shellwords.escape("Site updated at #{Time.now.utc}") |
102 | | - system 'git add .' |
| 103 | + system "git add ." |
103 | 104 | system "git commit -am #{message}" |
104 | | - system 'git push origin gh-pages --force' |
105 | | - system 'git checkout master' |
106 | | - system 'echo yolo' |
| 105 | + system "git push origin gh-pages --force" |
| 106 | + system "git checkout master" |
| 107 | + system "echo yolo" |
107 | 108 | end |
108 | 109 | end |
0 commit comments