Sha256: a59d00bc78c6c1a393c04308c679fb3b0fda859587e697581adf9d68bc2d9917
Contents?: true
Size: 1021 Bytes
Versions: 6
Compression:
Stored size: 1021 Bytes
Contents
module RbsRails class DependencyBuilder attr_reader :deps def initialize @deps = [] end def build dep_rbs = +"" done = Set.new(['ActiveRecord::Base', 'ActiveRecord', 'Object']) deps.uniq! while dep = deps.shift next unless done.add?(dep) case dep_object = Object.const_get(dep) when Class superclass = dep_object.superclass or raise super_name = Util.module_name(superclass) deps << super_name dep_rbs << "class #{dep} < #{super_name} end\n" when Module dep_rbs << "module #{dep} end\n" else raise end # push namespaces namespaces = dep.split('::') namespaces.pop namespaces.inject('') do |base, name| full_name = base.empty? ? name : [base, name].join('::') deps << full_name full_name end end unless dep_rbs.empty? Util.format_rbs(dep_rbs) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems