-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #614 from sparklemotion/flavorjones-ci-and-dep-cle…
…anup dep: move style and docs deps into a separate group
- Loading branch information
Showing
6 changed files
with
80 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,75 @@ | ||
require "rake/clean" | ||
require "rubocop/rake_task" | ||
|
||
module AstyleHelper | ||
class << self | ||
def run(files) | ||
assert | ||
command = ["astyle", args, files].flatten.shelljoin | ||
system(command) | ||
end | ||
|
||
def assert | ||
require "mkmf" | ||
find_executable0("astyle") || raise("Could not find command 'astyle'") | ||
end | ||
begin | ||
require "rubocop/rake_task" | ||
|
||
def args | ||
[ | ||
# indentation | ||
"--indent=spaces=4", | ||
"--indent-switches", | ||
module AstyleHelper | ||
class << self | ||
def run(files) | ||
assert | ||
command = ["astyle", args, files].flatten.shelljoin | ||
system(command) | ||
end | ||
|
||
# brackets | ||
"--style=1tbs", | ||
"--keep-one-line-blocks", | ||
def assert | ||
require "mkmf" | ||
find_executable0("astyle") || raise("Could not find command 'astyle'") | ||
end | ||
|
||
# where do we want spaces | ||
"--unpad-paren", | ||
"--pad-header", | ||
"--pad-oper", | ||
"--pad-comma", | ||
def args | ||
[ | ||
# indentation | ||
"--indent=spaces=4", | ||
"--indent-switches", | ||
|
||
# "void *pointer" and not "void* pointer" | ||
"--align-pointer=name", | ||
# brackets | ||
"--style=1tbs", | ||
"--keep-one-line-blocks", | ||
|
||
# function definitions and declarations | ||
"--break-return-type", | ||
"--attach-return-type-decl", | ||
# where do we want spaces | ||
"--unpad-paren", | ||
"--pad-header", | ||
"--pad-oper", | ||
"--pad-comma", | ||
|
||
# gotta set a limit somewhere | ||
"--max-code-length=100", | ||
# "void *pointer" and not "void* pointer" | ||
"--align-pointer=name", | ||
|
||
# be quiet about files that haven't changed | ||
"--formatted", | ||
"--verbose" | ||
] | ||
end | ||
# function definitions and declarations | ||
"--break-return-type", | ||
"--attach-return-type-decl", | ||
|
||
def c_files | ||
SQLITE3_SPEC.files.grep(%r{ext/sqlite3/.*\.[ch]\Z}) | ||
# gotta set a limit somewhere | ||
"--max-code-length=100", | ||
|
||
# be quiet about files that haven't changed | ||
"--formatted", | ||
"--verbose" | ||
] | ||
end | ||
|
||
def c_files | ||
SQLITE3_SPEC.files.grep(%r{ext/sqlite3/.*\.[ch]\Z}) | ||
end | ||
end | ||
end | ||
end | ||
|
||
namespace "format" do | ||
desc "Format C code" | ||
task "c" do | ||
puts "Running astyle on C files ..." | ||
AstyleHelper.run(AstyleHelper.c_files) | ||
end | ||
namespace "format" do | ||
desc "Format C code" | ||
task "c" do | ||
puts "Running astyle on C files ..." | ||
AstyleHelper.run(AstyleHelper.c_files) | ||
end | ||
|
||
CLEAN.add(AstyleHelper.c_files.map { |f| "#{f}.orig" }) | ||
CLEAN.add(AstyleHelper.c_files.map { |f| "#{f}.orig" }) | ||
|
||
desc "Format Ruby code" | ||
task "ruby" => "rubocop:autocorrect" | ||
end | ||
desc "Format Ruby code" | ||
task "ruby" => "rubocop:autocorrect" | ||
end | ||
|
||
RuboCop::RakeTask.new | ||
RuboCop::RakeTask.new | ||
|
||
task "format" => ["format:c", "format:ruby"] | ||
task "format" => ["format:c", "format:ruby"] | ||
rescue LoadError => e | ||
puts "NOTE: Rubocop is not available in this environment: #{e.message}" | ||
end |