Skip to content

Commit

Permalink
Arrested by rubocop again.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Oct 18, 2013
1 parent 2887db7 commit 28852ff
Show file tree
Hide file tree
Showing 29 changed files with 288 additions and 303 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Paper House is a ruby gem to easily build C projects using [Rake](https://github
* [Executable](http://rubydoc.info/github/trema/paper-house/PaperHouse/ExecutableTask)
* [Static library](http://rubydoc.info/github/trema/paper-house/PaperHouse/StaticLibraryTask)
* [Shared library](http://rubydoc.info/github/trema/paper-house/PaperHouse/SharedLibraryTask)
* [C extension for Ruby](http://rubydoc.info/github/trema/paper-house/PaperHouse/CExtensionTask)
* [Ruby extension written in C](http://rubydoc.info/github/trema/paper-house/PaperHouse/RubyExtensionTask)


Features Overview
Expand Down Expand Up @@ -48,15 +48,15 @@ If you wish to customize the build process more, please set the
following options defined in `PaperHouse::ExecutableTask`:

```ruby
PaperHouse::ExecutableTask.new :hello do | task |
task.executable_name = "hello_world"
task.target_directory = "objects"
task.cc = "llvm-gcc"
task.includes = "includes"
task.sources = "sources"
task.cflags = [ "-Werror", "-Wall", "-Wextra" ]
task.ldflags = "-L/some/path"
task.library_dependencies = "m"
PaperHouse::ExecutableTask.new :hello do |task|
task.executable_name = 'hello_world'
task.target_directory = 'objects'
task.cc = 'llvm-gcc'
task.includes = 'includes'
task.sources = 'sources'
task.cflags = %w(-Werror -Wall -Wextra)
task.ldflags = '-L/some/path'
task.library_dependencies = 'm'
end
```

Expand Down
113 changes: 49 additions & 64 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,121 +15,106 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require "bundler/gem_tasks"
require "coveralls/rake/task"
require "flay"
require "flay_task"
require "flog"
require "rake/tasklib"
require "reek/rake/task"
require "rspec/core"
require "rspec/core/rake_task"
require "yaml"
require "yard"


$ruby_source = FileList[ "lib/**/*.rb" ]

require 'bundler/gem_tasks'
require 'coveralls/rake/task'
require 'flay'
require 'flay_task'
require 'flog'
require 'rake/tasklib'
require 'reek/rake/task'
require 'rspec/core'
require 'rspec/core/rake_task'
require 'yaml'
require 'yard'

$ruby_source = FileList['lib/**/*.rb']

task :default => :travis
task :travis => [ :spec, :cucumber, :quality, "coveralls:push" ]
task :quality => [ :reek, :flog, :flay ]

task :travis => [:spec, :cucumber, :quality, 'coveralls:push']
task :quality => [:reek, :flog, :flay]

Coveralls::RakeTask.new


RSpec::Core::RakeTask.new


require "cucumber/rake/task"
Cucumber::Rake::Task.new do | t |
require 'cucumber/rake/task'
Cucumber::Rake::Task.new do |t|
profile = %w(--profile)
require "paper_house/platform"
require 'paper_house/platform'
if PaperHouse::Platform::MAC
profile << "mac"
profile << 'mac'
else
profile << "linux"
profile << 'linux'
end
t.cucumber_opts = profile.join( " " )
t.cucumber_opts = profile.join(' ')
end


Reek::Rake::Task.new do | t |
Reek::Rake::Task.new do |t|
t.fail_on_error = true
t.verbose = false
t.ruby_opts = [ "-rubygems" ]
t.reek_opts = "--quiet"
t.ruby_opts = ['-rubygems']
t.reek_opts = '--quiet'
t.source_files = $ruby_source
end


desc "Analyze for code complexity"
desc 'Analyze for code complexity'
task :flog do
flog = Flog.new( :continue => true )
flog.flog( *$ruby_source )
flog = Flog.new(:continue => true)
flog.flog(*$ruby_source)
threshold = 10

bad_methods = flog.totals.select do | name, score |
( not ( /##{flog.no_method}$/=~ name ) ) and score > threshold
bad_methods = flog.totals.select do |name, score|
!(/##{flog.no_method}$/ =~ name) && score > threshold
end
bad_methods.sort do | a, b |
a[ 1 ] <=> b[ 1 ]
end.reverse.each do | name, score |
puts "%8.1f: %s" % [ score, name ]
bad_methods.sort do |a, b|
a[1] <=> b[1]
end.reverse.each do |name, score|
puts sprintf('%8.1f: %s', [score, name])
end
unless bad_methods.empty?
raise "#{ bad_methods.size } methods have a flog complexity > #{ threshold }"
fail "#{bad_methods.size} methods have a flog complexity > #{threshold}"
end
end


FlayTask.new do | t |
t.dirs = $ruby_source.collect do | each |
each[ /[^\/]+/ ]
FlayTask.new do |t|
t.dirs = $ruby_source.map do |each|
each[/[^\/]+/]
end.uniq
t.threshold = 0
t.verbose = $trace
end


task :relish do
sh "relish push trema/paper-house"
sh 'relish push trema/paper-house'
end


YARD::Rake::YardocTask.new do | t |
t.options = [ "--no-private" ]
t.options << "--debug" << "--verbose" if $trace
YARD::Rake::YardocTask.new do |t|
t.options = ['--no-private']
t.options << '--debug' << '--verbose' if $trace
end


def travis_yml
File.join File.dirname( __FILE__ ), ".travis.yml"
File.join File.dirname(__FILE__), '.travis.yml'
end


def rubies
( [ "1.8.7" ] + YAML.load_file( travis_yml )[ "rvm" ] ).uniq.sort
(['1.8.7'] + YAML.load_file(travis_yml)['rvm']).uniq.sort
end


desc "Run tests against multiple rubies"
desc 'Run tests against multiple rubies'
task :portability

rubies.each do | each |
portability_task_name = "portability:#{ each }"
rubies.each do |each|
portability_task_name = "portability:#{each}"
task :portability => portability_task_name

desc "Run tests against Ruby#{ each }"
desc "Run tests against Ruby#{each}"
task portability_task_name do
sh "rvm #{ each } exec bundle"
sh "rvm #{ each } exec bundle exec rake"
sh "rvm #{each} exec bundle"
sh "rvm #{each} exec bundle exec rake"
end
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
Expand Down
3 changes: 0 additions & 3 deletions examples/c_extension/Rakefile

This file was deleted.

5 changes: 0 additions & 5 deletions examples/c_extension/Rakefile.llvm

This file was deleted.

2 changes: 1 addition & 1 deletion examples/executable/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require "paper_house"
require 'paper_house'

PaperHouse::ExecutableTask.new :hello
10 changes: 5 additions & 5 deletions examples/executable_subdirs/Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require "paper_house"
require 'paper_house'

PaperHouse::ExecutableTask.new :hello do | task |
task.executable_name = "hello"
task.target_directory = "objects"
task.sources = "sources/*.c"
task.includes = "includes"
task.executable_name = 'hello'
task.target_directory = 'objects'
task.sources = 'sources/*.c'
task.includes = 'includes'
task.cflags = %w(-Wall -Wextra)
end
File renamed without changes.
3 changes: 3 additions & 0 deletions examples/ruby_extension/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'paper_house'

PaperHouse::RubyExtensionTask.new :hello
5 changes: 5 additions & 0 deletions examples/ruby_extension/Rakefile.llvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require "paper_house"

PaperHouse::RubyExtensionTask.new :hello do |task|
task.cc = "llvm-gcc"
end
File renamed without changes.
14 changes: 7 additions & 7 deletions examples/shared_library/Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require "paper_house"
require 'paper_house'

$libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
task.version = "0.1.0"
task.sources = "hello.c"
task.library_dependencies = "m" # not used.
task.version = '0.1.0'
task.sources = 'hello.c'
task.library_dependencies = 'm' # not used.
end

task :hello => [:libhello, $libhello.linker_name, $libhello.soname]

PaperHouse::ExecutableTask.new :hello do | task |
task.sources = "main.c"
task.ldflags = "-L."
task.sources = 'main.c'
task.ldflags = '-L.'
end

load "symlinks.rake"
load 'symlinks.rake'
20 changes: 10 additions & 10 deletions examples/shared_library_subdirs/Rakefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
require "paper_house"
require 'paper_house'

libhello = PaperHouse::SharedLibraryTask.new :libhello do | task |
task.library_name = "hello"
task.version = "0.1.0"
task.target_directory = "objects"
task.sources = "sources/hello.c"
task.includes = "includes"
task.library_name = 'hello'
task.version = '0.1.0'
task.target_directory = 'objects'
task.sources = 'sources/hello.c'
task.includes = 'includes'
task.cflags = %w(-Werror -Wall -Wextra)
end

task :hello => [:libhello, libhello.linker_name, libhello.soname]

PaperHouse::ExecutableTask.new :hello do | task |
task.sources = "sources/main.c"
task.includes = "includes"
task.ldflags = "-L."
task.sources = 'sources/main.c'
task.includes = 'includes'
task.ldflags = '-L.'
end

[libhello.linker_name, libhello.soname].each do | each |
file each do | task |
symlink File.join("objects", libhello.target_file_name), task.name
symlink File.join('objects', libhello.target_file_name), task.name
end

CLOBBER.include each if FileTest.exists?(each)
Expand Down
8 changes: 4 additions & 4 deletions examples/static_library/Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require "paper_house"
require 'paper_house'

task :hello => :libhello

PaperHouse::StaticLibraryTask.new :libhello do | task |
task.sources = "hello.c"
task.sources = 'hello.c'
end

PaperHouse::ExecutableTask.new :hello do | task |
task.ldflags = "-L."
task.sources = "main.c"
task.ldflags = '-L.'
task.sources = 'main.c'
end
16 changes: 8 additions & 8 deletions examples/static_library_subdirs/Rakefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
require "paper_house"
require 'paper_house'

task :hello => :libhello

PaperHouse::StaticLibraryTask.new :libhello do | task |
task.library_name = "hello"
task.target_directory = "objects"
task.sources = "sources/hello.c"
task.includes = "includes"
task.library_name = 'hello'
task.target_directory = 'objects'
task.sources = 'sources/hello.c'
task.includes = 'includes'
task.cflags = %w(-Werror -Wall -Wextra)
end

PaperHouse::ExecutableTask.new :hello do | task |
task.sources = "sources/main.c"
task.includes = "includes"
task.ldflags = "-Lobjects"
task.sources = 'sources/main.c'
task.includes = 'includes'
task.ldflags = '-Lobjects'
end

0 comments on commit 28852ff

Please sign in to comment.