awesome_print 0.1.2 → 0.1.3

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.
Files changed (5) hide show
  1. data/CHANGELOG +15 -0
  2. data/README.md +16 -6
  3. data/VERSION +1 -1
  4. data/lib/ap/awesome_print.rb +32 -0
  5. metadata +4 -3
@@ -0,0 +1,15 @@
1
+ 0.1.3
2
+ - Added support for setting custom defaults in ~/.aprc
3
+
4
+ 0.1.2
5
+ - Correctly handle empty arrays and hashes
6
+ - Use alias_method instead of alias (fixes non-tty method aliasing)
7
+ - Added awesome_inspect method
8
+
9
+ 0.1.1
10
+ - Added support for tableless ActiveRecord models
11
+ - Left align hash keys if @options[:indent] is negative
12
+
13
+ 0.1.0
14
+ - Initial Release.
15
+
data/README.md CHANGED
@@ -4,13 +4,13 @@ exposing their internal structure with proper indentation. Rails ActiveRecord
4
4
  objects are supported via included mixin.
5
5
 
6
6
  ### Installation ###
7
- $ # Installing as Ruby gem
7
+ # Installing as Ruby gem
8
8
  $ gem install awesome_print
9
9
 
10
10
  # Installing as Rails plugin
11
11
  $ ruby script/plugin install http://github.com/michaeldv/awesome_print_.git
12
12
 
13
- $ # Cloning the repository
13
+ # Cloning the repository
14
14
  $ git clone git://github.com/michaeldv/awesome_print_.git
15
15
 
16
16
  ### Usage ###
@@ -20,7 +20,7 @@ objects are supported via included mixin.
20
20
 
21
21
  Default options:
22
22
 
23
- :miltiline => true,
23
+ :multiline => true,
24
24
  :plain => false,
25
25
  :indent => 4,
26
26
  :colors => {
@@ -144,9 +144,19 @@ Supported color names:
144
144
  }
145
145
  rails>
146
146
 
147
- ### Known Issues ###
148
-
149
- * Windows...
147
+ ### Setting Custom Defaults ###
148
+ You can set your own default options by creating ``.aprc`` file in your home
149
+ directory. Within that file assign your defaults to ``AwesomePrint.defaults``.
150
+ For example:
151
+
152
+ # ~/.aprc file.
153
+ AwesomePrint.defaults = {
154
+ :indent => -2,
155
+ :color => {
156
+ :hash => :pale,
157
+ :class => :white
158
+ }
159
+ }
150
160
 
151
161
  ### Note on Patches/Pull Requests ###
152
162
  * Fork the project on Github.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -29,6 +29,8 @@ class AwesomePrint
29
29
  }.merge(options.delete(:color) || {})
30
30
  }.merge(options)
31
31
 
32
+ load_custom_defaults
33
+
32
34
  @indentation = @options[:indent].abs
33
35
  Thread.current[AP] ||= []
34
36
  end
@@ -196,4 +198,34 @@ class AwesomePrint
196
198
  @outdent = ' ' * (@indentation - @options[:indent].abs)
197
199
  end
198
200
 
201
+ # Load ~/.aprc file that can store custom defaults, for example:
202
+ #
203
+ # AwesomePrint.defaults = {
204
+ # :indent => -2,
205
+ # :color => {
206
+ # :trueclass => :red
207
+ # }
208
+ # }
209
+ #------------------------------------------------------------------------------
210
+ def load_custom_defaults
211
+ dotfile = File.join(ENV["HOME"], ".aprc")
212
+ if File.readable?(dotfile)
213
+ load dotfile
214
+ @options[:color].merge!(self.class.defaults.delete(:color) || {})
215
+ @options.merge!(self.class.defaults)
216
+ end
217
+ rescue => e
218
+ $stderr.puts "Could not load #{dotfile}: #{e}"
219
+ end
220
+
221
+ # Class accessors for custom defaults.
222
+ #------------------------------------------------------------------------------
223
+ def self.defaults
224
+ @@defaults ||= {}
225
+ end
226
+
227
+ def self.defaults=(*args)
228
+ @@defaults = *args
229
+ end
230
+
199
231
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michael Dvorkin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-05 00:00:00 -07:00
17
+ date: 2010-04-07 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -41,6 +41,7 @@ extra_rdoc_files:
41
41
  - LICENSE
42
42
  - README.md
43
43
  files:
44
+ - CHANGELOG
44
45
  - LICENSE
45
46
  - README.md
46
47
  - Rakefile