pastel 0.6.0 → 0.6.1

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: 391313f0e40b883c29f307c2484cabe9585f0e5a
4
- data.tar.gz: 4ed8c3fce07de31b31b1d1ebe374d47c89f01ab5
3
+ metadata.gz: 36792f1ad19da1d3055e30adc845e03e6ac1c3be
4
+ data.tar.gz: 4ddf64dfbb76fb94f39117fc11f1d037ca192313
5
5
  SHA512:
6
- metadata.gz: 549b782b7c6c4db583298d765ee8d8bc07c42ad317153b5fd2450cc07734a4bfcc0cf4d5460cfa3978b1504c457ed25b218dae1dd73b9d0f2013021cddc0ab69
7
- data.tar.gz: 75c0f16901dae62dbec9f3cd3790162a30a29ac0cffedd2dc930a75dd2d0d7bd57212dd669ae0f5b935ff36d3d6ced914fd25dfbbabb995c392ae5466776b2f5
6
+ metadata.gz: 4c3391540a8a5b9100cb4cadde405ac364b5dc9de035a4192a5002130c5076cf338870e20cacbb30a9704b3bd193587f8793a0440bf50ea3a8f37166ad156525
7
+ data.tar.gz: 1876b306cb278ec5cbc0bd5cde41a9e5be19733b30d26091c52329bcdd4db3b5cfda1f4e870257e512c7972eaf6c30d0cd67acaa5e17b29719e8e93b0aec9574
@@ -21,3 +21,5 @@ matrix:
21
21
  fast_finish: true
22
22
  branches:
23
23
  only: master
24
+ notifications:
25
+ email: false
@@ -1,5 +1,10 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.6.1] - 2016-04-09
4
+
5
+ ### Fixed
6
+ * Fix #decorate to apply color to non zero length strings
7
+
3
8
  ## [v0.6.0] - 2016-01-15
4
9
 
5
10
  ### Added
@@ -81,6 +86,7 @@
81
86
  * Change gemspec to include equatable as dependency
82
87
  * Change Delegator to stop creating instances and improve performance
83
88
 
89
+ [v0.6.1]: https://github.com/peter-murach/pastel/compare/v0.6.0...v0.6.1
84
90
  [v0.6.0]: https://github.com/peter-murach/pastel/compare/v0.5.3...v0.6.0
85
91
  [v0.5.3]: https://github.com/peter-murach/pastel/compare/v0.5.2...v0.5.3
86
92
  [v0.5.2]: https://github.com/peter-murach/pastel/compare/v0.5.1...v0.5.2
data/README.md CHANGED
@@ -1,26 +1,26 @@
1
1
  <div align="center">
2
- <img width="215" src="https://cdn.rawgit.com/peter-murach/pastel/master/assets/pastel_logo.png" alt="pastel logo" />
2
+ <img width="215" src="https://cdn.rawgit.com/piotrmurach/pastel/master/assets/pastel_logo.png" alt="pastel logo" />
3
3
  </div>
4
4
  # Pastel
