pastel 0.7.1 → 0.7.2

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: aaa5adc3e15580e13bb1a6e6408c4ae861291eae
4
- data.tar.gz: 29d6776a836796d28f8512c90fa2dfcd3e4d5483
3
+ metadata.gz: a9423d9bb23567a05cccb8fa304de88cf791f01d
4
+ data.tar.gz: 4c251c76dfabc80d5e2a48b031983eec254c8faa
5
5
  SHA512:
6
- metadata.gz: f778303c03d07dfedabdb2f7b8d79c8b8e3aca7cd03d9c25a27af616794267305648079841deea03390f56e84867e868edc1146452f247ca89f2d721bd27691a
7
- data.tar.gz: a20b24d879adb603257444a760dbe8a23c797be93e2c483634ccd49df4a9d0c7d718e470cb705ab21bd7c114ee81e9e5be318961f0988d70f3213467211b2ad2
6
+ metadata.gz: c32d02d36f105e11ee28bf219556088bc2a2b84e625490cdc23ab4a5aad99eee136270662a78f779ea13549a278795510d8e97176ce8487f91a6c76441557906
7
+ data.tar.gz: 925733ccb1ef6cd33cf11362da01eb28b830b8cdb36e681d4b65ae3305816d37fb4c437451c6387cb2d2d6fd6dbb7ef3106e540d922570e61ba99563b0da06bb
@@ -2,23 +2,23 @@
2
2
  language: ruby
3
3
  sudo: false
4
4
  cache: bundler
5
+ before_install: "gem update bundler"
5
6
  bundler_args: --without yard benchmarks
6
7
  script: "bundle exec rake ci"
7
8
  rvm:
8
9
  - 1.9.3
9
10
  - 2.0.0
10
11
  - 2.1.10
11
- - 2.2.5
12
- - 2.3.1
12
+ - 2.2.8
13
+ - 2.3.5
14
+ - 2.4.2
13
15
  - jruby-9000
14
16
  - jruby-head
15
17
  - ruby-head
16
- - rbx-2
17
18
  matrix:
18
19
  allow_failures:
19
20
  - rvm: ruby-head
20
21
  - rvm: jruby-head
21
- - rvm: rbx-2
22
22
  fast_finish: true
23
23
  branches:
24
24
  only: master
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.7.2] - 2017-11-09
4
+
5
+ ### Changed
6
+ * Change to load relative file paths
7
+ * Change to allow `#alias_color` to accept multiple colors by Jared Ning (@ordinaryzelig)
8
+
3
9
  ## [v0.7.1] - 2017-01-09
4
10
 
5
11
  ### Changed
@@ -102,6 +108,7 @@
102
108
  * Change gemspec to include equatable as dependency
103
109
  * Change Delegator to stop creating instances and improve performance
104
110
 
111
+ [v0.7.2]: https://github.com/peter-murach/pastel/compare/v0.7.1...v0.7.2
105
112
  [v0.7.1]: https://github.com/peter-murach/pastel/compare/v0.7.0...v0.7.1
106
113
  [v0.7.0]: https://github.com/peter-murach/pastel/compare/v0.6.1...v0.7.0
107
114
  [v0.6.1]: https://github.com/peter-murach/pastel/compare/v0.6.0...v0.6.1
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'rspec', '~> 3.5.0'
7
6
  gem 'yard', '~> 0.8.7'
8
7
  gem 'benchmark-ips', '~> 2.0.0'
9
8
  end
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  <div align="center">
2
2
  <img width="215" src="https://cdn.rawgit.com/piotrmurach/pastel/master/assets/pastel_logo.png" alt="pastel logo" />
3
3
  </div>
4
+
4
5
  # Pastel
