about_page 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- about_page (0.0.1)
4
+ about_page (0.0.2)
5
5
  rails (~> 3.2)
6
6
 
7
7
  GEM
@@ -7,7 +7,8 @@ module AboutPage
7
7
  def index
8
8
  @configuration = AboutPage.configuration
9
9
 
10
- AboutPage.configuration.set_headers!(response)
10
+ @configuration = @configuration.select { |key, value| (params[:filter].split(/[\W\+]/) + ["app"]).include? key.to_s } if params[:filter]
11
+ @configuration.set_headers!(response)
11
12
 
12
13
  respond_to do |format|
13
14
  format.html { render :status => @configuration.ok? ? 200 : 417 } # about_page.html.erb
@@ -1,4 +1,9 @@
1
1
  <h1><%= key.to_s.humanize %></h1>
2
+ <% if profile.respond_to? :messages %>
3
+ <% profile.messages.each do |msg| %>
4
+ <div><%= msg %></div>
5
+ <% end %>
6
+ <% end %>
2
7
  <ul>
3
8
  <% profile.each_pair do |k,v| %>
4
9
  <li><%= [k,v].join(': ') %></li>
@@ -1,3 +1,4 @@
1
1
  AboutPage::Engine.routes.draw do
2
+ match ":filter" => 'about_page/about#index'
2
3
  root :to => 'about_page/about#index'
3
4
  end
@@ -8,6 +8,14 @@ module AboutPage
8
8
  Hash[*@table.map { |k, v| [k, (v.to_h if v.respond_to? :to_h || v) ] }.flatten ]
9
9
  end
10
10
 
11
+ def reject &block
12
+ self.class.new to_h.reject(&block)
13
+ end
14
+
15
+ def select &block
16
+ self.class.new to_h.select(&block)
17
+ end
18
+
11
19
  def to_xml(options = {})
12
20
  @table
13
21
  end
@@ -22,8 +30,16 @@ module AboutPage
22
30
  delegate :to_xml, :to_h, :to_json, :to => :hash
23
31
  delegate :each, :map, :to => :to_h
24
32
 
25
- def initialize
26
- @hash = OpenStructWithHashAccess.new
33
+ def initialize hash = nil
34
+ @hash = hash || OpenStructWithHashAccess.new
35
+ end
36
+
37
+ def reject &block
38
+ AboutPage::Configuration.new @hash.reject(&block)
39
+ end
40
+
41
+ def select &block
42
+ AboutPage::Configuration.new @hash.select(&block)
27
43
  end
28
44
 
29
45
  def method_missing *args
@@ -52,7 +68,7 @@ module AboutPage
52
68
  end
53
69
 
54
70
  def set_headers! response
55
-
71
+ messages.each { |m| add_header(response, m) }
56
72
  end
57
73
 
58
74
  def add_header response, text
@@ -64,6 +80,10 @@ module AboutPage
64
80
  def ok?
65
81
  true
66
82
  end
83
+
84
+ def messages
85
+ []
86
+ end
67
87
  end
68
88
  end
69
89
  end
@@ -9,7 +9,24 @@ module AboutPage
9
9
  end
10
10
 
11
11
  def to_h
12
- rubydora.profile
12
+ rubydora.profile || {}
13
13
  end
14
+
15
+ def ok?
16
+ !to_h.empty?
17
+ end
18
+
19
+ def messages
20
+ a = []
21
+ a << "Unable to connect to fedora: #{self.rubydora.inspect}" if rubydora.profile.nil?
22
+
23
+ a
24
+ end
25
+
26
+ def preflight request
27
+ # FIXME: ew.
28
+ self.rubydora.instance_variable_set('@profile', nil)
29
+ end
30
+
14
31
  end
15
32
  end
@@ -23,14 +23,22 @@ module AboutPage
23
23
  alias_method :to_h, :index
24
24
 
25
25
  def ok?
26
- true if index[:numDocs].to_i >= minimum_numdocs
26
+ return false if schema.empty?
27
+ return false if index[:numDocs].to_i < minimum_numdocs
28
+
29
+ true
27
30
  end
28
31
 
29
- def set_headers! response
30
- add_header(response, "solr numDocs: #{index[:numDocs]} < #{minimum_numdocs}") if index[:numDocs].to_i < minimum_numdocs
32
+ def messages
33
+ a = []
34
+ a << "Unable to connect to solr: #{self.rsolr.inspect}" if schema.empty?
35
+ a << "Solr numDocs (#{index[:numDocs]}) is less than the minimum #{minimum_numdocs}" if !schema.empty? and index[:numDocs].to_i < minimum_numdocs
36
+
37
+ a
31
38
  end
32
39
 
33
40
  def preflight request
41
+ @schema = nil
34
42
  @minimum_numdocs = request.params['solr.numDocs'].to_i if request.params['solr.numDocs'].to_i
35
43
  end
36
44
 
@@ -1,3 +1,3 @@
1
1
  module AboutPage
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: about_page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  segments:
189
189
  - 0
190
- hash: 1997216736359114848
190
+ hash: 823128254637505744
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  none: false
193
193
  requirements:
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  segments:
198
198
  - 0
199
- hash: 1997216736359114848
199
+ hash: 823128254637505744
200
200
  requirements: []
201
201
  rubyforge_project:
202
202
  rubygems_version: 1.8.24