# File lib/rspec-puppet/setup.rb, line 57 def self.get_module_name_from_file(file) # FIXME: see discussion at # https://github.com/rodjek/rspec-puppet/issues/290 if Puppet.version.to_f >= 4.0 p = Puppet::Pops::Parser::Lexer2.new else p = Puppet::Parser::Lexer.new end module_name = nil p.string = File.read(file) tokens = p.fullscan i = tokens.index { |token| [:CLASS, :DEFINE].include? token.first } unless i.nil? module_name = tokens[i + 1].last[:value].split('::').first end module_name end