Class: Rim

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rim.rb,
lib/rim/git.rb,
lib/rim/irb.rb,
lib/rim/rdoc.rb,
lib/rim/test.rb,
lib/rim/rspec.rb,
lib/rim/aspell.rb,
lib/rim/gemspec.rb,
lib/rim/regtest.rb

Overview

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. ;)

Constant Summary collapse

VERSION =
'3.0.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aspell_encodingObject

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



6
7
8
# File 'lib/rim/aspell.rb', line 6

def aspell_encoding
  @aspell_encoding
end

#aspell_filesObject

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



9
10
11
# File 'lib/rim/aspell.rb', line 9

def aspell_files
  @aspell_files
end

#aspell_langObject

Language for aspell (default: ‘en’)



12
13
14
# File 'lib/rim/aspell.rb', line 12

def aspell_lang
  @aspell_lang
end

#aspell_word_listObject

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



15
16
17
# File 'lib/rim/aspell.rb', line 15

def aspell_word_list
  @aspell_word_list
end

#git_push_commandsObject

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



6
7
8
# File 'lib/rim/git.rb', line 6

def git_push_commands
  @git_push_commands
end

#irb_requiresObject

Required files for irb (default: Rim#name)



6
7
8
# File 'lib/rim/irb.rb', line 6

def irb_requires
  @irb_requires
end

#rdoc_dirObject

Directory for rdoc output



6
7
8
# File 'lib/rim/rdoc.rb', line 6

def rdoc_dir
  @rdoc_dir
end

#rdoc_filesObject

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



9
10
11
# File 'lib/rim/rdoc.rb', line 9

def rdoc_files
  @rdoc_files
end

#rdoc_mainObject

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



12
13
14
# File 'lib/rim/rdoc.rb', line 12

def rdoc_main
  @rdoc_main
end

#regtest_filesObject

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



9
10
11
# File 'lib/rim/regtest.rb', line 9

def regtest_files
  @regtest_files
end

#regtest_files_rbObject

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



12
13
14
# File 'lib/rim/regtest.rb', line 12

def regtest_files_rb
  @regtest_files_rb
end

#rspec_filesObject

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



6
7
8
# File 'lib/rim/rspec.rb', line 6

def rspec_files
  @rspec_files
end

#rspec_require_pathsObject

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



9
10
11
# File 'lib/rim/rspec.rb', line 9

def rspec_require_paths
  @rspec_require_paths
end

#run_regtest_before_releaseObject

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



16
17
18
# File 'lib/rim/regtest.rb', line 16

def run_regtest_before_release
  @run_regtest_before_release
end

#test_filesObject

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



6
7
8
# File 'lib/rim/test.rb', line 6

def test_files
  @test_files
end

#test_require_pathsObject

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



9
10
11
# File 'lib/rim/test.rb', line 9

def test_require_paths
  @test_require_paths
end

#test_verboseObject

Verbose option for test task (default true)



15
16
17
# File 'lib/rim/test.rb', line 15

def test_verbose
  @test_verbose
end

#test_warningObject

Warning option for test task (default true)



12
13
14
# File 'lib/rim/test.rb', line 12

def test_warning
  @test_warning
end

Class Method Details

.after_setup(&blk) ⇒ Object

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



51
52
53
# File 'lib/rim.rb', line 51

def self.after_setup(&blk)
  @definitions << blk
end

.defaults(&blk) ⇒ Object

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.



25
26
27
28
29
30
31
32
# 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

.setup(&blk) ⇒ Object

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.



38
39
40
41
42
43
44
45
46
# 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

Instance Method Details

#aspell_errors?(fn) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# 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) ⇒ Boolean

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

Returns:

  • (Boolean)


77
78
79
# File 'lib/rim.rb', line 77

def feature_loaded? name
  ! $LOADED_FEATURES.grep(%r((^|/)#{name}\.rb$)).empty?
end

#filelist(*args) ⇒ Object

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.



63
64
65
66
67
68
69
70
71
72
73
# 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

#gemspecObject



18
19
20
# File 'lib/rim/gemspec.rb', line 18

def gemspec
  @gemspec ||= eval(File.read(gemspec_file), binding, gemspec_file)
end

#gemspec_fileObject



14
15
16
# File 'lib/rim/gemspec.rb', line 14

def gemspec_file
  @gemspec_file ||= Dir['*.gemspec'].first or fail 'no gemspec file found'
end

#invoke(name) ⇒ Object

Invoke task name if defined raise an error otherwise.



56
57
58
# File 'lib/rim.rb', line 56

def invoke name
  Rake::Task[name].invoke
end