6
+
5
7
  [![Gem Version](https://badge.fury.io/rb/pastel.svg)][gem]
6
8
  [![Build Status](https://secure.travis-ci.org/piotrmurach/pastel.svg?branch=master)][travis]
7
9
  [![Build status](https://ci.appveyor.com/api/projects/status/9blbjfq42o4v1rk4?svg=true)][appveyor]
@@ -119,7 +121,7 @@ pastel.red.on_green('Unicorns') {
119
121
  }
120
122
  ```
121
123
 
122
- When dealing with multiline strings you can set `eachline` option(more info see [eachline](#29-eachline)):
124
+ When dealing with multiline strings you can set `eachline` option(more info see [eachline](#211-eachline)):
123
125
 
124
126
  ```
125
127
  pastel = Pastel.new(eachline: "\n")
@@ -266,16 +268,16 @@ pastel.red("foo\nbar") # => "\e[31mfoo\e[0m\n\e[31mbar\e[0m"
266
268
 
267
269
  ### 2.12 Alias Color
268
270
 
269
- In order to setup an alias for the standard color do:
271
+ In order to setup an alias for standard colors do:
270
272
 
271
273
  ```ruby
272
- pastel.alias_color(:funky, :red)
274
+ pastel.alias_color(:funky, :red, :bold)
273
275
  ```
274
276
 
275
- From that point forward, `:funky` alias can be passed to `decorate`, `valid?` with the same meaning as standard color:
277
+ From that point forward, `:funky` alias can be passed to `decorate`, `valid?` with the same meaning as standard colors:
276
278
 
277
279
  ```ruby
278
- pastel.funky.on_green('unicorn') # => will use :red color
280
+ pastel.funky.on_green('unicorn') # => will use :red, :bold color
279
281
  ```
280
282
 
281
283
  This method allows you to give more meaningful names to existing colors.
@@ -345,10 +347,10 @@ Generic styles:
345
347
 
346
348
  This environment variable allows you to specify custom color aliases at runtime that will be understood by **Pastel**. The environment variable is read and used when the instance of **Pastel** is created. You can also use `alias_color` to create aliases.
347
349
 
348
- Only alphanumeric and `_` are allowed in the alias names with the following format:
350
+ Only alphanumeric and `_` and `.` are allowed in the alias names with the following format:
349
351
 
350
352
  ```ruby
351
- PASTEL_COLORS_ALIASES='newcolor_1=red,newcolor_2=on_green'
353
+ PASTEL_COLORS_ALIASES='newcolor_1=red,newcolor_2=on_green,funky=red.bold'
352
354
  ```
353
355
 
354
356
  ## 5. Command line
@@ -9,7 +9,6 @@ test_script:
9
9
  - bundle exec rake ci
10
10
  environment:
11
11
  matrix:
12
- - ruby_version: "193"
13
12
  - ruby_version: "200"
14
13
  - ruby_version: "200-x64"
15
14
  - ruby_version: "21"
@@ -18,6 +17,5 @@ environment:
18
17
  - ruby_version: "22-x64"
19
18
  - ruby_version: "23"
20
19
  - ruby_version: "23-x64"
21
- matrix:
22
- allow_failures:
23
- - ruby_version: "193"
20
+ - ruby_version: "24"
21
+ - ruby_version: "24-x64"
@@ -2,12 +2,12 @@
2
2
 
3
3
  require 'tty-color'
4
4
 
5
- require 'pastel/alias_importer'
6
- require 'pastel/color'
7
- require 'pastel/color_resolver'
8
- require 'pastel/delegator'
9
- require 'pastel/decorator_chain'
10
- require 'pastel/version'
5
+ require_relative 'pastel/alias_importer'
6
+ require_relative 'pastel/color'
7
+ require_relative 'pastel/color_resolver'
8
+ require_relative 'pastel/delegator'
9
+ require_relative 'pastel/decorator_chain'
10
+ require_relative 'pastel/version'
11
11
 
12
12
  module Pastel
13
13
  # Raised when the style attribute is not supported
@@ -18,7 +18,7 @@ module Pastel
18
18
  # Import aliases from the environment
19
19
  #
20
20
  # @example
21
- # importer = Pastel::AliasImporter.new(Pastel::Color.new)
21
+ # importer = Pastel::AliasImporter.new(Pastel::Color.new, {})
22
22
  # importer.import
23
23
  #
24
24
  # @return [nil]
@@ -28,11 +28,12 @@ module Pastel
28
28
  color_aliases = env['PASTEL_COLORS_ALIASES']
29
29
  return unless color_aliases
30
30
  color_aliases.split(',').each do |color_alias|
31
- new_color, old_color = color_alias.split('=').map(&:to_sym)
32
- if !new_color || !old_color
31
+ new_color, old_colors = color_alias.split('=')
32
+ if !new_color || !old_colors
33
33
  output.puts "Bad color mapping `#{color_alias}`"
34
34
  else
35
- color.alias_color(new_color, old_color)
35
+ color.alias_color(new_color.to_sym,
36
+ *old_colors.split('.').map(&:to_sym))
36
37
  end
37
38
  end
38
39
  end
@@ -1,7 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  require 'equatable'
4
- require 'pastel/ansi'
4
+
5
+ require_relative 'ansi'
5
6
 
6
7
  module Pastel
7
8
  # A class responsible for coloring strings.
@@ -194,19 +195,19 @@ module Pastel
194
195
  colors.all? { |color| style_names.include?(color.to_sym) }
195
196
  end
196
197
 
197
- # Define a new color alias
198
+ # Define a new colors alias
198
199
  #
199
200
  # @param [String] alias_name
200
- # the color alias to define
201
- # @param [String] color
202
- # the color the alias will correspond to
201
+ # the colors alias to define
202
+ # @param [Array[Symbol,String]] color
203
+ # the colors the alias will correspond to
203
204
  #
204
- # @return [String]
205
- # the standard color value of the alias
205
+ # @return [Array[String]]
206
+ # the standard color values of the alias
206
207
  #
207
208
  # @api public
208
- def alias_color(alias_name, color)
209
- validate(color)
209
+ def alias_color(alias_name, *colors)
210
+ validate(*colors)
210
211
 
211
212
  if !(alias_name.to_s =~ /^[\w]+$/)
212
213
  fail InvalidAliasNameError, "Invalid alias name `#{alias_name}`"
@@ -215,8 +216,8 @@ module Pastel
215
216
  "Cannot alias standard color `#{alias_name}`"
216
217
  end
217
218
 
218
- ALIASES[alias_name.to_sym] = ANSI::ATTRIBUTES[color]
219
- color
219
+ ALIASES[alias_name.to_sym] = colors.map(&ANSI::ATTRIBUTES.method(:[]))
220
+ colors
220
221
  end
221
222
 
222
223
  private
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'pastel/ansi'
3
+ require_relative 'ansi'
4
4
 
5
5
  module Pastel
6
6
  # Responsible for parsing color symbols out of text with color escapes
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'pastel/detached'
3
+ require_relative 'detached'
4
4
 
5
5
  module Pastel
6
6
  # Contains logic for resolving styles applied to component
@@ -3,8 +3,8 @@
3
3
  require 'equatable'
4
4
  require 'forwardable'
5
5
 
6
- require 'pastel/color_parser'
7
- require 'pastel/decorator_chain'
6
+ require_relative 'color_parser'
7
+ require_relative 'decorator_chain'
8
8
 
9
9
  module Pastel
10
10
  # Wrapes the {DecoratorChain} to allow for easy resolution
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Pastel
4
- VERSION = '0.7.1'
4
+ VERSION = '0.7.2'
5
5
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
25
25
  spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rspec', '~> 3.1'
26
27
  end
@@ -5,13 +5,13 @@ RSpec.describe Pastel, '#alias_color' do
5
5
  subject(:pastel) { described_class.new(enabled: true) }
6
6
 
7
7
  it "aliases color" do
8
- pastel.alias_color(:funky, :red)
9
- expect(pastel.funky('unicorn')).to eq("\e[31municorn\e[0m")
8
+ pastel.alias_color(:funky, :red, :bold)
9
+ expect(pastel.funky('unicorn')).to eq("\e[31;1municorn\e[0m")
10
10
  end
11
11
 
12
12
  it "aliases color and combines with regular ones" do
13
- pastel.alias_color(:funky, :red)
14
- expect(pastel.funky.on_green('unicorn')).to eq("\e[31;42municorn\e[0m")
13
+ pastel.alias_color(:funky, :red, :bold)
14
+ expect(pastel.funky.on_green('unicorn')).to eq("\e[31;1;42municorn\e[0m")
15
15
  end
16
16
 
17
17
  it "reads aliases from the environment" do
@@ -5,13 +5,13 @@ RSpec.describe Pastel::AliasImporter, '#import' do
5
5
  let(:output) { StringIO.new }
6
6
 
7
7
  it "imports aliases from environment" do
8
- color_aliases = "funky=red,base=bright_yellow"
8
+ color_aliases = "funky=red.bold,base=bright_yellow"
9
9
  env = {'PASTEL_COLORS_ALIASES' => color_aliases}
10
10
  importer = described_class.new(color, env)
11
11
 
12
12
  importer.import
13
13
 
14
- expect(color).to have_received(:alias_color).with(:funky, :red)
14
+ expect(color).to have_received(:alias_color).with(:funky, :red, :bold)
15
15
  expect(color).to have_received(:alias_color).with(:base, :bright_yellow)
16
16
  end
17
17
 
@@ -23,10 +23,10 @@ RSpec.describe Pastel::Color, '.alias_color' do
23
23
  end
24
24
 
25
25
  it 'aliases color :red to :funky' do
26
- color.alias_color(:funky, :red)
26
+ color.alias_color(:funky, :red, :bold)
27
27
  expect(color.valid?(:funky)).to eq(true)
28
- expect(color.code(:funky)).to eq([31])
29
- expect(color.lookup(:funky)).to eq("\e[31m")
28
+ expect(color.code(:funky)).to eq([[31, 1]])
29
+ expect(color.lookup(:funky)).to eq("\e[31;1m")
30
30
  end
31
31
 
32
32
  it "has global aliases" do
@@ -18,7 +18,7 @@ RSpec.describe Pastel::Color, '#code' do
18
18
  end
19
19
 
20
20
  it "finds alias code" do
21
- color.alias_color(:funky, :red)
22
- expect(color.code(:funky)).to eq(color.code(:red))
21
+ color.alias_color(:funky, :red, :bold)
22
+ expect(color.code(:funky)).to eq([color.code(:red) + color.code(:bold)])
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pastel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equatable
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.1'
75
89
  description: Terminal strings styling with intuitive and clean API.
76
90
  email:
77
91
  - ''