5
5
  [![Gem Version](https://badge.fury.io/rb/pastel.svg)][gem]
6
- [![Build Status](https://secure.travis-ci.org/peter-murach/pastel.svg?branch=master)][travis]
7
- [![Code Climate](https://codeclimate.com/github/peter-murach/pastel/badges/gpa.svg)][codeclimate]
8
- [![Coverage Status](https://coveralls.io/repos/peter-murach/pastel/badge.svg)][coverage]
9
- [![Inline docs](http://inch-ci.org/github/peter-murach/pastel.svg?branch=master)][inchpages]
6
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/pastel.svg?branch=master)][travis]
7
+ [![Code Climate](https://codeclimate.com/github/piotrmurach/pastel/badges/gpa.svg)][codeclimate]
8
+ [![Coverage Status](https://coveralls.io/repos/github/piotrmurach/pastel/badge.svg)][coverage]
9
+ [![Inline docs](http://inch-ci.org/github/piotrmurach/pastel.svg?branch=master)][inchpages]
10
10
 
11
11
  [gem]: http://badge.fury.io/rb/pastel
12
- [travis]: http://travis-ci.org/peter-murach/pastel
13
- [codeclimate]: https://codeclimate.com/github/peter-murach/pastel
14
- [coverage]: https://coveralls.io/r/peter-murach/pastel
15
- [inchpages]: http://inch-ci.org/github/peter-murach/pastel
12
+ [travis]: http://travis-ci.org/piotrmurach/pastel
13
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/pastel
14
+ [coverage]: https://coveralls.io/github/piotrmurach/pastel
15
+ [inchpages]: http://inch-ci.org/github/piotrmurach/pastel
16
16
 
17
17
  > Terminal output styling with intuitive and clean API that doesn't monkey patch String class.
18
18
 
19
19
  **Pastel** is minimal and focused to work in all terminal emulators.
20
20
 
21
- ![screenshot](https://github.com/peter-murach/pastel/raw/master/assets/screenshot.png)
21
+ ![screenshot](https://github.com/piotrmurach/pastel/raw/master/assets/screenshot.png)
22
22
 
23
- **Pastel** provides independent coloring component for [TTY](https://github.com/peter-murach/tty) toolkit.
23
+ **Pastel** provides independent coloring component for [TTY](https://github.com/piotrmurach/tty) toolkit.
24
24
 
25
25
  ## Features
26
26
 
@@ -58,7 +58,7 @@ Or install it yourself as:
58
58
  * [2.7 Lookup](#27-lookup)
59
59
  * [2.8 Valid?](#28-valid)
60
60
  * [2.9 Colored?](#29-colored)
61
- * [2.10 Enabled?](#30-enabled)
61
+ * [2.10 Enabled?](#210-enabled)
62
62
  * [2.11 Eachline](#211-eachline)
63
63
  * [2.12 Alias Color](#212-alias-color)
64
64
  * [3. Supported Colors](#3-supported-colors)
@@ -133,6 +133,9 @@ puts error.('Error!')
133
133
  puts warning.('Warning')
134
134
  ```
135
135
 
136
+ If your output is redirected to a file, you probably don't want Pastel to add color to your text.
137
+ See https://github.com/piotrmurach/pastel#210-enabled for a way to easily accomplish this.
138
+
136
139
  **Pastel** has companion library called `pastel-cli` that allows you to style text in terminal via `pastel` executable:
137
140
 
138
141
  ```bash
@@ -242,6 +245,14 @@ pastel = Pastel.new(enabled: true)
242
245
  pastel.enabled? # => true
243
246
  ```
244
247
 
248
+ If you are outputting to stdout or stderr, and want to suppress color if output is redirected to a file,
249
+ you can set the enabled attribute dynamically, as in:
250
+
251
+ ```ruby
252
+ stdout_pastel = Pastel.new(enabled: $stdout.tty?)
253
+ stderr_pastel = Pastel.new(enabled: $stderr.tty?)
254
+ ```
255
+
245
256
  ### 2.11 Eachline
246
257
 
247
258
  Normally **Pastel** colors string by putting color codes at the beginning and end of the string, but if you provide `eachline` option set to some string, that string will be considered the line delimiter. Consequently, each line will be separately colored with escape sequence and reset code at the end. This option is desirable if the output string contains newlines and you're using background colors. Since color code that spans more than one line is often interpreted by terminal as providing background for all the lines that follow. This in turn may cause programs such as pagers to spill the colors throughout the text. In most cases you will want to set `eachline` to `\n` character like so:
@@ -340,7 +351,7 @@ PASTEL_COLORS_ALIASES='newcolor_1=red,newcolor_2=on_green'
340
351
 
341
352
  ## 5. Command line
342
353
 
343
- You can also install [pastel-cli](https://github.com/peter-murach/pastel-cli) to use `pastel` executable in terminal:
354
+ You can also install [pastel-cli](https://github.com/piotrmurach/pastel-cli) to use `pastel` executable in terminal:
344
355
 
345
356
  ```bash
346
357
  $ pastel green 'Unicorns & rainbows!'
@@ -348,7 +359,7 @@ $ pastel green 'Unicorns & rainbows!'
348
359
 
349
360
  ## Contributing
350
361
 
351
- 1. Fork it ( https://github.com/peter-murach/pastel/fork )
362
+ 1. Fork it ( https://github.com/piotrmurach/pastel/fork )
352
363
  2. Create your feature branch (`git checkout -b my-new-feature`)
353
364
  3. Commit your changes (`git commit -am 'Add some feature'`)
354
365
  4. Push to the branch (`git push origin my-new-feature`)
@@ -12,8 +12,6 @@ module Pastel
12
12
  # Match all color escape sequences
13
13
  ANSI_COLOR_REGEXP = /\x1b+(\[|\[\[)[0-9;:?]+m/mo.freeze
14
14
 
15
- BLANK_REGEX = /\A[[:space:]]*\z/o.freeze
16
-
17
15
  attr_reader :enabled
18
16
  alias_method :enabled?, :enabled
19
17
 
@@ -226,9 +224,7 @@ module Pastel
226
224
  #
227
225
  # @api private
228
226
  def blank?(value)
229
- value.nil? ||
230
- value.respond_to?(:empty?) && value.empty? ||
231
- BLANK_REGEX =~ value
227
+ value.nil? || !value.respond_to?(:to_str) || value.to_s == ''
232
228
  end
233
229
 
234
230
  # @api private
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Pastel
4
- VERSION = "0.6.0"
4
+ VERSION = '0.6.1'
5
5
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = [""]
11
11
  spec.summary = %q{Terminal strings styling with intuitive and clean API.}
12
12
  spec.description = %q{Terminal strings styling with intuitive and clean API.}
13
- spec.homepage = "https://github.com/peter-murach/pastel"
13
+ spec.homepage = "https://github.com/piotrmurach/pastel"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -69,7 +69,11 @@ RSpec.describe Pastel::Color, '.decorate' do
69
69
  expect(color.decorate(nil, :red)).to eq(nil)
70
70
  end
71
71
 
72
- it "doesn't decorate empty string" do
73
- expect(color.decorate(" ", :red)).to eq(" ")
72
+ it "doesn't decorate zero length string" do
73
+ expect(color.decorate('', :red)).to eq('')
74
+ end
75
+
76
+ it "doesn't decorate non-zero length string" do
77
+ expect(color.decorate(' ', :red)).to eq("\e[31m \e[0m")
74
78
  end
75
79
  end
@@ -1,11 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  RSpec.describe Pastel, 'coloring dsl' do
4
- subject(:pastel) { described_class.new(enabled: true) }
5
4
 
6
- it "doesn't apply styles to empty string" do
7
- expect(pastel.red('')).to eq('')
8
- end
5
+ subject(:pastel) { described_class.new(enabled: true) }
9
6
 
10
7
  it "colors string" do
11
8
  expect(pastel.red("unicorn")).to eq("\e[31municorn\e[0m")
@@ -71,6 +68,18 @@ RSpec.describe Pastel, 'coloring dsl' do
71
68
  end).to eq(string)
72
69
  end
73
70
 
71
+ it "doesn't decorate nil" do
72
+ expect(pastel.red(nil)).to eq('')
73
+ end
74
+
75
+ it "doesn't apply styles to empty string" do
76
+ expect(pastel.red('')).to eq('')
77
+ end
78
+
79
+ it "applies styles to empty with width more than 1" do
80
+ expect(pastel.red(' ')).to eq("\e[31m \e[0m")
81
+ end
82
+
74
83
  it "raises error when chained with unrecognized color" do
75
84
  expect {
76
85
  pastel.unknown.on_red('unicorn')
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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equatable
@@ -81,7 +81,6 @@ extra_rdoc_files: []
81
81
  files:
82
82
  - .gitignore
83
83
  - .rspec
84
- - .ruby-version
85
84
  - .travis.yml
86
85
  - CHANGELOG.md
87
86
  - Gemfile
@@ -128,7 +127,7 @@ files:
128
127
  - tasks/console.rake
129
128
  - tasks/coverage.rake
130
129
  - tasks/spec.rake
131
- homepage: https://github.com/peter-murach/pastel
130
+ homepage: https://github.com/piotrmurach/pastel
132
131
  licenses:
133
132
  - MIT
134
133
  metadata: {}
@@ -1 +0,0 @@
1
- 2.0.0