fedux_org-stdlib 0.7.14 → 0.7.15

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: 2c3c74f2e817987c3344c6fc427fe3aecab95dd5
4
- data.tar.gz: 2861de2ac0abae4df1a9a56a4281d7c3c1193bc8
3
+ metadata.gz: b3620db0d8a2e9c953b9f301958a36df12ca6bf6
4
+ data.tar.gz: 32d8f81fb9168468a6dfddb5da3a60274e3f3b11
5
5
  SHA512:
6
- metadata.gz: 6f910d7792719da8152274a147c11a0983910eb26f8c8ef055b2c57fadfc384f95c1e07fdcc34dd4bbcb9dce058b7b0881a29c916b9118ce0728474f62b70cf6
7
- data.tar.gz: 042b8f37317e6569b47c169d3c33946b8ce9790e3bcf7f445e4d19a8bac7633de2b1a450f48b8cb489c6ea23c8ca8aa9c94f39382974b003fca618220d135673
6
+ metadata.gz: 6f869c2fe0adfa38bd8e471ee82c19bbdce4e69c580ac25fa0a7caa42e866cf3a61cf3351ad3c5f30c4314c740727bb325f9df357b1c60e8407fd2cd2dfb2c3e
7
+ data.tar.gz: 875b121ef2709c192360252f53973a8a64ca870a497cc655ef128aa05f5f8b3140b2b9aecff2261851c806a1e7f85d83a5d21406c366a27e59ff4a1e3cf76ca7
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fedux_org-stdlib (0.7.13)
4
+ fedux_org-stdlib (0.7.14)
5
5
  activesupport
6
6
 
7
7
  PATH
@@ -1,6 +1,13 @@
1
1
  # encoding: utf-8
2
2
  class Array
3
- def to_list
4
- self.map { |l| format('"%s"', l) }.join(", ")
3
+ def to_list(separator: ', ', last_separator: separator, around: '"')
4
+ items = self.map { |l| format("#{around}%s#{around}", l) }
5
+
6
+ return items.join(last_separator) if items.size <= 2
7
+
8
+ result = items.slice(1..-1).join(separator) << last_separator
9
+ result << items.last
10
+
11
+ result
5
12
  end
6
13
  end
@@ -1,4 +1,8 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
3
+ require 'fedux_org_stdlib/core_ext/array/list'
4
+ require_library %w{ active_support/core_ext/object/blank }
5
+
2
6
  module FeduxOrgStdlib
3
7
  module GemPlugins
4
8
  class Plugin
@@ -8,15 +12,17 @@ module FeduxOrgStdlib
8
12
 
9
13
  attr_accessor :enabled, :active
10
14
  attr_writer :gem_name
15
+ attr_reader :prefix
11
16
 
12
17
  public
13
18
 
14
19
  attr_reader :name, :gem_name
15
20
 
16
- def initialize(name, gem_name:, enabled:)
21
+ def initialize(name, gem_name:, enabled:, prefix: nil)
17
22
  @name = name
18
23
  @gem_name = gem_name
19
24
  @enabled = enabled
25
+ @prefix = prefix
20
26
  end
21
27
 
22
28
  # Disable a plugin. (prevents plugin from being loaded, cannot
@@ -36,16 +42,24 @@ module FeduxOrgStdlib
36
42
  # disabled)
37
43
  # Does not reload plugin if it's already active.
38
44
  def activate
45
+
46
+ variants = []
47
+ variants << gem_name
48
+ variants << gem_name.gsub(/-/, '/')
49
+ variants << prefix.source.sub(/-$/, '') if prefix
50
+
39
51
  begin
40
52
  if !active?
41
53
  begin
42
- require gem_name
54
+ require variants.shift
43
55
  rescue LoadError
44
- require gem_name.gsub(/-/, '/')
56
+ retry unless variants.blank?
57
+
58
+ raise LoadError
45
59
  end
46
60
  end
47
61
  rescue LoadError => e
48
- warn "Found plugin #{gem_name}, but could not require '#{gem_name}' or '#{gem_name.gsub(/-/, '/')}'"
62
+ warn "Found plugin #{gem_name}, but could not require '#{variants.to_list(last_separator: ' or ')}'"
49
63
  warn e
50
64
  rescue StandardError => e
