Module: GuardHelpers::GuardHelper::ClassMethods

Defined in:
lib/ro_support/guard_helpers/erb_helper.rb

Instance Method Summary collapse

Instance Method Details

#create_erb(erb) ⇒ Object



22
23
24
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 22

def create_erb(erb)
  FileUtils.touch create_erb_name(erb)
end

#create_erb_name(erb) ⇒ Object



17
18
19
20
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 17

def create_erb_name(erb)
  basename = Time.now.strftime("%Y-%m-%d-#{erb}.md.erb")
  File.join("templates", basename)
end

#erb_build(erb) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 27

def erb_build(erb)
  #full_name = get_erb_name(erb)
  #puts "full_name:#{full_name}   file:#{File.basename __FILE__} line:#{__LINE__}"
  basename = File.basename(erb).gsub(%r{\.erb}) do |m|
    ""
  end

  to = File.join("_posts", basename)
  ctn = File.read(erb)
  result = ERB.new(ctn).result(binding)
  File.write(to, result)
  notify "#{to} writing success"
end

#erb_build_allObject



41
42
43
44
45
46
47
48
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 41

def erb_build_all
  Find.find("templates") do |erb|
    if test(?f, erb)
      Out.out(erb, "red")
      erb_build(erb)
    end
  end
end

#get_erb_name(erb) ⇒ Object



13
14
15
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 13

def get_erb_name(erb)
  Find.find("templates").grep(%r{#{erb}}).first
end

#site_buildObject



9
10
11
# File 'lib/ro_support/guard_helpers/erb_helper.rb', line 9

def site_build
  bash "jekyll build"
end