fedux_org-stdlib 0.7.14 → 0.7.15
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fedux_org_stdlib/core_ext/array/list.rb +9 -2
- data/lib/fedux_org_stdlib/gem_plugins/plugin.rb +18 -4
- data/lib/fedux_org_stdlib/gem_plugins/plugin_manager.rb +2 -0
- data/lib/fedux_org_stdlib/list.rb +1 -0
- data/lib/fedux_org_stdlib/models/base_model.rb +1 -0
- data/lib/fedux_org_stdlib/rake/shell_task.rb +1 -0
- data/lib/fedux_org_stdlib/rake_tasks/documentation/yard.rb +1 -0
- data/lib/fedux_org_stdlib/support_information.rb +1 -0
- data/lib/fedux_org_stdlib/version.rb +1 -1
- data/spec/core_ext/array/list_spec.rb +49 -0
- metadata +3 -3
- data/spec/core_ext/array/list.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3620db0d8a2e9c953b9f301958a36df12ca6bf6
|
4
|
+
data.tar.gz: 32d8f81fb9168468a6dfddb5da3a60274e3f3b11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f869c2fe0adfa38bd8e471ee82c19bbdce4e69c580ac25fa0a7caa42e866cf3a61cf3351ad3c5f30c4314c740727bb325f9df357b1c60e8407fd2cd2dfb2c3e
|
7
|
+
data.tar.gz: 875b121ef2709c192360252f53973a8a64ca870a497cc655ef128aa05f5f8b3140b2b9aecff2261851c806a1e7f85d83a5d21406c366a27e59ff4a1e3cf76ca7
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
class Array
|
3
|
-
def to_list
|
4
|
-
self.map { |l| format(
|
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
|
54
|
+
require variants.shift
|
43
55
|
rescue LoadError
|
44
|
-
|
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 '#{
|
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
|
|
@@ -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.
|
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/
|
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/
|
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
|
data/spec/core_ext/array/list.rb
DELETED
@@ -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
|