fedux_org-stdlib 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07105d31a9defee5a1b04c4750d41e349265e320
4
- data.tar.gz: c096fa8eb0183ae14945d223a23785882f060e3a
3
+ metadata.gz: 907a7d351528faae756fd50831b8ddaa35693456
4
+ data.tar.gz: 336241c90c03b70e2cc310ca90241cea9c78df59
5
5
  SHA512:
6
- metadata.gz: a86ac5f4d81cedfba4d2032e4b3a1edb536293d39b7103abb0f9bbd1828ec6ab8e05461a2fbbbeeb135289e08de7dd311255660e1a5879a66c053ddebc4eca35
7
- data.tar.gz: 6050c492908fe9ff901eabf636acbe2b7e1f821008f75e06ea0d898edb2b3c677b5c1d72b956a11197a9477102a799c238e9aedfc1331ef3dd1ffb8a9a73adae
6
+ metadata.gz: f08f459e7c6233149ee3fbcbf4f07da665650d21ae7708c9de8bf9f71a7ca6f921b5fd59d6762d0a0eb6a4a080f89b54ed120679efbcef9cc9817917b724efec
7
+ data.tar.gz: 949807005bd2ff2c77c1833905ec13786735e0d8ae1b0696dfe6156d61a62070d1b8dbbd3a11a6ebd6dad422a091fac2bba324bb4b7ff615c97dd2f24d8d32a1
data/Gemfile CHANGED
@@ -40,6 +40,7 @@ group :development, :test do
40
40
  gem 'yard'
41
41
  gem 'travis-lint'
42
42
  gem 'facter'
43
+ gem 'hirb'
43
44
 
44
45
  gem 'fedux_org_stdlib-fixtures-plugin_manager-plugin-load', require: false, path: File.expand_path('../fixtures/plugin-load-app', __FILE__)
45
46
  gem 'fedux_org_stdlib-fixtures-plugin_manager-plugin-no_load', require: false, path: File.expand_path('../fixtures/plugin-no_load-app', __FILE__)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fedux_org-stdlib (0.7.5)
4
+ fedux_org-stdlib (0.7.6)
5
5
  activesupport
6
6
 
7
7
  PATH
@@ -72,6 +72,7 @@ GEM
72
72
  multi_json (~> 1.3)
73
73
  github-markup (1.2.1)
74
74
  posix-spawn (~> 0.3.8)
75
+ hirb (0.7.2)
75
76
  i18n (0.6.11)
76
77
  json (1.8.1)
77
78
  launchy (2.4.2)
@@ -171,6 +172,7 @@ DEPENDENCIES
171
172
  filegen
172
173
  fuubar
173
174
  github-markup
175
+ hirb
174
176
  launchy
175
177
  pry
176
178
  pry-byebug
@@ -5,11 +5,12 @@ module FeduxOrgStdlib
5
5
 
6
6
  private
7
7
 
8
- attr_accessor :enabled, :active, :gem_name
8
+ attr_accessor :enabled, :active
9
+ attr_writer :gem_name
9
10
 
10
11
  public
11
12
 
12
- attr_reader :name
13
+ attr_reader :name, :gem_name
13
14
 
14
15
  def initialize(name, gem_name:, enabled:)
15
16
  @name = name
@@ -2,8 +2,9 @@
2
2
  require 'fedux_org_stdlib/gem_plugins/no_plugin'
3
3
  require 'fedux_org_stdlib/gem_plugins/plugin'
4
4
  require 'fedux_org_stdlib/gem_plugins/exceptions'
5
+ require 'fedux_org_stdlib/list'
5
6
 
6
- require_library %w( active_support/core_ext/string/inflections active_support/core_ext/object/blank )
7
+ require_library %w( active_support/core_ext/string/inflections active_support/core_ext/object/blank hirb/console )
7
8
 
8
9
  module FeduxOrgStdlib
9
10
  module GemPlugins
@@ -100,6 +101,15 @@ module FeduxOrgStdlib
100
101
  each_enabled_plugin { |p| p.activate }
101
102
  end
102
103
 
104
+ # String representation
105
+ def to_s
106
+ data = plugins.inject([]) { |a, e| a << {name: e.name, enabled: e.enabled?, gem_name: e.gem_name} }
107
+
108
+ List.new(data).to_s(
109
+ fields: [:name, :gem_name, :enabled]
110
+ )
111
+ end
112
+
103
113
  private
