Class: JaxrsDoc::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/site.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resources, output_location, options = {}) ⇒ Site

Returns a new instance of Site.



11
12
13
14
15
16
17
# File 'lib/site.rb', line 11

def initialize(resources, output_location, options = {})
  @resources = resources.sort!
  @project_version = options[:project_version]
  @project_name = options[:project_name]
  make_output_dir(output_location)
  copy_resources_to_output_dir
end

Instance Attribute Details

#output_dirObject (readonly)

Returns the value of attribute output_dir.



9
10
11
# File 'lib/site.rb', line 9

def output_dir
  @output_dir
end

#project_nameObject (readonly)

Returns the value of attribute project_name.



9
10
11
# File 'lib/site.rb', line 9

def project_name
  @project_name
end

#project_versionObject (readonly)

Returns the value of attribute project_version.



9
10
11
# File 'lib/site.rb', line 9

def project_version
  @project_version
end

#resourcesObject (readonly)

Returns the value of attribute resources.



9
10
11
# File 'lib/site.rb', line 9

def resources
  @resources
end

Instance Method Details

#generateObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/site.rb', line 19

def generate
  @resources.each { |resource|
    File.open(resource_file_path(resource.name), "w") { |f|
        content = ERB.new(JaxrsDoc::Templates.get_resource_page).result(binding)
        f.syswrite(content)
    }
  }
  
  File.open(index_file_path, "w") { |f|
      content = ERB.new(JaxrsDoc::Templates.get_index_page).result(binding)
      f.syswrite(content)
  }
  @output_dir
end