Module: Inline

Defined in:
lib/inline.rb,
lib/inline/mapping.rb,
lib/inline/version.rb

Overview

Inline::Mapping - mapping method names from impl to test.

Method names are mapped bidirectionally in the following way:

method      test_method
method?     test_method_eh          (too much exposure to Canadians :)
method!     test_method_bang
method=     test_method_equals
[]          test_index
*           test_times
==          test_equals2
===         test_equals3

Further, any of the test methods should be able to have arbitrary extensions put on the name to distinguish edge cases:

method      test_method
method      test_method_simple
method      test_method_no_network

To allow for unmapped test methods (ie, non-unit tests), name them:

test_integration_.*

Defined Under Namespace

Modules: Mapping Classes: C

Constant Summary collapse

WINDOZE =
/mswin|mingw/ =~ RUBY_PLATFORM
RUBINIUS =
defined? RUBY_ENGINE
DEV_NULL =
(WINDOZE ? 'nul'      : '/dev/null')
GEM =
'gem'
RAKE =
if RUBINIUS then
  File.join(Gem.bindir, 'rake')
else
  "#{Gem.ruby} -S rake"
end
VERSION =
"3.12.2".freeze

Class Method Summary collapse

Class Method Details

.directoryObject



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/inline.rb', line 132

def self.directory
  unless defined? @@directory then
    version = "#{Gem.ruby_engine}-#{RbConfig::CONFIG['ruby_version']}"

    @@directory = File.join(self.rootdir, ".ruby_inline", version)
  end

  Dir.assert_secure @@directory

  @@directory
end

.register(cls) ⇒ Object



80
81
82
83
# File 'lib/inline.rb', line 80

def self.register cls
  registered_inline_classes << cls
  registered_inline_classes.uniq!
end

.registered_inline_classesObject



85
86
87
# File 'lib/inline.rb', line 85

def self.registered_inline_classes
  @@registered_inline_classes ||= []
end

.rootdirObject

rootdir can be forced using INLINEDIR variable if not defined, it should store in user HOME folder

Under Windows user data can be stored in several locations:

HOME
HOMEDRIVE + HOMEPATH
APPDATA
USERPROFILE

Perform a check in that other to see if the environment is defined and if so, use it. only try this on Windows.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/inline.rb', line 102

def self.rootdir
  env = ENV['INLINEDIR'] || ENV['HOME']

  if env.nil? and WINDOZE then
    # try HOMEDRIVE + HOMEPATH combination
    if ENV['HOMEDRIVE'] && ENV['HOMEPATH'] then
      env = ENV['HOMEDRIVE'] + ENV['HOMEPATH']
    end

    # no HOMEDRIVE? use APPDATA
    env = ENV['APPDATA'] if env.nil? and ENV['APPDATA']

    # bummer, still no env? then fall to USERPROFILE
    env = ENV['USERPROFILE'] if env.nil? and ENV['USERPROFILE']
  end

  if env.nil? then
    abort "Define INLINEDIR or HOME in your environment and try again"
  end

  unless defined? @@rootdir and env == @@rootdir and test ?d, @@rootdir then
    rootdir = env
    Dir.mkdir rootdir, 0700 unless test ?d, rootdir
    Dir.assert_secure rootdir
    @@rootdir = rootdir
  end

  @@rootdir
end