Permalink
Browse files

various cleanup

  • Loading branch information...
1 parent e7de640 commit 130e77551ec4a36580817e83f7af2f846475c1e3 @quix committed Aug 6, 2009
Showing with 17 additions and 15 deletions.
  1. +6 −3 Rakefile
  2. +7 −12 lib/pure/pure_private/extractor.rb
  3. +4 −0 lib/pure/pure_private/util.rb
View
@@ -4,9 +4,12 @@ require "jumpstart"
Jumpstart.new "pure" do |s|
s.developer("James M. Lawrence", "quixoticsycophant@gmail.com")
- s.dependency("comp_tree", ">= 0.7.6")
- s.dependency("ruby_parser", ">= 2.0.0")
- s.rdoc_files = %w[lib/pure.rb lib/pure/pure_private/singleton_features.rb]
s.rubyforge_user = "quix"
s.rubyforge_name = "purefunctional"
+ s.dependency("comp_tree", ">= 0.7.6")
+ s.dependency("ruby_parser", ">= 2.0.0")
+ s.rdoc_files = %w[
+ lib/pure.rb
+ lib/pure/pure_private/singleton_features.rb
+ ]
end
@@ -24,31 +24,26 @@ def extract(mod, method_name, backtrace)
@engine.extract(mod, method_name, file, line)
end
- def engine=(engine)
- if engine.nil?
+ def engine=(engine_sym)
+ if engine_sym.nil?
@engine = nil
else
begin
- require "pure/pure_private/extractor/#{engine}_check"
+ require "pure/pure_private/extractor/#{engine_sym}_check"
@engine = PurePrivate::Extractor.const_get(
- to_camel_case(engine.to_s)
+ to_camel_case(engine_sym.to_s)
)
rescue LoadError
raise PurePrivate::NotImplementedError,
- "engine not available: #{engine}"
+ "engine not available: #{engine_sym}"
end
end
- engine
+ engine_sym
end
def engine
if @engine
- @engine.
- name.
- split("::").
- last.
- gsub(%r![A-Z]!) { |capital| "_" + capital.downcase }[1..-1].
- to_sym
+ to_underscore_case(@engine.name.split("::").last).to_sym
end
end
@@ -18,6 +18,10 @@ class << obj
def to_camel_case(str)
str.split('_').map { |t| t.capitalize }.join
end
+
+ def to_underscore_case(str)
+ str.gsub(%r![A-Z]!) { |t| "_" + t.downcase }[1..-1]
+ end
end
end
end

0 comments on commit 130e775

Please sign in to comment.