Permalink
Browse files

Move out lookout-rake

  • Loading branch information...
1 parent dfb4bd3 commit 94db8ebe81ffb54e78e9ab0c86288182131e89c0 Nikolai Weibull committed Apr 26, 2012
View
57 README
@@ -524,62 +524,21 @@
§ Integration
- Lookout can be used from Rake¹. Simply include the following code in
- your ‹Rakefile›:
+ Lookout can be used from Rake¹. Simply install Lookout-Rake²:
- require 'lookout/rake/tasks'
+ % gem install lookout-rake
- Lookout::Rake::Tasks::Test.new
-
- If the ‹:default› task hasn’t been defined it’ll be set to depend on the
- ‹:test› task. The ‹:check› task will also depend on the ‹:test› task.
- There’s also a ‹:test:coverage› task that gets defined that uses the
- coverage library that comes with Ruby 1.9 to check the test coverage when
- the tests are run.
-
- You can hook up your test task to use your Inventory²:
-
- require 'library/version.rb'
-
- Lookout::Rake::Tasks::Test.new :inventory => Library::Version
-
- Also, if you use the tasks that come with Inventory, the test task will
- hook into the inventory you tell them to use automatically.
+ and add the following code to your Rakefile
- To use Lookout together with Vim³, place ‹contrib/rakelookout.vim› in
- ‹~/.vim/compiler› and add
+ require 'lookout/rake-3.0'
- compiler rakelookout
-
- to ‹~/.vim/after/ftplugin/ruby.vim›. Executing ‹:make› from inside Vim
- will now run your tests and an errors and failures can be visited with
- ‹:cnext›. Execute ‹:help quickfix› for additional information.
-
- Another useful addition to your ‹~/.vim/after/ftplugin/ruby.vim› file may
- be
-
- nnoremap <buffer> <silent> <Leader>M <Esc>:call <SID>run_test()<CR>
- let b:undo_ftplugin .= ' | nunmap <buffer> <Leader>M'
-
- function! s:run_test()
- let test = expand('%')
- let line = 'LINE=' . line('.')
- if test =~ '^lib/'
- let test = substitute(test, '^lib/', 'test/', '')
- let line = ""
- endif
- execute 'make' 'TEST=' . shellescape(test) line
- endfunction
+ Lookout::Rake::Tasks::Test.new
- Now, pressing ‹<Leader>M› will either run all tests for a given class, if
- the implementation file is active, or run the test at or just before the
- cursor, if the test file is active. This is useful if you’re currently
- receiving a lot of errors and/or failures and want to focus on those
- associated with a specific class or on a specific test.
+ Make sure to read up on using Lookout-Rake for further benefits and
+ customization.
¹ Read more about Rake at http://rake.rubyforge.org/
-² Get information on Inventory at http://disu.se/software/inventory/
-³ Find out more about Vim at http://www.vim.org/
+² Get information on Lookout-Rake at http://disu.se/software/lookout-rake/
§ Interface Design
View
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
-require 'inventory/rake/tasks-1.0'
+require 'inventory/rake-1.0'
+require 'lookout/rake-3.0'
-$:.unshift File.expand_path('../lib', __FILE__)
-require 'lookout/rake/tasks-3.0'
-require 'lookout/version'
+load File.expand_path('../lib/lookout/version.rb', __FILE__)
Inventory::Rake::Tasks.define Lookout::Version, :gem => proc{ |_, s|
s.author = 'Nikolai Weibull'
View
@@ -1,33 +0,0 @@
-" Vim compiler file
-" Compiler: Rake with lookout test framework
-" Maintainer: Nikolai Weibull <now@bitwi.se>
-" Latest Revision: 2011-05-25
-
-if exists('current_compiler')
- finish
-endif
-let current_compiler = 'rakelookout'
-
-let s:cpo_save = &cpo
-set cpo-=C
-
-if $OS == 'Windows_NT'
- CompilerSet makeprg=rake\ -s\ $*\ 2>&1\ \\\|\ sed\ 's///g'
-else
- CompilerSet makeprg=rake\ -s\ $*
-endif
-
-CompilerSet errorformat=
- \%+E%f:%l:\ parse\ error,
- \%W%f:%l:\ warning:\ %m,
- \%E%f:%l:in\ %*[^:]:\ %m,
- \%E%f:%l:\ %m\ (SyntaxError),
- \%-C%%.%#,
- \%-Z%p^,
- \%E%f:%l:\ %m,
- \%-C%\tfrom\ %f:%l:in\ %.%#,
- \%-Z%\tfrom\ %f:%l,
- \%-G%.%#
-
-let &cpo = s:cpo_save
-unlet s:cpo_save
@@ -1,16 +0,0 @@
-# -*- coding: utf-8 -*-
-
-require 'rake'
-
-module Lookout
- # Namespace for Rake-related namespaces.
- module Rake
- end
-end
-
-# Namespace for Rake tasks.
-module Lookout::Rake::Tasks
- %w'test'.each do |file|
- load File.expand_path('../tasks/%s.rb' % file, __FILE__)
- end
-end
@@ -1,170 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# Rake task for running expectation tests.
-class Lookout::Rake::Tasks::Test
- include Rake::DSL
-
- LoaderPath = File.join(File.dirname(__FILE__), 'test/loader.rb')
- Paths = %w'lib'
-
- # Defines a Rake task for running expectation tests named _:name_. Also
- # defines a task for running expectations with coverage name
- # _:name_:coverage. If _:name_ `#==` `:test`, then the default task is set
- # to depend on it, unless the default task has already been defined, as well
- # as the `:check` task.
- #
- # Optionally yields the _task_ being created so that it may be adjusted
- # further before being defined.
- # @param [Hash] options
- # @option options [Symbol] :name (:test) The name of the task
- # @option options [Array<String>] :paths (['lib']) The paths to add to
- # `$LOAD_PATH`
- # @option options [Array<String>] :requires ([]) The libraries to require
- # @option options [Array<String>] :files (FileList[ENV['TEST']]) The
- # expectation files to load
- # @option options [Inventory] :inventory (Inventory::Rake::Tasks.inventory)
- # The Inventory to look for :paths, :requires, and :files in, see
- # {#inventory=} (the default is only used if `inventory/rake/tasks` has
- # been required)
- # @option options [Gem::Specification] :specification The Gem specification
- # to look for :paths and :requires in, see {#specification=}
- # @option options [Array<String>] :options (['-w']) The options to pass to
- # ruby
- # @yield [?]
- # @yieldparam [Test] task
- def initialize(options = {})
- self.name = options.fetch(:name, :test)
- self.paths = options.fetch(:paths, Paths)
- self.requires = options.fetch(:requires, [])
- self.files = options.fetch(:files){ ENV.include?('TEST') ? FileList[ENV['TEST']] : nil }
- inventory = options[:inventory] ||
- (provided?('inventory/rake/tasks-1.0') and Inventory::Rake::Tasks.inventory) and
- self.inventory = inventory
- self.specification = options.fetch(:specification) if options.include? :specification
- self.options = options.fetch(:options, %w'-w')
- yield self if block_given?
- define
- end
-
- # @return [Symbol] The name of the task
- attr_reader :name
-
- # @param [Symbol] value
- # @return [Symbol] The new name of the task: _value_
- attr_writer :name
-
- # @return [Array<String>] The paths to add to `$LOAD_PATH`; may load
- # {#specification}
- def paths
- return @paths if @paths and not @paths.equal? Paths
- self.specification = specification
- @paths
- end
-
- # @param [Array<String>] value
- # @return [Array<String>] The new paths to add to `$LOAD_PATH`: _value_
- attr_writer :paths
-
- # @return [Array<String>] The libraries to require; may load {#specification}
- def requires
- return @requires unless @requires.empty?
- self.specification = specification
- @requires
- end
-
- # @param [Array<String>] value
- # @return [Array<String>] The new libraries to require: _value_
- attr_writer :requires
-
- # @return [Array<String>] The expectation files to load; defaults to
- # `FileList['test/unit/**/*.rb]`
- def files
- @files ||= FileList['test/unit/**/*.rb']
- end
-
- # @param [Array<String>] value
- # @return [Array<String>] The new expectation files to load: _value_
- attr_writer :files
-
- # @return [Inventory] The inventory to use
- attr_reader :inventory
-
- # @param [Inventory] inventory
- # @return [Inventory] The new inventory to use for {#paths}, {#requires}, and
- # {#files}: _inventory_
- def inventory=(inventory)
- self.paths = inventory.lib_directories
- self.requires = [inventory.package_require]
- @files ||= inventory.unit_test_files
- inventory
- end
-
- # @return [Gem::Specification] The specification to use; will try to find one
- # by looking for `*.gemspec` in the current directory
- # @raise [RuntimeError] If no specification has been set and one can’t be
- # found in the current directory (the project root directory)
- def specification
- return @specification if defined? @specification
- return nil unless defined? ::Gem
- gemspec = Dir['*.gemspec'].first
- fail 'gem specification was not given and could not be found in project root: %s' %
- Dir.pwd unless gemspec
- @specification = Gem::Specification.load(gemspec)
- end
-
- # @param [Gem::Specification] specification
- # @return [Gem::Specification] The new specification to use for {#paths} and
- # {#requires}: _specification_
- def specification=(specification)
- self.paths = specification.require_paths
- self.requires = [specification.name.gsub('-', '/')]
- specification
- end
-
- # @return [Array<String>] The options to pass to ruby
- attr_reader :options
-
- # @param [Array<String>] value
- # @return [Array<String>] The new options to pass to ruby: _value_
- attr_writer :options
-
- def define
- desc @name == :test ? 'Run tests' : 'Run tests for %s' % @name
- task @name do
- run
- end
-
- desc @name == :test ? 'Check test coverage' : 'Check test coverage for %s' % @name
- task :"#{@name}:coverage" do
- run %w'-c'
- end
-
- task :default => @name unless Rake::Task.task_defined? :default
-
- task :check => :test if @name == :test
- end
-
- private
-
- def run(arguments = [])
- ruby '%s -- %s %s' % [(options + paths.uniq.map{ |e| '-I%s' % e }).join(' '),
- escape(LoaderPath),
- requires.uniq.map{ |r| '-r%s' % r }.
- concat(line).concat(arguments).
- push('--').
- concat(files.map{ |e| escape(e) }).join(' ')]
- end
-
- def line
- return [] unless ENV['LINE'] and not ENV['LINE'].empty?
- ['-l%d' % ENV['LINE'].to_i]
- end
-
- def escape(path)
- path.gsub(/([^A-Za-z0-9_\-.,:\/@\n])/n, '\\\\\\1').gsub(/\n/, "'\n'")
- end
-
- def provided?(path)
- $LOADED_FEATURES.any?{ |e| e.end_with? path + File.extname(e) }
- end
-end
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-
-require 'lookout-3.0'
-exit false unless Lookout::Interface::Commandline.new.call
View
@@ -6,6 +6,8 @@ module Lookout
Version = Inventory.new(3, 0, 0){
def dependencies
super + Inventory::Dependencies.new{
+ development 'inventory-rake', 1, 2, 0
+ development 'lookout-rake', 3, 0, 0
development 'yard', 0, 7, 0
runtime 'value', 1, 0, 0
@@ -147,20 +149,6 @@ def libs
'
end
- def additional_libs
- super + %w'
- lookout/rake/tasks-3.0.rb
- lookout/rake/tasks/test.rb
- lookout/rake/tasks/test/loader.rb
- '
- end
-
- def unit_tests
- super - %w'
- lookout/rake/tasks/test/loader.rb
- '
- end
-
def additional_unit_tests
%w'
examples.rb
@@ -1,4 +0,0 @@
-# -*- coding: utf-8 -*-
-
-Expectations do
-end
Oops, something went wrong.

0 comments on commit 94db8eb

Please sign in to comment.