lib/ryan.rb in ryan-1.0.0 vs lib/ryan.rb in ryan-1.1.0
- old
+ new
@@ -16,11 +16,17 @@
extend Forwardable
def_delegators :const,
:name, :funcs, :type, :initialization_args, :func_by_name, :class?, :module?
- # @param [Pathname, String] file
- def initialize(file)
- @sexp = RubyParser.new.parse File.read(file)
+ def self.root
+ Pathname.new File.expand_path('../..', __FILE__)
+ end
+
+ # @note Attempts to read a file if a path is given, otherwise threats input as ruby code string
+ # @param [Pathname, String] input
+ def initialize(input)
+ input = File.read(input) if File.file?(input)
+ @sexp = RubyParser.new.parse(input)
@const = Const.new(sexp)
end
end