Module: Jot::Ruby::Utils::Snippets

Included in:
ImplBase, Operation
Defined in:
lib/jot/ruby/utils/snippets.rb

Instance Method Summary collapse

Instance Method Details

#gem_rootObject



15
16
17
18
19
20
21
22
# File 'lib/jot/ruby/utils/snippets.rb', line 15

def gem_root
  root = File.dirname(File.expand_path(caller_locations(1, 1)[0].path))
  while root != '/'
    return root unless Dir[File.join(root, '*.gemspec')].empty?
    root = File.dirname(root)
  end
  nil
end

#not_implemented(*method_names) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/jot/ruby/utils/snippets.rb', line 5

def not_implemented(*method_names)
  include Module.new do
    method_names.each do |method_name|
      define_method method_name do |*_args|
        raise NotImplementedError, method_name
      end
    end
  end
end