raygun 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +99 -0
- data/.ruby-version +1 -1
- data/CHANGES.md +38 -0
- data/Gemfile +1 -1
- data/README.md +81 -39
- data/Rakefile +9 -1
- data/bin/raygun +2 -2
- data/bin/setup +6 -0
- data/lib/colorize.rb +55 -55
- data/lib/raygun/raygun.rb +159 -148
- data/lib/raygun/template_repo.rb +78 -0
- data/lib/raygun/version.rb +1 -1
- data/raygun.gemspec +13 -8
- data/spec/raygun/raygun.rb +3 -0
- data/spec/raygun/runner_spec.rb +27 -0
- data/spec/spec_helper.rb +1 -0
- metadata +76 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c7ca3630bd95d0e0c12a7bf9d9f6b5cc0255ba5dfced51c83017a164f84ff147
|
4
|
+
data.tar.gz: 06ba32e033ec46d2ebe15f4e03c781b91ba94ac912075e9c1fff6872b68a5489
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24416fbf00a23e6cb6b9afaf3c9ac3184bf1e99127c97a0f3db58d09364625e3f4ca5145e5801a039e4f878fa7b5e5952235866a792bfb462ec3b19c145a98ec
|
7
|
+
data.tar.gz: 496bcae1bc8c9bdaa1ed4975c9794c916a2187dfe76d1fb2df7fde190431f05c8a25cad2ed7b226898afc3d8a7249c02ee0ecdf6d2046e0633f806b74ba3e8b4
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
DisplayCopNames: true
|
4
|
+
DisplayStyleGuide: true
|
5
|
+
|
6
|
+
#
|
7
|
+
# Ruby Cops
|
8
|
+
#
|
9
|
+
|
10
|
+
Layout/CaseIndentation:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Layout/FirstArrayElementIndentation:
|
14
|
+
EnforcedStyle: consistent
|
15
|
+
|
16
|
+
Layout/HashAlignment:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Layout/LineLength:
|
20
|
+
Max: 120
|
21
|
+
|
22
|
+
Layout/MultilineMethodCallIndentation:
|
23
|
+
EnforcedStyle: indented
|
24
|
+
|
25
|
+
Lint/AmbiguousBlockAssociation:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Lint/ScriptPermission:
|
29
|
+
Exclude:
|
30
|
+
- "Rakefile"
|
31
|
+
|
32
|
+
Metrics/AbcSize:
|
33
|
+
Max: 35
|
34
|
+
Exclude:
|
35
|
+
- "spec/**/*"
|
36
|
+
|
37
|
+
Metrics/BlockLength:
|
38
|
+
CountComments: false
|
39
|
+
Max: 50
|
40
|
+
Exclude:
|
41
|
+
- "config/**/*"
|
42
|
+
- "spec/**/*"
|
43
|
+
|
44
|
+
Metrics/ClassLength:
|
45
|
+
Max: 250
|
46
|
+
Exclude:
|
47
|
+
- "spec/**/*"
|
48
|
+
|
49
|
+
Metrics/MethodLength:
|
50
|
+
Max: 25
|
51
|
+
Exclude:
|
52
|
+
- "db/migrate/*"
|
53
|
+
- "spec/**/*"
|
54
|
+
|
55
|
+
Naming/PredicateName:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Security/YAMLLoad:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
Style/BarePercentLiterals:
|
62
|
+
EnforcedStyle: percent_q
|
63
|
+
|
64
|
+
Style/BlockDelimiters:
|
65
|
+
EnforcedStyle: braces_for_chaining
|
66
|
+
|
67
|
+
Style/Documentation:
|
68
|
+
Enabled: false
|
69
|
+
|
70
|
+
Style/EmptyMethod:
|
71
|
+
EnforcedStyle: expanded
|
72
|
+
|
73
|
+
Style/FrozenStringLiteralComment:
|
74
|
+
EnforcedStyle: never
|
75
|
+
|
76
|
+
Style/Lambda:
|
77
|
+
EnforcedStyle: literal
|
78
|
+
|
79
|
+
Style/ModuleFunction:
|
80
|
+
EnforcedStyle: extend_self
|
81
|
+
|
82
|
+
Style/MutableConstant:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/PreferredHashMethods:
|
86
|
+
Enabled: false
|
87
|
+
|
88
|
+
Style/SpecialGlobalVars:
|
89
|
+
Enabled: false
|
90
|
+
|
91
|
+
Style/StringLiterals:
|
92
|
+
EnforcedStyle: double_quotes
|
93
|
+
|
94
|
+
Style/StringLiteralsInInterpolation:
|
95
|
+
EnforcedStyle: double_quotes
|
96
|
+
|
97
|
+
Style/StructInheritance:
|
98
|
+
Enabled: true
|
99
|
+
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.5
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,43 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
**Note:** Don't let the apparent lack of activity here scare you away. Almost all changes are captured in the
|
4
|
+
prototype repo (see [raygun-rails](https://github.com/carbonfive/raygun-rails)), and it's kept pretty well up to date.
|
5
|
+
|
6
|
+
## 1.1.0 [2020-07-02]
|
7
|
+
|
8
|
+
Breaking:
|
9
|
+
|
10
|
+
* Require Ruby 2.4+ (#151)
|
11
|
+
|
12
|
+
New features:
|
13
|
+
|
14
|
+
* Copy `.rubocop.yml` template instead of using a fragile link to the c5-conventions repo (#148)
|
15
|
+
* Initialize zapped projects with a default branch of "main" (#157)
|
16
|
+
|
17
|
+
Docs:
|
18
|
+
|
19
|
+
* Add Bootstrap instructions to the README (it has been removed from the app prototype) (#141)
|
20
|
+
|
21
|
+
Housekeeping:
|
22
|
+
|
23
|
+
* Add bundler and rake development dependencies (#143)
|
24
|
+
* Upgrade to Ruby 2.6.5 (#142)
|
25
|
+
|
26
|
+
## 1.0.4 [2017-11-28]
|
27
|
+
|
28
|
+
* Tweak instructions: use `heroku local` instead of `foreman s` (#138, thanks @mattbrictson)
|
29
|
+
|
30
|
+
## 1.0.3 [2017-10-25]
|
31
|
+
|
32
|
+
* Add ability to pull template repository by branch name (#137, thanks @bunnymatic!).
|
33
|
+
* Updates to the README (mostly tweaks).
|
34
|
+
* Use Ruby 2.4.2 for development.
|
35
|
+
|
36
|
+
## 1.0.1 [2015-01-30]
|
37
|
+
|
38
|
+
* Simplify instructions: use ./bin/setup instead of explicit commands.
|
39
|
+
* Use ruby 2.2.0 for development.
|
40
|
+
|
3
41
|
## 1.0.0 [2014-07-01]
|
4
42
|
|
5
43
|
* 1.0 Release, because it's about time.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/raygun.
|
2
|
-
<img src="https://raw.github.com/carbonfive/raygun/
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/raygun.svg)](http://badge.fury.io/rb/raygun)
|
2
|
+
<img src="https://raw.github.com/carbonfive/raygun/main/marvin.jpg" align="right"/>
|
3
3
|
|
4
4
|
# Raygun
|
5
5
|
|
6
6
|
Rails application generator that builds a new project skeleton configured with Carbon Five preferences and
|
7
7
|
best practices baked right in. Spend less time configuring and more building cool features.
|
8
8
|
|
9
|
-
Raygun generates Rails
|
9
|
+
Raygun generates Rails projects by copying this [sample app](https://github.com/carbonfive/raygun-rails)
|
10
10
|
and massaging it gently into shape.
|
11
11
|
|
12
12
|
Alternatively, Raygun allows you to specify your own prototype instead of the default sample app. See below
|
@@ -18,17 +18,15 @@ Major tools/libraries:
|
|
18
18
|
* PostgreSQL
|
19
19
|
* Slim
|
20
20
|
* Sass
|
21
|
-
*
|
22
|
-
*
|
23
|
-
* Factory Girl
|
24
|
-
* Jasmine
|
21
|
+
* RSpec and Capybara
|
22
|
+
* Factory Bot
|
25
23
|
* SimpleCov
|
26
|
-
* Guard (rspec,
|
27
|
-
* And many tweaks, patterns and common recipes (see [raygun-rails](https://github.com/carbonfive/raygun-rails) for all
|
24
|
+
* Guard (rspec, livereload)
|
25
|
+
* And many tweaks, patterns and common recipes (see [raygun-rails](https://github.com/carbonfive/raygun-rails) for all
|
26
|
+
the details).
|
28
27
|
|
29
28
|
Raygun includes generator templates for controllers, views, and specs so that generated code follows best
|
30
|
-
practices. For example,
|
31
|
-
girl when appropriate.
|
29
|
+
practices. For example, rspec specs use factory bot when appropriate.
|
32
30
|
|
33
31
|
Inspired by Xavier Shay work at Square and ThoughtBot's Suspenders. Thanks!
|
34
32
|
|
@@ -47,61 +45,97 @@ Raygun...
|
|
47
45
|
|
48
46
|
## Prerequisites
|
49
47
|
|
50
|
-
To generate an application, you only need the
|
48
|
+
To generate an application, you only need the Raygun gem and network connectivity.
|
51
49
|
|
52
50
|
To run your new application's specs or fire up its server, you'll need to meet these requirements.
|
53
51
|
|
54
|
-
* PostgreSQL 9.x with superuser 'postgres' with no password (
|
55
|
-
* PhantomJS for JavaScript testing (
|
52
|
+
* PostgreSQL 9.x with superuser 'postgres' with no password (`createuser -s postgres`)
|
53
|
+
* PhantomJS for JavaScript testing (`brew install phantomjs`)
|
56
54
|
|
57
|
-
The generated app will be configured to use the ruby version that was used to invoke
|
58
|
-
another ruby, just change the
|
55
|
+
The generated app will be configured to use the ruby version that was used to invoke Raygun. If you're using
|
56
|
+
another ruby, just change the `Gemfile` and `.ruby-version` as necessary.
|
59
57
|
|
60
58
|
## Usage
|
61
59
|
|
62
|
-
|
60
|
+
```bash
|
61
|
+
$ raygun your-project
|
62
|
+
```
|
63
63
|
|
64
|
-
Once your project is baked out, you can easily kick the wheels. Be sure that you have the
|
64
|
+
Once your project is baked out, you can easily kick the wheels. Be sure that you have the prerequisites
|
65
65
|
covered (see above).
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
```bash
|
68
|
+
$ cd your-project
|
69
|
+
$ bin/setup
|
70
70
|
|
71
|
-
|
72
|
-
|
71
|
+
# Run the specs, they should all pass
|
72
|
+
$ bin/rake
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
# Fire up the app and open it in a browser
|
75
|
+
$ heroku local
|
76
|
+
$ open http://localhost:3000
|
77
|
+
```
|
78
|
+
|
79
|
+
## Next Steps
|
80
|
+
|
81
|
+
As you'll notice, the project comes with enough CSS (SCSS, actually) to establish some patterns. If you
|
82
|
+
need more of a framework, here are instructions on how to add Bootstrap to your new project.
|
83
|
+
|
84
|
+
```bash
|
85
|
+
$ yarn add bootstrap
|
86
|
+
$ rails generate simple_form:install --bootstrap
|
87
|
+
|
88
|
+
# Answer Yes to the question about overwriting your existing `config/initializers/simple_form.rb`
|
89
|
+
```
|
90
|
+
|
91
|
+
This generates an initializer and scaffold files for Rails view scaffolding.
|
92
|
+
|
93
|
+
Add Bootstrap imports to the top your `application.scss`
|
94
|
+
|
95
|
+
```css
|
96
|
+
// application.scss
|
97
|
+
@import "~bootstrap/scss/_functions";
|
98
|
+
@import "~bootstrap/scss/_variables";
|
99
|
+
|
100
|
+
...
|
101
|
+
```
|
102
|
+
|
103
|
+
Now you've got Bootstrap in the application.
|
104
|
+
|
105
|
+
We include `simple_form` in the project by default. For more information about using Bootstrap styling
|
106
|
+
on `simple_form` forms, check out the documentation here http://simple-form-bootstrap.plataformatec.com.br/documentation
|
76
107
|
|
77
|
-
# Fire up the app and open it in a browser
|
78
|
-
$ foreman start
|
79
|
-
$ open http://localhost:3000
|
80
108
|
|
81
109
|
## Using a Custom Project Template
|
82
110
|
|
83
111
|
The default is to use the project at [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails) as a
|
84
|
-
starting point. You can use another repo as the project template with the
|
112
|
+
starting point. You can use another repo as the project template with the `-p` command line option.
|
85
113
|
|
86
|
-
If you invoke raygun with the
|
114
|
+
If you invoke raygun with the `-p` option, you can specify your own github repository.
|
87
115
|
|
88
116
|
$ raygun -p githubid/repo your-project
|
89
117
|
|
118
|
+
Or
|
119
|
+
|
120
|
+
$ raygun -p githubid/repo your-project#new-branch-name
|
121
|
+
|
90
122
|
The repository must:
|
91
123
|
|
92
|
-
|
93
|
-
|
124
|
+
Not have any binary files. Raygun runs a 'sed' command on all files, which will fail on binaries, such as jar files.
|
125
|
+
|
126
|
+
If you are not planning to pull the prototype repository by branch, it must also have a tag. Raygun will choose the
|
127
|
+
"greatest" tag and downloads the repository as of that tag.
|
94
128
|
|
95
|
-
If your project template requires a minimum version of
|
96
|
-
|
129
|
+
If your project template requires a minimum version of Raygun, include the version in a file called
|
130
|
+
`.raygun-version` at the root. Raygun will make sure it's new enough for your repo.
|
97
131
|
|
98
132
|
## Internal Mechanics
|
99
133
|
|
100
134
|
Raygun fetches the greatest tag from the [carbonfive/raygun-rails](https://github.com/carbonfive/raygun-rails)
|
101
|
-
repo, unless it already has it cached in
|
135
|
+
repo, unless it already has it cached in `~/.raygun`, extracts the contents of the tarball, and runs a series of
|
102
136
|
search-and-replaces on the code to customize it accordingly.
|
103
137
|
|
104
|
-
This approach is fast, simple, and makes
|
138
|
+
This approach is fast, simple, and makes developmentn on Raygun very easy: make changes to the application
|
105
139
|
prototype (which is a valid rails app) and tag them when they should be used for new applications.
|
106
140
|
|
107
141
|
## Contributing
|
@@ -114,10 +148,18 @@ prototype (which is a valid rails app) and tag them when they should be used for
|
|
114
148
|
|
115
149
|
### Development
|
116
150
|
|
117
|
-
|
151
|
+
To set up your local environment, run:
|
152
|
+
|
153
|
+
$ bin/setup
|
154
|
+
|
155
|
+
To run tests and rubocop checks:
|
156
|
+
|
157
|
+
$ bundle exec rake
|
158
|
+
|
159
|
+
To generate an example app using your local development version of Raygun:
|
118
160
|
|
119
|
-
$
|
161
|
+
$ bin/raygun tmp/example_app
|
120
162
|
|
121
163
|
## Changes
|
122
164
|
|
123
|
-
[View the Change Log](https://github.com/carbonfive/raygun/tree/
|
165
|
+
[View the Change Log](https://github.com/carbonfive/raygun/tree/main/CHANGES.md)
|
data/Rakefile
CHANGED
data/bin/raygun
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
File.expand_path(
|
3
|
+
File.expand_path("../lib", __dir__).tap do |lib|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
end
|
6
6
|
|
7
|
-
require
|
7
|
+
require "raygun/raygun"
|
8
8
|
|
9
9
|
raygun = Raygun::Runner.parse(ARGV)
|
10
10
|
|
data/bin/setup
ADDED
data/lib/colorize.rb
CHANGED
@@ -5,41 +5,40 @@
|
|
5
5
|
# want to add a gem dependency.
|
6
6
|
|
7
7
|
class String
|
8
|
-
|
9
8
|
#
|
10
9
|
# Colors Hash
|
11
10
|
#
|
12
11
|
COLORS = {
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
12
|
+
black: 0,
|
13
|
+
red: 1,
|
14
|
+
green: 2,
|
15
|
+
yellow: 3,
|
16
|
+
blue: 4,
|
17
|
+
magenta: 5,
|
18
|
+
cyan: 6,
|
19
|
+
white: 7,
|
20
|
+
default: 9,
|
21
|
+
|
22
|
+
light_black: 10,
|
23
|
+
light_red: 11,
|
24
|
+
light_green: 12,
|
25
|
+
light_yellow: 13,
|
26
|
+
light_blue: 14,
|
27
|
+
light_magenta: 15,
|
28
|
+
light_cyan: 16,
|
29
|
+
light_white: 17
|
31
30
|
}
|
32
31
|
|
33
32
|
#
|
34
33
|
# Modes Hash
|
35
34
|
#
|
36
35
|
MODES = {
|
37
|
-
:
|
36
|
+
default: 0, # Turn off all attributes
|
38
37
|
#:bright => 1, # Set bright mode
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
38
|
+
underline: 4, # Set underline mode
|
39
|
+
blink: 5, # Set blink mode
|
40
|
+
swap: 7, # Exchange foreground and background colors
|
41
|
+
hide: 8 # Hide text (foreground color would be the same as background)
|
43
42
|
}
|
44
43
|
|
45
44
|
protected
|
@@ -47,16 +46,14 @@ class String
|
|
47
46
|
#
|
48
47
|
# Set color values in new string intance
|
49
48
|
#
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
nil
|
59
|
-
end
|
49
|
+
def color_parameters(params)
|
50
|
+
return unless params.instance_of?(Hash)
|
51
|
+
|
52
|
+
@color = params[:color]
|
53
|
+
@background = params[:background]
|
54
|
+
@mode = params[:mode]
|
55
|
+
@uncolorized = params[:uncolorized]
|
56
|
+
self
|
60
57
|
end
|
61
58
|
|
62
59
|
public
|
@@ -77,22 +74,23 @@ class String
|
|
77
74
|
# puts "This is blue text on red".blue.on_red.blink
|
78
75
|
# puts "This is uncolorized".blue.on_red.uncolorize
|
79
76
|
#
|
80
|
-
|
77
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
78
|
+
def colorize(params)
|
81
79
|
return self unless STDOUT.isatty
|
82
80
|
|
83
81
|
begin
|
84
|
-
require
|
82
|
+
require "Win32/Console/ANSI" if RUBY_PLATFORM.match?(/win32/)
|
85
83
|
rescue LoadError
|
86
|
-
raise
|
84
|
+
raise "You must gem install win32console to use colorize on Windows"
|
87
85
|
end
|
88
86
|
|
89
87
|
color_parameters = {}
|
90
88
|
|
91
|
-
if
|
89
|
+
if params.instance_of?(Hash)
|
92
90
|
color_parameters[:color] = COLORS[params[:color]]
|
93
91
|
color_parameters[:background] = COLORS[params[:background]]
|
94
92
|
color_parameters[:mode] = MODES[params[:mode]]
|
95
|
-
elsif
|
93
|
+
elsif params.instance_of?(Symbol)
|
96
94
|
color_parameters[:color] = COLORS[params]
|
97
95
|
end
|
98
96
|
|
@@ -100,15 +98,18 @@ class String
|
|
100
98
|
color_parameters[:background] ||= @background ||= COLORS[:default]
|
101
99
|
color_parameters[:mode] ||= @mode ||= MODES[:default]
|
102
100
|
|
103
|
-
color_parameters[:uncolorized] ||= @uncolorized ||=
|
101
|
+
color_parameters[:uncolorized] ||= @uncolorized ||= dup
|
104
102
|
|
105
103
|
# calculate bright mode
|
106
104
|
color_parameters[:color] += 50 if color_parameters[:color] > 10
|
107
105
|
|
108
106
|
color_parameters[:background] += 50 if color_parameters[:background] > 10
|
109
107
|
|
110
|
-
"\033[#{color_parameters[:mode]};#{color_parameters[:color]+30}
|
108
|
+
"\033[#{color_parameters[:mode]};#{color_parameters[:color] + 30};"\
|
109
|
+
"#{color_parameters[:background] + 40}m#{color_parameters[:uncolorized]}\033[0m"\
|
110
|
+
.color_parameters(color_parameters)
|
111
111
|
end
|
112
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
112
113
|
|
113
114
|
#
|
114
115
|
# Return uncolorized string
|
@@ -127,37 +128,36 @@ class String
|
|
127
128
|
#
|
128
129
|
# Make some color and on_color methods
|
129
130
|
#
|
130
|
-
COLORS.each_key do |
|
131
|
+
COLORS.each_key do |key|
|
131
132
|
next if key == :default
|
132
133
|
|
133
134
|
define_method key do
|
134
|
-
|
135
|
+
colorize(color: key)
|
135
136
|
end
|
136
137
|
|
137
138
|
define_method "on_#{key}" do
|
138
|
-
|
139
|
+
colorize(background: key)
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
143
|
#
|
143
144
|
# Methods for modes
|
144
145
|
#
|
145
|
-
MODES.each_key do |
|
146
|
+
MODES.each_key do |key|
|
146
147
|
next if key == :default
|
147
148
|
|
148
149
|
define_method key do
|
149
|
-
|
150
|
+
colorize(mode: key)
|
150
151
|
end
|
151
152
|
end
|
152
153
|
|
153
154
|
class << self
|
154
|
-
|
155
155
|
#
|
156
156
|
# Return array of available modes used by colorize method
|
157
157
|
#
|
158
158
|
def modes
|
159
159
|
keys = []
|
160
|
-
MODES.each_key do |
|
160
|
+
MODES.each_key do |key|
|
161
161
|
keys << key
|
162
162
|
end
|
163
163
|
keys
|
@@ -168,7 +168,7 @@ class String
|
|
168
168
|
#
|
169
169
|
def colors
|
170
170
|
keys = []
|
171
|
-
COLORS.each_key do |
|
171
|
+
COLORS.each_key do |key|
|
172
172
|
keys << key
|
173
173
|
end
|
174
174
|
keys
|
@@ -177,16 +177,16 @@ class String
|
|
177
177
|
#
|
178
178
|
# Display color matrix with color names.
|
179
179
|
#
|
180
|
-
def color_matrix(
|
180
|
+
def color_matrix(txt = "[X]")
|
181
181
|
size = String.colors.length
|
182
|
-
String.colors.each do |
|
183
|
-
String.colors.each do |
|
184
|
-
print txt.colorize(
|
182
|
+
String.colors.each do |color|
|
183
|
+
String.colors.each do |back|
|
184
|
+
print txt.colorize(color: color, background: back)
|
185
185
|
end
|
186
186
|
puts " < #{color}"
|
187
187
|
end
|
188
|
-
String.colors.reverse.each_with_index do |
|
189
|
-
puts "#{"|".rjust(txt.length)*(size-index)} < #{back}"
|
188
|
+
String.colors.reverse.each_with_index do |back, index|
|
189
|
+
puts "#{"|".rjust(txt.length) * (size - index)} < #{back}"
|
190
190
|
end
|
191
191
|
""
|
192
192
|
end
|