Module: Gempage
- Defined in:
- lib/gempage.rb,
lib/gempage/version.rb,
lib/gempage/ruby_gem_info.rb,
lib/gempage/gemfile_processor.rb
Defined Under Namespace
Modules: Configuration
Classes: GemfileProcessor, RubyGemInfo
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Class Method Details
.color_scheme_file(options) ⇒ Object
57
58
59
|
# File 'lib/gempage.rb', line 57
def color_scheme_file(options)
options && options[:colorscheme] && css_file_exists?(options[:colorscheme].to_s) ? options[:colorscheme].to_s : 'default'
end
|
.create_index ⇒ Object
40
41
42
43
44
|
# File 'lib/gempage.rb', line 40
def create_index
File.open(File.join(gempage_path, "index.html"), "w+") do |file|
file.puts template('layout').result(binding)
end
end
|
.create_stylesheet(options) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/gempage.rb', line 50
def create_stylesheet(options)
File.open(File.join(asset_gempage_path, "application.css"), "w+") do |file|
file.puts File.readlines(File.join(File.dirname(__FILE__), "../public/application.css"))
file.puts File.readlines(File.join(File.dirname(__FILE__), "../public/color-schemes/#{color_scheme_file(options)}.css"))
end
end
|
.css_file_exists?(file_name) ⇒ Boolean
61
62
63
|
# File 'lib/gempage.rb', line 61
def css_file_exists?(file_name)
File.exist?(File.join(File.dirname(__FILE__), "../public/color-schemes/#{file_name}.css"))
end
|
34
35
36
37
38
|
# File 'lib/gempage.rb', line 34
def format(options)
create_index
create_stylesheet(options)
puts output_message
end
|
.gem_listing ⇒ Object
22
23
24
25
|
# File 'lib/gempage.rb', line 22
def gem_listing
return @gem_listing if defined? @gem_listing
@gem_listing = Gempage::GemfileProcessor.new(gemfile_path).gem_list
end
|
.generate(options = nil) ⇒ Object
13
14
15
|
# File 'lib/gempage.rb', line 13
def generate(options = nil)
result ? format(options) : puts(output_message)
end
|
.merge_gem_and_info ⇒ Object
27
28
29
30
31
32
|
# File 'lib/gempage.rb', line 27
def merge_gem_and_info
gem_listing.each_with_index do |listed_gem, index|
ruby_gem_json = Gempage::RubyGemInfo.new(listed_gem['name']).gem_json
gem_listing[index].merge!(ruby_gem_json)
end
end
|
.output_message ⇒ Object
65
66
67
68
69
70
71
72
|
# File 'lib/gempage.rb', line 65
def output_message
if result
category_count = result.group_by{ |result| result['category'] }.length
"Gem list generated for #{category_count} gem groups and #{result.length} gems to #{gempage_path}."
else
"There is no Gemfile to process, how odd..."
end
end
|
.result ⇒ Object
17
18
19
20
|
# File 'lib/gempage.rb', line 17
def result
return @result if defined? @result
@result = gem_listing ? merge_gem_and_info : false
end
|
.template(name) ⇒ Object
46
47
48
|
# File 'lib/gempage.rb', line 46
def template(name)
ERB.new(File.read(File.join(File.dirname(__FILE__), '../views/', "#{name}.erb")))
end
|