class Chemlab::CLI::Stubber::PageLibrary
A Class representation of a Page
Library
Attributes
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/chemlab/cli/stubber.rb, line 43 def initialize(path) @path = File.absolute_path(path) end
Public Instance Methods
generate_stub()
click to toggle source
Generate the stub for a given Page
Library
# File lib/chemlab/cli/stubber.rb, line 48 def generate_stub $stdout.print "- #{@path} :\t" begin load @path library = Stubber.libraries.last # last appended library is this Page Library require 'chemlab/core_ext/string/inflections' stub_path = @path.gsub(@path[@path.rindex('.')..], '.stub.rb') File.open(stub_path, 'w') do |stub| stub.write(ERB.new(File.read(File.expand_path("#{__dir__}/stub.erb")), trim_mode: '%<>').result_with_hash({ library: library })) Stubber.libraries.pop end rescue StandardError => e # $stderr.print(e.message) raise e ensure $stdout.print "\tDone.\n" end end