warner 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ceede9c3e8dc1130b0439eb00abd5e453d7c7ad
4
- data.tar.gz: 1b1121e81131e995ac86b44d3f79b2c325328795
3
+ metadata.gz: c0e0c6766b6792b26499609e1ed60aa5168f8d5e
4
+ data.tar.gz: 6ac1b99242df916c0d440c0c46fafe28e52821b5
5
5
  SHA512:
6
- metadata.gz: 8cd0cca9eecf3b1a00dfa4f9d31421d12466f0a68db6adeb3aa21b111cb0b3e46e312795da19a2e06091f30b2a0973ad2b6ab20e6d95662d9992cdcc66434dc0
7
- data.tar.gz: 2a96186f30aac6b50fbc189d587c5a4bfdb30a1a2e5026527dab4c71ebdfe596a307138ccf7d0ed9618267181c9531adf49a7d1ee6cc727c203dfe3a23014eb8
6
+ metadata.gz: e36449d6d6cac48242d77c785cf9151bfb819805dd82d5d52ed4529609ebc681c71276d4b74108f6e11528a4b17426cdcc5c1072b514089af83a3d6c39710295
7
+ data.tar.gz: 87b27e953dc4fd6f4864fa4711dfdc2cf4ea1360b24ce66f08cc7e1681fb5c2cd5d204d703781fc1d2f6a02f941b5ff2763833df0bd46cf158683207341d4a05
data/README.md CHANGED
@@ -2,7 +2,15 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/warner.svg)](https://badge.fury.io/rb/warner) [![Codeship Status for LeipeLeon/warner](https://app.codeship.com/projects/951314e0-806a-0135-5d58-6a64ad6118ad/status?branch=master)](https://app.codeship.com/projects/246699)
4
4
 
5
- Annotate your code w/ custom deprecation warnings to the `$stderr` when a newer version of a gem or rails is installed. Especially useful for monkeypatching.
5
+ Annotate your code w/ custom deprecation warnings to the `$stderr` when a newer version of a gem or rails is installed.
6
+
7
+
8
+ Especially useful for a controlled (rails) monkeypatching workflow:
9
+
10
+ Say you found a bug in a gem and waiting for a new release wil ltake to long.
11
+ Add a monkeypatch in `app/monkeypatches/` (e.g. `app/monkeypatches/bootstrap_form.rb` and maybe write a spec for it.)
12
+ When you update the flawed gem, `Warner` will check the supplied version against the installed version and will put out a deprecation warning (w/ `ActiveSupport::Deprecation`) so you can act upon it.
13
+
6
14
 
7
15
  ## Installation
8
16
 
@@ -22,51 +30,29 @@ Or install it yourself as:
22
30
 
23
31
  ## Usage
24
32
 
25
- ### `Warner.gem_version_warning`
26
-
27
- Display a message when specified is updated and needs a change.
28
-
29
33
  ```ruby
30
34
  # app/monkeypatches/bootstrap_form.rb
31
35
  Warner.gem_version_warning('bootstrap_form', "1.2", "upgrade to latest version")
32
- ```
33
-
34
- will output:
35
-
36
- ```log
37
- DEPRECATION WARNING: [gem:bootstrap_form] 2.7.0 > 1.2 : upgrade to latest version (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:1)
38
- ```
39
- ---
40
-
41
- ### `Warner.rails_version_warning`
42
-
43
- Display a message when rails is updated and needs a change.
44
-
45
- ```ruby
46
- # app/monkeypatches/bootstrap_form.rb
47
36
  Warner.rails_version_warning("5.0", "Remove this monkeypatch b/c it's fixed in 5.1 (see issue #99999)")
37
+ Warner.colored_warning("Somebody look at this piece of code please!")
48
38
  ```
49
39
 
50
40
  will output:
51
41
 
52
42
  ```log
53
- DEPRECATION WARNING: [RAILS] 5.1.6 > 5.0 : Remove this monkeypatch b/c it's fixed in 5.1 (see issue #99999) (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:1)
43
+ DEPRECATION WARNING: [gem:bootstrap_form] 2.7.0 > 1.2 : upgrade to latest version (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:1)
44
+ DEPRECATION WARNING: [RAILS] 5.1.6 > 5.0 : Remove this monkeypatch b/c it's fixed in 5.1 (see issue #99999) (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:2)
45
+ DEPRECATION WARNING: Somebody look at this piece of code please! (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:3)
54
46
  ```
55
47
 
56
- ---
57
- ### `Warner.colored_warning`
58
-
59
- Just display a message w/o any checking of versions
48
+ ## Bonus material: make deprecations stand out in the logfile
60
49
 
61
50
  ```ruby
62
- # app/monkeypatches/bootstrap_form.rb
63
- Warner.colored_warning("Somebody look at this piece of code please!")
64
- ```
65
-
66
- will output:
67
-
68
- ```log
69
- DEPRECATION WARNING: Somebody look at this piece of code please! (called from <top (required)> at /Users/berl/Clients/bwh/core/app/monkeypatches/bootstrap_form.rb:1)
51
+ # config/environments/development.rb
52
+ ActiveSupport::Deprecation.behavior = -> (message, callstack) {
53
+ $stderr.puts"\e[41;37;1m#{message}\e[0m"
54
+ $stderr.puts callstack.join("\n ") if debug
55
+ }
70
56
  ```
71
57
 
72
58
  ## Development
@@ -1,21 +1,9 @@
1
1
  require_relative "warner/version"
2
2
 
3
- if Object.const_defined?('ActiveSupport')
4
- module ActiveSupport
5
- class Deprecation
6
- DEFAULT_BEHAVIORS[:stderr] = -> (message, callstack) {
7
- $stderr.puts"\e[41;37;1m#{message}\e[0m"
8
- $stderr.puts callstack.join("\n ") if debug
9
- }
10
- end
11
- end
12
- end
13
-
14
3
  class Warner
15
4
 
16
5
  def self.colored_warning(message, callstack = nil)
17
6
  if Object.const_defined?('ActiveSupport')
18
- # callstack ||= caller_locations(2)
19
7
  ActiveSupport::Deprecation.warn message, callstack
20
8
  else
21
9
  warn "\e[41;37;1m[DEPRECATION WARNING]: #{message}\e[0m"
@@ -1,3 +1,3 @@
1
1
  class Warner
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["leipeleon@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Annotate your code w/ custom deprecation warnings}
13
- spec.description = %q{for exampele when a newer version of a gem or rails is installed. Especially useful for monkeypatching.}
13
+ spec.description = %q{Annotate your code w/ custom deprecation warnings. For example when a newer version of a gem or rails is installed. Especially useful for monkeypatching.}
14
14
  spec.homepage = "https://github.com/LeipeLeon/warner"
15
15
  spec.license = "MIT"
16
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Berenschot
@@ -108,8 +108,8 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: for exampele when a newer version of a gem or rails is installed. Especially
112
- useful for monkeypatching.
111
+ description: Annotate your code w/ custom deprecation warnings. For example when a
112
+ newer version of a gem or rails is installed. Especially useful for monkeypatching.
113
113
  email:
114
114
  - leipeleon@gmail.com
115
115
  executables: []