class Rim

Rim a super simple ruby project / gem manager

Goal is to have a project managing that just works on many Ruby versions as possible and is easy to extend. Feel free to dislike it. ;)

Constants

VERSION

Attributes

aspell_encoding[RW]

Encoding of spell checked files (default: ‘UTF-8’)

aspell_files[RW]

Files to check via aspell (default: /^README/i, /^Changelog/i)

aspell_lang[RW]

Language for aspell (default: ‘en’)

aspell_word_list[RW]

File to store the word list of the project (default: ‘./.aspell.pws’)

git_push_commands[RW]

Git push commands (default: ['--tags origin master'])

irb_requires[RW]

Required files for irb (default: Rim#name)

rdoc_dir[RW]

Directory for rdoc output

rdoc_files[RW]

RDoc files (default: /README(.rdoc)?/i, lib/*\/)

rdoc_main[RW]

Main file for RDoc (default: /README(.rdoc)?/i)

regtest_files[RW]

ALL regtest files incl. sample files, results files and maybe other files (default: REGTEST_FILES)

regtest_files_rb[RW]

Sample files (Ruby files) for regtest (default: REGTEST_FILES_RB)

rspec_files[RW]

RSpec files (default: 'spec/*/.rb')

rspec_require_paths[RW]

Require dirs for tests (default: %w(lib spec))

run_regtest_before_release[RW]

Flag if task regtest is invoked before releasing this means it is a precondition for tasks prepare_release and release (default: true)

test_files[RW]

Test files (default: 'test/*/.rb')

test_require_paths[RW]

Require dirs for tests (default: %w(lib test))

test_verbose[RW]

Verbose option for test task (default true)

test_warning[RW]

Warning option for test task (default true)

Public Class Methods

after_setup(&blk) click to toggle source

The block is executed after setup is completed. Useful when writing rim extensions. At execution time the Rim instance is complete initialized.

# File lib/rim.rb, line 51
def self.after_setup(&blk)
  @definitions << blk
end
attr_accessor(attr) click to toggle source
# File lib/rim.rb, line 83
def self.attr_accessor attr
  attr_writer attr
  self.class_eval "def #{attr}(arg=nil); arg.nil? ? @#{attr} : @#{attr} = arg; end"
end
defaults() { |rim| ... } click to toggle source

Setting the default values of attributes. Useful when writing Rim extensions. The block is evaluated in Rim.instance when no parameter is used. Otherwise the method yields Rim.instance.

# File lib/rim.rb, line 25
def self.defaults(&blk)
  rim = Rim.instance
  if blk.arity < 1
    rim.instance_eval(&blk)
  else
    yield rim
  end
end
execute_definitions() click to toggle source
# File lib/rim.rb, line 90
def self.execute_definitions
  @definitions.each do |blk|
    Rim.instance.instance_eval(&blk)
  end
end
setup() { |rim| ... } click to toggle source

Setting up Rim. This method is usual used in Rakefiles to setting the project specific values of the Rim instance. The block is evaluated in Rim.instance when no parameter is used. Otherwise the method yields Rim.instance.

# File lib/rim.rb, line 38
def self.setup(&blk)
  rim = Rim.instance
  if blk.arity < 1
    rim.instance_eval(&blk)
  else
    yield rim
  end
  execute_definitions
end

Public Instance Methods

aspell_errors?(fn) click to toggle source
# File lib/rim/aspell.rb, line 17
def aspell_errors? fn
  ! `aspell list --encoding=#{aspell_encoding} -l #{aspell_lang} -p #{aspell_word_list} < #{fn}`.empty?
end
feature_loaded?(name) click to toggle source

Helper method to check if a module is already required Example: feature_loaded?(‘rim/release’)

# File lib/rim.rb, line 77
def feature_loaded? name
  ! $LOADED_FEATURES.grep(%r((^|/)#{name}\.rb$)).empty?
end
filelist(*args) click to toggle source

Helper method to generate Rake::FileList objects. Main difference between Rake::FileList.new and this method is the possibility to use Regexp objects as parameters.

# File lib/rim.rb, line 63
def filelist(*args)
  res = FileList.new
  args.each do |arg|
    if arg.kind_of?(Regexp)
      res += FileList.new('**/*').grep(arg)
    else
      res += FileList.new(arg)
    end
  end
  res
end
gemspec() click to toggle source
# File lib/rim/gemspec.rb, line 18
def gemspec
  @gemspec ||= eval(File.read(gemspec_file), binding, gemspec_file)
end
gemspec_file() click to toggle source
# File lib/rim/gemspec.rb, line 14
def gemspec_file
  @gemspec_file ||= Dir['*.gemspec'].first or fail 'no gemspec file found'
end
invoke(name) click to toggle source

Invoke task name if defined raise an error otherwise.

# File lib/rim.rb, line 56
def invoke name
  Rake::Task[name].invoke
end