104
114
 
105
115
  def each_enabled_plugin(&block)
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+ require_library %w( hirb/console )
3
+
4
+ module FeduxOrgStdlib
5
+ class List
6
+
7
+ private
8
+
9
+ attr_reader :data
10
+
11
+ public
12
+
13
+ def initialize(*data)
14
+ @data = data.flatten.map { |e| Hash(e) }
15
+ end
16
+
17
+ # Render data to table
18
+ def to_s(**options)
19
+ Hirb::Helpers::Table.render data, header_filter: proc { |h| h.humanize }, **options
20
+ end
21
+
22
+ # Data as array
23
+ def to_a
24
+ Array(data)
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # FeduxOrgStdlib
3
3
  module FeduxOrgStdlib
4
- VERSION = '0.7.6'
4
+ VERSION = '0.7.7'
5
5
  end
data/spec/list_spec.rb ADDED
@@ -0,0 +1,43 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'fedux_org_stdlib/list'
4
+
5
+ RSpec.describe List do
6
+ context '#to_a' do
7
+ it 'returns data as array' do
8
+ list = List.new(
9
+ [
10
+ { name: 'user1' }
11
+ ]
12
+ )
13
+
14
+ expect(list.to_a).to include(name: 'user1')
15
+ end
16
+
17
+ it 'handles non array input as well' do
18
+ list = List.new(name: 'user1', age: 30)
19
+
20
+ expect(list.to_a).to include(name: 'user1', age: 30)
21
+ end
22
+ end
23
+
24
+ context '#to_s' do
25
+ it 'converts data to table' do
26
+ list = List.new(name: 'user1', age: 30)
27
+
28
+ expect(list.to_s).to include('| 30 | user1 |')
29
+ end
30
+
31
+ it 'passes options to table helper' do
32
+ list = List.new(name: 'user1', age: 30)
33
+ expect_result = <<-EOS.strip_heredoc
34
+ ****** 1. row ******
35
+ Age: 30
36
+ Name: user1
37
+ EOS
38
+
39
+ expect(list.to_s(style: :vertical)).to include expect_result
40
+ end
41
+ end
42
+
43
+ end
@@ -31,4 +31,14 @@ RSpec.describe GemPlugins::PluginManager do
31
31
  expect(result).to include 'plugin-blub'
32
32
  end
33
33
  end
34
+
35
+ context '#to_s' do
36
+ it 'has a string representation' do
37
+ manager = GemPlugins::PluginManager.new prefix: 'fedux_org_stdlib-fixtures-plugin_manager-'
38
+ manager.disable_plugin 'plugin-no_load'
39
+ manager.load_plugins
40
+
41
+ expect(manager.to_s).to include 'plugin'
42
+ end
43
+ end
34
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -78,6 +78,7 @@ files:
78
78
  - lib/fedux_org_stdlib/gem_plugins/no_plugin.rb
79
79
  - lib/fedux_org_stdlib/gem_plugins/plugin.rb
80
80
  - lib/fedux_org_stdlib/gem_plugins/plugin_manager.rb
81
+ - lib/fedux_org_stdlib/list.rb
81
82
  - lib/fedux_org_stdlib/logging.rb
82
83
  - lib/fedux_org_stdlib/logging/logger.rb
83
84
  - lib/fedux_org_stdlib/logging/severity.rb
@@ -173,6 +174,7 @@ files:
173
174
  - spec/examples/models/filesystem_based/find_files/abc.rb.swp
174
175
  - spec/examples/models/filesystem_based/find_files/cde.rb
175
176
  - spec/examples/project/plan.tjp
177
+ - spec/list_spec.rb
176
178
  - spec/logger/logger_spec.rb
177
179
  - spec/logic_converters/on_off_converter_spec.rb
178
180
  - spec/logic_converters/true_false_converter_spec.rb
@@ -249,6 +251,7 @@ test_files:
249
251
  - spec/examples/models/filesystem_based/find_files/abc.rb.swp
250
252
  - spec/examples/models/filesystem_based/find_files/cde.rb
251
253
  - spec/examples/project/plan.tjp
254
+ - spec/list_spec.rb
252
255
  - spec/logger/logger_spec.rb
253
256
  - spec/logic_converters/on_off_converter_spec.rb
254
257
  - spec/logic_converters/true_false_converter_spec.rb