claide 0.9.1 → 1.0.0.beta.1
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/.gitignore +17 -0
- data/.kick +30 -0
- data/.rubocop.yml +2 -0
- data/.rubocop_cocoapods.yml +116 -0
- data/.travis.yml +15 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +174 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +75 -0
- data/Rakefile +57 -0
- data/claide.gemspec +21 -0
- data/lib/claide.rb +1 -1
- data/lib/claide/command/plugin_manager.rb +50 -83
- metadata +16 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a888d4809588a8ca94222c78932a36cfac67940
|
4
|
+
data.tar.gz: babd101e0982e0a7f8a426b4cc39ba49a282c3b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a909e58b2f88c4fe849466a1808866dbfe85189e8ec05f3d8a6be04e4ab3a5929fdd90e1dc70b14ac19adee19b81766ca48adef3ccfc6f210f48c889c61ac4cd
|
7
|
+
data.tar.gz: ddb80f1c803f42e6940736b43236828082cd91658fa4199351534072627e84148f2b280253e93d9ca39ea68fce1503006336d923d29333ba4beee4234346f76e
|
data/.gitignore
ADDED
data/.kick
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
recipe :ruby
|
2
|
+
|
3
|
+
Kicker::Recipes::Ruby.runner_bin = 'bundle exec bacon --quiet'
|
4
|
+
|
5
|
+
process do |files|
|
6
|
+
specs = files.take_and_map do |file|
|
7
|
+
if file =~ %r{lib/[^/]*/(.+?)\.rb$}
|
8
|
+
s = Dir.glob("spec/**/#{File.basename(file, '.rb')}_spec.rb")
|
9
|
+
s.uniq unless s.empty?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
Kicker::Recipes::Ruby.run_tests(specs)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Have written this so many times, probably should make a recipe out of it.
|
16
|
+
process do |files|
|
17
|
+
files.each do |file|
|
18
|
+
case file
|
19
|
+
when 'Gemfile'
|
20
|
+
files.delete(file)
|
21
|
+
execute 'bundle install'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
recipe :ignore
|
27
|
+
ignore(/.*\/?tags/)
|
28
|
+
ignore(/.*\/?\.git/)
|
29
|
+
ignore(/^tmp/)
|
30
|
+
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
AllCops:
|
2
|
+
Include:
|
3
|
+
- ./Rakefile
|
4
|
+
- ./Gemfile
|
5
|
+
- ./*.gemspec
|
6
|
+
Exclude:
|
7
|
+
- ./spec/fixtures/**/*
|
8
|
+
|
9
|
+
# At the moment not ready to be used
|
10
|
+
# https://github.com/bbatsov/rubocop/issues/947
|
11
|
+
Documentation:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
#- CocoaPods -----------------------------------------------------------------#
|
15
|
+
|
16
|
+
# We adopted raise instead of fail.
|
17
|
+
SignalException:
|
18
|
+
EnforcedStyle: only_raise
|
19
|
+
|
20
|
+
# They are idiomatic
|
21
|
+
AssignmentInCondition:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
# Allow backticks
|
25
|
+
AsciiComments:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Indentation clarifies logic branches in implementations
|
29
|
+
IfUnlessModifier:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# No enforced convention here.
|
33
|
+
SingleLineBlockParams:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# We only add the comment when needed.
|
37
|
+
Encoding:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# Having these make it easier to *not* forget to add one when adding a new
|
41
|
+
# value and you can simply copy the previous line.
|
42
|
+
TrailingComma:
|
43
|
+
EnforcedStyleForMultiline: comma
|
44
|
+
|
45
|
+
Style/MultilineOperationIndentation:
|
46
|
+
EnforcedStyle: indented
|
47
|
+
|
48
|
+
# Clashes with CLAide Command#validate!
|
49
|
+
GuardClause:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Not always desirable: lib/claide/command/plugins_helper.rb:12:15
|
53
|
+
Next:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Arbitrary max lengths for classes simply do not work and enabling this will
|
57
|
+
# lead to a never ending stream of annoyance and changes.
|
58
|
+
Metrics/ClassLength:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
# Arbitrary max lengths for methods simply do not work and enabling this will
|
62
|
+
# lead to a never ending stream of annoyance and changes.
|
63
|
+
Metrics/MethodLength:
|
64
|
+
Enabled: false
|
65
|
+
|
66
|
+
# No enforced convention here.
|
67
|
+
Metrics/BlockNesting:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
# It will be obvious which code is complex, Rubocop should only lint simple
|
71
|
+
# rules for us.
|
72
|
+
Metrics/AbcSize:
|
73
|
+
Enabled: false
|
74
|
+
|
75
|
+
# It will be obvious which code is complex, Rubocop should only lint simple
|
76
|
+
# rules for us.
|
77
|
+
Metrics/CyclomaticComplexity:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
#- CocoaPods support for Ruby 1.8.7 ------------------------------------------#
|
81
|
+
|
82
|
+
HashSyntax:
|
83
|
+
EnforcedStyle: hash_rockets
|
84
|
+
|
85
|
+
Lambda:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
DotPosition:
|
89
|
+
EnforcedStyle: trailing
|
90
|
+
|
91
|
+
EachWithObject:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/SpecialGlobalVars:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
#- CocoaPods specs -----------------------------------------------------------#
|
98
|
+
|
99
|
+
# Allow for `should.match /regexp/`.
|
100
|
+
AmbiguousRegexpLiteral:
|
101
|
+
Exclude:
|
102
|
+
- spec/**/*
|
103
|
+
|
104
|
+
# Allow `object.should == object` syntax.
|
105
|
+
Void:
|
106
|
+
Exclude:
|
107
|
+
- spec/**/*
|
108
|
+
|
109
|
+
ClassAndModuleChildren:
|
110
|
+
Exclude:
|
111
|
+
- spec/**/*
|
112
|
+
|
113
|
+
UselessComparison:
|
114
|
+
Exclude:
|
115
|
+
- spec/**/*
|
116
|
+
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
addons:
|
3
|
+
code_climate:
|
4
|
+
repo_token: 46c8b29dd6711f35704e7c5a541486cbbf2cff8b2df8ce755bfc09917d3c1cbb
|
5
|
+
branches:
|
6
|
+
only:
|
7
|
+
- master
|
8
|
+
- /.+-stable$/
|
9
|
+
rvm:
|
10
|
+
- 1.8.7
|
11
|
+
- 1.9.3
|
12
|
+
- 2.1.1
|
13
|
+
bundler_args: --without development
|
14
|
+
script: bundle exec rake spec
|
15
|
+
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown --protected --charset=utf-8 lib
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
# CLAide Changelog
|
2
|
+
|
3
|
+
## 1.0.0.beta.1 (2015-12-30)
|
4
|
+
|
5
|
+
##### Bug Fixes
|
6
|
+
|
7
|
+
* The plugin manager will now properly activate plugin gems, ensuring all of
|
8
|
+
their files are requirable.
|
9
|
+
[Samuel Giddins](https://github.com/segiddins)
|
10
|
+
|
11
|
+
|
12
|
+
## 0.9.1 (2015-07-05)
|
13
|
+
|
14
|
+
##### Bug Fixes
|
15
|
+
|
16
|
+
* Fix a regression when contradictory flags were given in `ARGV` -- the last
|
17
|
+
flag given will once again be the value returned, and all entries for that key
|
18
|
+
are removed.
|
19
|
+
[Samuel Giddins](https://github.com/segiddins)
|
20
|
+
|
21
|
+
|
22
|
+
## 0.9.0 (2015-07-02)
|
23
|
+
|
24
|
+
##### Enhancements
|
25
|
+
|
26
|
+
* Properly parse everything in `ARGV` after `--` as an argument.
|
27
|
+
[Samuel Giddins](https://github.com/segiddins)
|
28
|
+
[#48](https://github.com/CocoaPods/CLAide/issues/48)
|
29
|
+
|
30
|
+
* Allow parsing an option that occurs multiple times.
|
31
|
+
[Samuel Giddins](https://github.com/segiddins)
|
32
|
+
|
33
|
+
|
34
|
+
## 0.8.2 (2015-06-27)
|
35
|
+
|
36
|
+
##### Enhancements
|
37
|
+
|
38
|
+
* Add `ARGV#remainder!`, which returns all the remaining arguments, deleting
|
39
|
+
them from the receiver.
|
40
|
+
[Samuel Giddins](https://github.com/segiddins)
|
41
|
+
|
42
|
+
|
43
|
+
## 0.8.1 (2015-02-25)
|
44
|
+
|
45
|
+
###### Bug Fixes
|
46
|
+
|
47
|
+
* Silence errors while loading plugins.
|
48
|
+
[Clément Beffa](https://github.com/cl3m)
|
49
|
+
[#44](https://github.com/CocoaPods/CLAide/issues/44)
|
50
|
+
|
51
|
+
|
52
|
+
## 0.8.0 (2014-12-25)
|
53
|
+
|
54
|
+
###### Breaking
|
55
|
+
|
56
|
+
* Removes the `ShellCompletionHelper` along with completion script for ZSH. This is out of the scope of CLAide.
|
57
|
+
[Eloy Durán](https://github.com/alloy)
|
58
|
+
[#43](https://github.com/CocoaPods/CLAide/issues/43)
|
59
|
+
|
60
|
+
* Various refactoring replacing “Helper” API’s which specialised classes such as ArgumentSuggester, TextWrapper and PluginManager.
|
61
|
+
[Eloy Durán](https://github.com/alloy)
|
62
|
+
|
63
|
+
###### Enhancements
|
64
|
+
|
65
|
+
* Added convenience method to invoke commands more easily.
|
66
|
+
[Olivier Halligon](https://github.com/AliSoftware)
|
67
|
+
[#33](https://github.com/CocoaPods/CLAide/issues/40)
|
68
|
+
|
69
|
+
* Changes to the PluginManager to handle multiple plugin prefixes, which by default adds the `clad` plugin prefix.
|
70
|
+
[Eloy Durán](https://github.com/alloy)
|
71
|
+
|
72
|
+
## 0.7.0 (2014-09-11)
|
73
|
+
|
74
|
+
###### Breaking
|
75
|
+
|
76
|
+
* Plugins are now expected to include the `cocoapods-plugin.rb` file in
|
77
|
+
`./lib`.
|
78
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
79
|
+
[#28](https://github.com/CocoaPods/CLAide/pull/28)
|
80
|
+
|
81
|
+
###### Enhancements
|
82
|
+
|
83
|
+
* Improved messages for exceptions generated by plugins.
|
84
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
85
|
+
[#28](https://github.com/CocoaPods/CLAide/pull/28)
|
86
|
+
|
87
|
+
* Use the Argument class to describe arguments.
|
88
|
+
[Olivier Halligon](https://github.com/AliSoftware)
|
89
|
+
[#33](https://github.com/CocoaPods/CLAide/issues/33)
|
90
|
+
|
91
|
+
* Support for argument alternatives and repeatable arguments (ellipsis).
|
92
|
+
[Olivier Halligon](https://github.com/AliSoftware)
|
93
|
+
[#33](https://github.com/CocoaPods/CLAide/issues/33)
|
94
|
+
|
95
|
+
* No stack trace if --help and --vebose are combined.
|
96
|
+
[Marius Rackwitz](https://github.com/mrackwitz)
|
97
|
+
[#36](https://github.com/CocoaPods/CLAide/issues/36)
|
98
|
+
|
99
|
+
|
100
|
+
## 0.6.1 (2014-05-20)
|
101
|
+
|
102
|
+
###### Bug Fixes
|
103
|
+
|
104
|
+
* Respect the ANSI flag for the help banner.
|
105
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
106
|
+
[#34](https://github.com/CocoaPods/CLAide/issues/34)
|
107
|
+
|
108
|
+
* Underline the colon of the titles of the help banner.
|
109
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
110
|
+
|
111
|
+
## 0.6.0 (2014-05-19)
|
112
|
+
|
113
|
+
###### Enhancements
|
114
|
+
|
115
|
+
* Use an array to describe arguments.
|
116
|
+
[Fabio Pelosin][fabiopelosin]
|
117
|
+
[#26](https://github.com/CocoaPods/CLAide/issues/26)
|
118
|
+
|
119
|
+
* Improved layout and contents of help banner
|
120
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
121
|
+
[#25](https://github.com/CocoaPods/CLAide/pull/25)
|
122
|
+
|
123
|
+
* Colorize option, arguments, and example commands in the help banner.
|
124
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
125
|
+
[#12](https://github.com/CocoaPods/CLAide/issues/12)
|
126
|
+
|
127
|
+
* Add support for ANSI escape sequences.
|
128
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
129
|
+
[#17](https://github.com/CocoaPods/CLAide/issues/17)
|
130
|
+
[#20](https://github.com/CocoaPods/CLAide/pull/20)
|
131
|
+
[#24](https://github.com/CocoaPods/CLAide/pull/24)
|
132
|
+
|
133
|
+
* Add support for completion script
|
134
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
135
|
+
[#19](https://github.com/CocoaPods/CLAide/pull/19)
|
136
|
+
|
137
|
+
* Add support for version logic via the introduction of the `version` class
|
138
|
+
attribute to the `CLAide::Commmand` class. If a value for the attribute is
|
139
|
+
specified the `--version` flag is added. The `--version --verbose` flags
|
140
|
+
include the version of the plugins in the output.
|
141
|
+
[Fabio Pelosin](https://github.com/fabiopelosin)
|
142
|
+
[#13](https://github.com/CocoaPods/CLAide/issues/13)
|
143
|
+
[#14](https://github.com/CocoaPods/CLAide/issues/14)
|
144
|
+
|
145
|
+
## 0.5.0 (2014-03-26)
|
146
|
+
|
147
|
+
###### Enhancements
|
148
|
+
|
149
|
+
* Add a `ignore_in_command_lookup` option to commands, which makes it possible
|
150
|
+
to have anonymous command classes that are or only meant to provide common
|
151
|
+
functionality, but are otherwise completely ignored during parsing, command
|
152
|
+
lookup, and help banner printing.
|
153
|
+
[Eloy Durán](https://github.com/alloy)
|
154
|
+
|
155
|
+
* Deprecate the `color` option in favor of `ansi`. This is more abstract and
|
156
|
+
can be used for commands that only prettify output by using, for instance,
|
157
|
+
the bold ANSI code. This applies to the `CLAide` APIs as well.
|
158
|
+
[Eloy Durán](https://github.com/alloy)
|
159
|
+
|
160
|
+
* Add more hooks that allow the user to customize how to prettify output.
|
161
|
+
[Eloy Durán](https://github.com/alloy)
|
162
|
+
|
163
|
+
* Word wrap option descriptions to terminal width.
|
164
|
+
[Eloy Durán](https://github.com/alloy)
|
165
|
+
[#6](https://github.com/CocoaPods/CLAide/issues/6)
|
166
|
+
|
167
|
+
|
168
|
+
## 0.4.0 (2013-11-14)
|
169
|
+
|
170
|
+
###### Enhancements
|
171
|
+
|
172
|
+
* Added support for plugins.
|
173
|
+
[Les Hill](https://github.com/leshill)
|
174
|
+
[#1](https://github.com/CocoaPods/CLAide/pull/1)
|
data/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'rake'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'kicker'
|
9
|
+
gem 'colored' # for examples
|
10
|
+
end
|
11
|
+
|
12
|
+
group :spec do
|
13
|
+
gem 'bacon'
|
14
|
+
gem 'json'
|
15
|
+
gem 'mocha-on-bacon'
|
16
|
+
gem 'prettybacon'
|
17
|
+
|
18
|
+
if RUBY_VERSION >= '1.9.3'
|
19
|
+
gem 'rubocop'
|
20
|
+
gem 'codeclimate-test-reporter', :require => nil
|
21
|
+
gem 'simplecov'
|
22
|
+
end
|
23
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
claide (1.0.0.beta.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.0.0)
|
10
|
+
astrolabe (1.3.0)
|
11
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
12
|
+
bacon (1.2.0)
|
13
|
+
codeclimate-test-reporter (0.4.1)
|
14
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
15
|
+
colored (1.2)
|
16
|
+
docile (1.1.5)
|
17
|
+
ffi (1.9.6)
|
18
|
+
json (1.8.3)
|
19
|
+
kicker (3.0.0)
|
20
|
+
listen (~> 1.3.0)
|
21
|
+
notify (~> 0.5.2)
|
22
|
+
listen (1.3.1)
|
23
|
+
rb-fsevent (>= 0.9.3)
|
24
|
+
rb-inotify (>= 0.9)
|
25
|
+
rb-kqueue (>= 0.2)
|
26
|
+
metaclass (0.0.4)
|
27
|
+
mocha (1.1.0)
|
28
|
+
metaclass (~> 0.0.1)
|
29
|
+
mocha-on-bacon (0.2.2)
|
30
|
+
mocha (>= 0.13.0)
|
31
|
+
multi_json (1.10.1)
|
32
|
+
notify (0.5.2)
|
33
|
+
parser (2.2.0.3)
|
34
|
+
ast (>= 1.1, < 3.0)
|
35
|
+
powerpack (0.1.0)
|
36
|
+
prettybacon (0.0.2)
|
37
|
+
bacon (~> 1.2)
|
38
|
+
rainbow (2.0.0)
|
39
|
+
rake (10.3.2)
|
40
|
+
rb-fsevent (0.9.4)
|
41
|
+
rb-inotify (0.9.5)
|
42
|
+
ffi (>= 0.5.0)
|
43
|
+
rb-kqueue (0.2.3)
|
44
|
+
ffi (>= 0.5.0)
|
45
|
+
rubocop (0.29.1)
|
46
|
+
astrolabe (~> 1.3)
|
47
|
+
parser (>= 2.2.0.1, < 3.0)
|
48
|
+
powerpack (~> 0.1)
|
49
|
+
rainbow (>= 1.99.1, < 3.0)
|
50
|
+
ruby-progressbar (~> 1.4)
|
51
|
+
ruby-progressbar (1.7.1)
|
52
|
+
simplecov (0.9.1)
|
53
|
+
docile (~> 1.1.0)
|
54
|
+
multi_json (~> 1.0)
|
55
|
+
simplecov-html (~> 0.8.0)
|
56
|
+
simplecov-html (0.8.0)
|
57
|
+
|
58
|
+
PLATFORMS
|
59
|
+
ruby
|
60
|
+
|
61
|
+
DEPENDENCIES
|
62
|
+
bacon
|
63
|
+
claide!
|
64
|
+
codeclimate-test-reporter
|
65
|
+
colored
|
66
|
+
json
|
67
|
+
kicker
|
68
|
+
mocha-on-bacon
|
69
|
+
prettybacon
|
70
|
+
rake
|
71
|
+
rubocop
|
72
|
+
simplecov
|
73
|
+
|
74
|
+
BUNDLED WITH
|
75
|
+
1.11.2
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
#-- Bootstrap --------------------------------------------------------------#
|
4
|
+
|
5
|
+
desc 'Initializes your working copy to run the specs'
|
6
|
+
task :bootstrap do
|
7
|
+
if system('which bundle')
|
8
|
+
title 'Installing gems'
|
9
|
+
sh 'bundle install'
|
10
|
+
else
|
11
|
+
$stderr.puts "\033[0;31m" \
|
12
|
+
"[!] Please install the bundler gem manually:\n" \
|
13
|
+
' $ [sudo] gem install bundler' \
|
14
|
+
"\e[0m"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
require 'bundler/gem_tasks'
|
21
|
+
task :default => :spec
|
22
|
+
|
23
|
+
#-- Specs ------------------------------------------------------------------#
|
24
|
+
|
25
|
+
desc 'Run specs'
|
26
|
+
task :spec do
|
27
|
+
title 'Running Unit Tests'
|
28
|
+
files = FileList['spec/**/*_spec.rb'].shuffle.join(' ')
|
29
|
+
sh "bundle exec bacon #{files}"
|
30
|
+
|
31
|
+
Rake::Task['rubocop'].invoke if RUBY_VERSION >= '1.9.3'
|
32
|
+
end
|
33
|
+
|
34
|
+
#-- Rubocop ----------------------------------------------------------------#
|
35
|
+
|
36
|
+
desc 'Check code against RuboCop rules'
|
37
|
+
task :rubocop do
|
38
|
+
sh 'bundle exec rubocop'
|
39
|
+
end
|
40
|
+
|
41
|
+
rescue LoadError
|
42
|
+
$stderr.puts "\033[0;31m" \
|
43
|
+
'[!] Some Rake tasks haven been disabled because the environment' \
|
44
|
+
' couldn’t be loaded. Be sure to run `rake bootstrap` first.' \
|
45
|
+
"\e[0m"
|
46
|
+
end
|
47
|
+
|
48
|
+
#-- Helpers ------------------------------------------------------------------#
|
49
|
+
|
50
|
+
def title(title)
|
51
|
+
cyan_title = "\033[0;36m#{title}\033[0m"
|
52
|
+
puts
|
53
|
+
puts '-' * 80
|
54
|
+
puts cyan_title
|
55
|
+
puts '-' * 80
|
56
|
+
puts
|
57
|
+
end
|
data/claide.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'claide'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "claide"
|
7
|
+
s.version = CLAide::VERSION
|
8
|
+
s.license = "MIT"
|
9
|
+
s.email = ["eloy.de.enige@gmail.com", "fabiopelosin@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/CocoaPods/CLAide"
|
11
|
+
s.authors = ["Eloy Duran", "Fabio Pelosin"]
|
12
|
+
|
13
|
+
s.summary = "A small command-line interface framework."
|
14
|
+
|
15
|
+
s.files = `git ls-files -z`.split("\0").reject { |f| f =~ /\A(spec|examples)/i }
|
16
|
+
|
17
|
+
## Make sure you can build the gem on older versions of RubyGems too:
|
18
|
+
s.rubygems_version = "1.6.2"
|
19
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
20
|
+
s.specification_version = 3 if s.respond_to? :specification_version
|
21
|
+
end
|
data/lib/claide.rb
CHANGED
@@ -13,55 +13,38 @@ module CLAide
|
|
13
13
|
# - Be stored in a folder named after the plugin.
|
14
14
|
#
|
15
15
|
class PluginManager
|
16
|
-
# @return [
|
17
|
-
#
|
16
|
+
# @return [Hash<String,Gem::Specification>] The loaded plugins,
|
17
|
+
# grouped by plugin prefix.
|
18
18
|
#
|
19
|
-
def self.
|
20
|
-
@
|
19
|
+
def self.loaded_plugins
|
20
|
+
@loaded_plugins ||= {}
|
21
21
|
end
|
22
22
|
|
23
|
-
# @return [Array<
|
24
|
-
# named after the `PLUGIN_PREFIX_plugin` and returns the
|
25
|
-
# the gems loaded successfully.
|
23
|
+
# @return [Array<Gem::Specification>] Loads plugins via RubyGems looking
|
24
|
+
# for files named after the `PLUGIN_PREFIX_plugin` and returns the
|
25
|
+
# specifications of the gems loaded successfully.
|
26
|
+
# Plugins are required safely.
|
26
27
|
#
|
27
28
|
def self.load_plugins(plugin_prefix)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if safe_require(path.to_s)
|
33
|
-
loaded_paths << Pathname(path + './../../').cleanpath
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
plugin_paths[plugin_prefix] = loaded_paths
|
29
|
+
loaded_plugins[plugin_prefix] ||=
|
30
|
+
plugin_gems_for_prefix(plugin_prefix).map do |spec, paths|
|
31
|
+
spec if safe_activate_and_require(spec, paths)
|
32
|
+
end.compact
|
38
33
|
end
|
39
34
|
|
40
35
|
# @return [Array<Specification>] The RubyGems specifications for the
|
41
36
|
# loaded plugins.
|
42
37
|
#
|
43
38
|
def self.specifications
|
44
|
-
|
45
|
-
specification(path)
|
46
|
-
end.compact
|
39
|
+
loaded_plugins.values.flatten.uniq
|
47
40
|
end
|
48
41
|
|
49
|
-
# @return [Specification] The RubyGems
|
50
|
-
# given
|
51
|
-
#
|
52
|
-
# @param [#to_s] path
|
53
|
-
# The root path of the plugin.
|
42
|
+
# @return [Array<Specification>] The RubyGems specifications for the
|
43
|
+
# installed plugins that match the given `plugin_prefix`.
|
54
44
|
#
|
55
|
-
def self.
|
56
|
-
|
57
|
-
|
58
|
-
Gem::Specification.load(matches.first)
|
59
|
-
end if matches.count == 1
|
60
|
-
unless spec
|
61
|
-
warn '[!] Unable to load a specification for the plugin ' \
|
62
|
-
"`#{path}`".ansi.yellow
|
63
|
-
end
|
64
|
-
spec
|
45
|
+
def self.installed_specifications_for_prefix(plugin_prefix)
|
46
|
+
loaded_plugins[plugin_prefix] ||
|
47
|
+
plugin_gems_for_prefix(plugin_prefix).map(&:first)
|
65
48
|
end
|
66
49
|
|
67
50
|
# @return [Array<String>] The list of the plugins whose root path appears
|
@@ -71,72 +54,56 @@ module CLAide
|
|
71
54
|
# The exception to analyze.
|
72
55
|
#
|
73
56
|
def self.plugins_involved_in_exception(exception)
|
74
|
-
|
75
|
-
exception.backtrace.any?
|
76
|
-
|
77
|
-
|
57
|
+
specifications.select do |gemspec|
|
58
|
+
exception.backtrace.any? do |line|
|
59
|
+
gemspec.full_require_paths.any? do |plugin_path|
|
60
|
+
line.include?(plugin_path)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end.map(&:name)
|
78
64
|
end
|
79
65
|
|
80
|
-
#
|
81
|
-
|
82
|
-
#
|
83
|
-
#
|
66
|
+
# @group Helper Methods
|
67
|
+
|
68
|
+
# @return [Array<[Gem::Specification, Array<String>]>]
|
69
|
+
# Returns an array of tuples containing the specifications and
|
70
|
+
# plugin files to require for a given plugin prefix.
|
84
71
|
#
|
85
|
-
def self.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
Gem.find_files(pattern)
|
92
|
-
end
|
93
|
-
else
|
94
|
-
[]
|
95
|
-
end
|
72
|
+
def self.plugin_gems_for_prefix(prefix)
|
73
|
+
glob = "#{prefix}_plugin#{Gem.suffix_pattern}"
|
74
|
+
Gem::Specification.latest_specs(true).map do |spec|
|
75
|
+
matches = spec.matches_for_glob(glob)
|
76
|
+
[spec, matches] unless matches.empty?
|
77
|
+
end.compact
|
96
78
|
end
|
97
79
|
|
98
|
-
#
|
80
|
+
# Activates the given spec and requires the given paths.
|
81
|
+
# If any exception occurs it is caught and an
|
99
82
|
# informative message is printed.
|
100
83
|
#
|
101
|
-
# @param [
|
102
|
-
# The
|
84
|
+
# @param [Gem::Specification] spec
|
85
|
+
# The spec to be activated.
|
86
|
+
#
|
87
|
+
# @param [String] paths
|
88
|
+
# The paths to require.
|
89
|
+
#
|
90
|
+
# @return [Bool] Whether activation and requiring succeeded.
|
103
91
|
#
|
104
92
|
# rubocop:disable RescueException
|
105
|
-
def self.
|
106
|
-
|
93
|
+
def self.safe_activate_and_require(spec, paths)
|
94
|
+
spec.activate
|
95
|
+
paths.each { |path| require(path) }
|
107
96
|
true
|
108
97
|
rescue Exception => exception
|
109
98
|
message = "\n---------------------------------------------"
|
110
|
-
message << "\nError loading the plugin
|
99
|
+
message << "\nError loading the plugin `#{spec.full_name}`.\n"
|
111
100
|
message << "\n#{exception.class} - #{exception.message}"
|
112
101
|
message << "\n#{exception.backtrace.join("\n")}"
|
113
102
|
message << "\n---------------------------------------------\n"
|
114
|
-
|
103
|
+
warn message.ansi.yellow
|
115
104
|
false
|
116
105
|
end
|
117
106
|
# rubocop:enable RescueException
|
118
|
-
|
119
|
-
# Executes the given block while silencing the given streams.
|
120
|
-
#
|
121
|
-
# @return [Object] The value of the given block.
|
122
|
-
#
|
123
|
-
# @param [Array] streams
|
124
|
-
# The streams to silence.
|
125
|
-
#
|
126
|
-
# @note credit to DHH http://stackoverflow.com/a/8959520
|
127
|
-
#
|
128
|
-
def self.silence_streams(*streams)
|
129
|
-
on_hold = streams.map(&:dup)
|
130
|
-
streams.each do |stream|
|
131
|
-
stream.reopen('/dev/null')
|
132
|
-
stream.sync = true
|
133
|
-
end
|
134
|
-
yield
|
135
|
-
ensure
|
136
|
-
streams.each_with_index do |stream, i|
|
137
|
-
stream.reopen(on_hold[i])
|
138
|
-
end
|
139
|
-
end
|
140
107
|
end
|
141
108
|
end
|
142
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: claide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Duran
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -19,8 +19,19 @@ executables: []
|
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
|
+
- .gitignore
|
23
|
+
- .kick
|
24
|
+
- .rubocop.yml
|
25
|
+
- .rubocop_cocoapods.yml
|
26
|
+
- .travis.yml
|
27
|
+
- .yardopts
|
28
|
+
- CHANGELOG.md
|
29
|
+
- Gemfile
|
30
|
+
- Gemfile.lock
|
22
31
|
- LICENSE
|
23
32
|
- README.markdown
|
33
|
+
- Rakefile
|
34
|
+
- claide.gemspec
|
24
35
|
- lib/claide.rb
|
25
36
|
- lib/claide/ansi.rb
|
26
37
|
- lib/claide/ansi/cursor.rb
|
@@ -44,17 +55,17 @@ require_paths:
|
|
44
55
|
- lib
|
45
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
57
|
requirements:
|
47
|
-
- -
|
58
|
+
- - '>='
|
48
59
|
- !ruby/object:Gem::Version
|
49
60
|
version: '0'
|
50
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
62
|
requirements:
|
52
|
-
- -
|
63
|
+
- - '>='
|
53
64
|
- !ruby/object:Gem::Version
|
54
65
|
version: '0'
|
55
66
|
requirements: []
|
56
67
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.5.1
|
58
69
|
signing_key:
|
59
70
|
specification_version: 3
|
60
71
|
summary: A small command-line interface framework.
|