Skip to content

Commit

Permalink
adapt to latest changes in y2r
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Jun 14, 2013
1 parent ca26dfa commit f4999af
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/ruby/ycp/ycp.rb
Expand Up @@ -52,29 +52,21 @@ def deep_copy object
alias_method :copy_arg, :deep_copy

def self.include(target, path)
path_without_suffix = path.sub("\.rb$","")
path_without_suffix = path.sub(/\.rb$/,"")
module_name = path_without_suffix.
gsub(/^./) { |s| s.upcase }.
gsub(/\/./) { |s| "::" + s[1].upcase }.
gsub(/\/./) { |s| s[1].upcase }.
gsub(/[-_.]./) { |s| s[1].upcase } +
"Include"

name_parts = module_name.split("::")

parent = YCP
loaded = name_parts.all? do |name_part|
next false unless parent.constants.include? name_part.to_sym
parent = parent.const_get name_part
end
loaded = YCP.constants.include? module_name.to_sym

unless loaded
path = find_include_file path
require path
end

mod = name_parts.reduce(YCP) do |parent, module_name|
YCP.const_get module_name
end
mod = YCP.const_get module_name

return if target.class.include? mod

Expand Down

0 comments on commit f4999af

Please sign in to comment.