Sha256: 2a9fa4e60a6e2270b48e6bcd25a8fa06579ac538872b70a5785df4de28bd991c

Contents?: true

Size: 590 Bytes

Versions: 10

Compression:

Stored size: 590 Bytes

Contents

class TestFileTemplates

  def [](filename)
    if have_template?(filename)
      read_template filename
    else
      default_template filename
    end
  end

  private

  def have_template?(filename)
    File.exists?(template_path(filename))
  end

  def read_template(filename)
    File.open(template_path(filename), 'r', &:read)
  end

  def template_path(filename)
    File.expand_path(filename, templates_path)
  end

  def templates_path
    File.expand_path('file_templates', File.dirname(__FILE__))
  end

  def default_template(filename)
    "Contents of #{filename}"
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ftpd-0.3.2 features/support/test_file_templates.rb
ftpd-0.3.1 features/support/test_file_templates.rb
ftpd-0.2.2 features/support/test_file_templates.rb
ftpd-0.2.1 features/support/test_file_templates.rb
ftpd-0.2.0 features/support/test_file_templates.rb
ftpd-0.1.1 features/support/test_file_templates.rb
ftpd-0.1.0 features/support/test_file_templates.rb
ftpd-0.0.1.pre features/support/test_file_templates.rb
ftpd-0.0.0.pre2 features/support/test_file_templates.rb
ftpd-0.0.0.pre1 features/support/test_file_templates.rb