51
65
  warn "require '#{gem_name}' # Failed, saying: #{e}"
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require 'fedux_org_stdlib/gem_plugins/no_plugin'
3
4
  require 'fedux_org_stdlib/gem_plugins/plugin'
4
5
  require 'fedux_org_stdlib/gem_plugins/exceptions'
@@ -140,6 +141,7 @@ module FeduxOrgStdlib
140
141
  name,
141
142
  gem_name: gem.name,
142
143
  enabled: enabled,
144
+ prefix: prefix,
143
145
  )
144
146
  end
145
147
 
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require_library %w( hirb )
3
4
 
4
5
  module FeduxOrgStdlib
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require 'fedux_org_stdlib/logging'
3
4
  require 'fedux_org_stdlib/models/exceptions'
4
5
  require_library %w{ set }
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require 'fedux_org_stdlib/rake/task'
3
4
  require 'fedux_org_stdlib/require_files'
4
5
  require_library %w{ erubis }
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require 'fedux_org_stdlib/ci'
3
4
 
4
5
  unless ci?
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'fedux_org_stdlib/require_files'
2
3
  require_library %w{ facter }
3
4
 
4
5
  module FeduxOrgStdlib
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # FeduxOrgStdlib
3
3
  module FeduxOrgStdlib
4
- VERSION = '0.7.14'
4
+ VERSION = '0.7.15'
5
5
  end
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'fedux_org_stdlib/core_ext/array/list'
4
+
5
+ RSpec.describe Array do
6
+ context '#to_list' do
7
+ it 'handles single value' do
8
+ input = %w{ asdf }
9
+
10
+ expect(input.to_list).to eq '"asdf"'
11
+ end
12
+
13
+ it 'handles two values' do
14
+ input = %w{ test1 test2 }
15
+
16
+ expect(input.to_list).to eq '"test1", "test2"'
17
+ end
18
+
19
+ it 'converts array to a list of values' do
20
+ input = %w{ asdf asdf asdf}
21
+
22
+ expect(input.to_list).to eq '"asdf", "asdf", "asdf"'
23
+ end
24
+
25
+ it 'supports to change the last separator' do
26
+ input = %w{ asdf asdf asdf}
27
+
28
+ expect(input.to_list(last_separator: ' or ')).to eq '"asdf", "asdf" or "asdf"'
29
+ end
30
+
31
+ it 'supports to change the separator' do
32
+ input = %w{ asdf asdf asdf}
33
+
34
+ expect(input.to_list(separator: ':')).to eq '"asdf":"asdf":"asdf"'
35
+ end
36
+
37
+ it 'change multiple things' do
38
+ input = %w{ asdf asdf asdf}
39
+
40
+ expect(input.to_list(around: '', separator: ':')).to eq 'asdf:asdf:asdf'
41
+ end
42
+
43
+ it 'supports to change the string to surround items' do
44
+ input = %w{ asdf asdf asdf}
45
+
46
+ expect(input.to_list(around: '$')).to eq '$asdf$, $asdf$, $asdf$'
47
+ end
48
+ end
49
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.14
4
+ version: 0.7.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer
@@ -157,7 +157,7 @@ files:
157
157
  - spec/colors/html_color_spec.rb
158
158
  - spec/command/run_command_spec.rb
159
159
  - spec/command/which_spec.rb
160
- - spec/core_ext/array/list.rb
160
+ - spec/core_ext/array/list_spec.rb
161
161
  - spec/core_ext/hash/list_spec.rb
162
162
  - spec/core_ext/hash/options_spec.rb
163
163
  - spec/core_ext/shellwords/clean_spec.rb
@@ -234,7 +234,7 @@ test_files:
234
234
  - spec/colors/html_color_spec.rb
235
235
  - spec/command/run_command_spec.rb
236
236
  - spec/command/which_spec.rb
237
- - spec/core_ext/array/list.rb
237
+ - spec/core_ext/array/list_spec.rb
238
238
  - spec/core_ext/hash/list_spec.rb
239
239
  - spec/core_ext/hash/options_spec.rb
240
240
  - spec/core_ext/shellwords/clean_spec.rb
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'fedux_org_stdlib/core_ext/array/list'
4
-
5
- RSpec.describe Array do
6
- context '#to_list' do
7
- it 'converts array to a list of values' do
8
- input = %w{ asdf asdf asdf}
9
-
10
- expect(input.to_list).to eq '"asdf", "asdf", "asdf"'
11
- end
12
- end
13
- end