foreman_column_view 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 95da9455cf65da4a8e2944bb57f9bd77521e1ca5
4
- data.tar.gz: 3c892aaceb8c2a1a69daaf84559160d77730a2c6
3
+ metadata.gz: b9b33311126673ce073f9d8dc8da89c55f08f8a7
4
+ data.tar.gz: 235bf44a424fd53d85d678975dec4ae6fc42a390
5
5
  SHA512:
6
- metadata.gz: 81478c69c4a0dbd9b69f07874b94bf2578716cb99a0ffe73a7f80f092fd6a3a167744008f88029b937e3fc581cc6328c364269a037ab329f67efd957b8475eaf
7
- data.tar.gz: 273371f2927e7ff22541cf9f8bdbbe6acb8abd780ff2a18d768e82a4c50437cf878b0f58c2b745b9baf371c5d0cc77f6116f76b55eb3e4be83df9fe6306f4f2e
6
+ metadata.gz: 3f047f1ecdcf6cbb52c6c0cc09fa8d851a82391fcef2b557d764a1d2498f0e6e54936edf8037cfab9dfc7c376c18446adb7b4b4720e938adaa2b40eeeb6102ac
7
+ data.tar.gz: 4022b58d4f20a5db80e7c1af0b9cd1e6b3e7a39e0836e9cce535d6be9a5d926460aec82ed2d5d96cd878ec88cf21f0b70f5527b45621e135c0182387e8f49bf1
data/README.md CHANGED
@@ -4,6 +4,14 @@ A small plugin to showcase the awesome [Deface](https://github.com/spree/deface)
4
4
  library. It simply adds a column to the Hosts list or properties table. It also
5
5
  serves as a simple example of including a new Helper in the plugin.
6
6
 
7
+ ## Compatibility
8
+
9
+ | Foreman Version | Plugin Version |
10
+ | --------------- | --------------:|
11
+ | <= 1.15 | ~> 0.3 |
12
+ | == 1.16 | untested |
13
+ | >= 1.17 | ~> 0.4 |
14
+
7
15
  # Installation
8
16
 
9
17
  Require the gem in Foreman (you may need extra dependencies such as libxml or libxslt
@@ -1,41 +1,46 @@
1
1
  module ForemanColumnView
2
2
  module HostsHelperExtension
3
- def self.included(base)
4
- base.send :alias_method_chain, :overview_fields, :fcv
5
- end
3
+ extend ActiveSupport::Concern
6
4
 
7
- # Extend core HostsHelper to add rows to Properties on hosts/show
8
- def overview_fields_with_fcv host
9
- fields = overview_fields_without_fcv(host)
10
- return fields unless SETTINGS[:column_view]
11
-
12
- valid_views = [:hosts_properties]
13
- SETTINGS[:column_view].reject { |k,v| !valid_views.include?(v[:view]) }.keys.sort.map do |k|
14
- after = SETTINGS[:column_view][k.to_sym][:after]
15
- conditional = SETTINGS[:column_view][k.to_sym][:conditional]
16
- if conditional.present?
17
- method = conditional[0].to_sym
18
- args = conditional.drop(1)
19
- end
5
+ module Overrides
6
+ # Extend core HostsHelper to add rows to Properties on hosts/show
7
+ def overview_fields(host)
8
+ fields = super
9
+ return fields unless SETTINGS[:column_view]
20
10
 
21
- begin
22
- next unless (conditional.present? && host.respond_to?(method) && host.send(method, *args)) ||
23
- (conditional.nil?)
24
- rescue ArgumentError
25
- Rails.logger.warn("Foreman_column_view: Your are supplying the wrong kind/number of arguments to your conditional method. Host #{host} , method - #{method} - arguments - #{args.join(', ')} ")
26
- next
27
- end
11
+ valid_views = [:hosts_properties]
12
+ SETTINGS[:column_view].reject { |k,v| !valid_views.include?(v[:view]) }.keys.sort.map do |k|
13
+ after = SETTINGS[:column_view][k.to_sym][:after]
14
+ conditional = SETTINGS[:column_view][k.to_sym][:conditional]
15
+ if conditional.present?
16
+ method = conditional[0].to_sym
17
+ args = conditional.drop(1)
18
+ end
19
+
20
+ begin
21
+ next unless (conditional.present? && host.respond_to?(method) && host.send(method, *args)) ||
22
+ (conditional.nil?)
23
+ rescue ArgumentError
24
+ Rails.logger.warn("Foreman_column_view: Your are supplying the wrong kind/number of arguments to your conditional method. Host #{host} , method - #{method} - arguments - #{args.join(', ')} ")
25
+ next
26
+ end
28
27
 
29
- # This won't work well with i18n, use row numbers instead
30
- after = fields.find_index { |r| r[0].include? after } unless after.is_a? Fixnum
31
- eval_content = SETTINGS[:column_view][k.to_sym][:eval_content]
32
- content = eval_content ? eval(SETTINGS[:column_view][k.to_sym][:content]) :
33
- fcv_content(host, k)
28
+ # This won't work well with i18n, use row numbers instead
29
+ after = fields.find_index { |r| r[0].include? after } unless after.is_a? Fixnum
30
+ eval_content = SETTINGS[:column_view][k.to_sym][:eval_content]
31
+ content = eval_content ? eval(SETTINGS[:column_view][k.to_sym][:content]) :
32
+ fcv_content(host, k)
34
33
 
35
- fields.insert(after || -1, [fcv_title(k), content])
34
+ fields.insert(after || -1, [fcv_title(k), content])
35
+ end
36
+
37
+ fields
36
38
  end
39
+ end
37
40
 
38
- fields
41
+ included do
42
+ prepend Overrides
39
43
  end
44
+
40
45
  end
41
46
  end
@@ -1,15 +1,16 @@
1
1
  require 'deface'
2
- require 'foreman_column_view'
3
- require 'deface'
4
2
 
5
3
  module ForemanColumnView
6
- #Inherit from the Rails module of the parent app (Foreman), not the plugin.
7
- #Thus, inhereits from ::Rails::Engine and not from Rails::Engine
8
4
  class Engine < ::Rails::Engine
5
+ engine_name 'foreman_column_view'
6
+
7
+ config.autoload_paths += Dir['#{config.root}/app/helpers']
8
+ config.autoload_paths += Dir['#{config.root}/app/overrides']
9
9
 
10
10
  initializer 'foreman_column_view.register_plugin', :before => :finisher_hook do |app|
11
11
  Foreman::Plugin.register :foreman_column_view do
12
- end if (Rails.env == "development" or defined? Foreman::Plugin)
12
+ requires_foreman '>= 1.17'
13
+ end
13
14
  end
14
15
 
15
16
  initializer 'foreman_column_view.helper' do |app|
@@ -1,3 +1,3 @@
1
1
  module ForemanColumnView
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_column_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sutcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-04 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -46,7 +46,7 @@ files:
46
46
  - lib/foreman_column_view/version.rb
47
47
  homepage: http://github.com/GregSutcliffe/foreman_column_view
48
48
  licenses:
49
- - GPL-3
49
+ - GPL-3.0
50
50
  metadata: {}
51
51
  post_install_message:
52
52
  rdoc_options: []