Class: AboutPage::Dependencies

Inherits:
Configuration::Node show all
Defined in:
lib/about_page/dependencies.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Configuration::Node

#add_header, #expects, #messages, #preflight, render_with, #set_headers!

Constructor Details

#initialize(max_depth = 100) ⇒ Dependencies

Returns a new instance of Dependencies.



5
6
7
# File 'lib/about_page/dependencies.rb', line 5

def initialize(max_depth=100)
  @max_depth = max_depth
end

Instance Attribute Details

#max_depthObject (readonly)

Returns the value of attribute max_depth.



3
4
5
# File 'lib/about_page/dependencies.rb', line 3

def max_depth
  @max_depth
end

Instance Method Details

#spec_listObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/about_page/dependencies.rb', line 25

def spec_list
  ruby_ver = "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
  required = environment.current_dependencies.inject({}) { |h,d| h[d.name] = d.groups; h }
  list = [[
    RUBY_ENGINE,
    Module.const_defined?(:JRUBY_VERSION) ? "#{JRUBY_VERSION}r#{JRUBY_REVISION} (#{ruby_ver})" : ruby_ver,
    ['system']
  ]] + environment.specs.sort { |a,b| a.name <=> b.name }.collect { |s| [
    s.name,
    [s.version.to_s, s.git_version.to_s].join,
    required[s.name]
  ]}
  list
end

#to_hObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/about_page/dependencies.rb', line 9

def to_h
  @dependencies ||= spec_list.inject({}) { |h,data|
    spec = { :name => data[0], :version => data[1] }
    if data[2].nil?
      h[:implied] ||= []
      h[:implied] << spec
    else
      data[2].each { |g|
        h[g] ||= []
        h[g] << spec
      }
    end
    h
  }
end