brice 0.3.0 → 0.4.0

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: 14d6f3cec45a0b45cb608322cde05228cc240695
4
- data.tar.gz: e91c0741caaf6184197a24229c05f78ff8250b61
3
+ metadata.gz: d96bffd26231c8896400dfbc6f7ba78abfd71fe1
4
+ data.tar.gz: 08437c2a60a49448f72b0175653164708afdbc54
5
5
  SHA512:
6
- metadata.gz: cebb5bd7516dc856accae7f1609bcf56008c5fce7faabf207238182e02a45c640965b1468e014031d65dfff6ecc71ce84c3bf35507d4af270a26fb70659232a6
7
- data.tar.gz: 5ad2d699bd528635b643fd055a8feb2030bda369bcbcfc32c5a6c2e5237aa023cdfbeb4d2841086556a2e6bb9196c5ba86c84b39d8ce213851f7466da598a31d
6
+ metadata.gz: f551999b288415c4d70c87bf3c9591d150f1ac7059e7b3546689b9a9f53cfd53590a54011daed0b3cbff1e174e22baf1630b742764e95a612e2baffc80a930dc
7
+ data.tar.gz: 71cd29a11628b99ca99cf286109ef017d28b6647edff9a1aca741a21ab64731f5437f1164469b0c571755b8abb2aff7ef158facd189a16c817e1a8aac3af90cd
data/ChangeLog CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  = Revision history for brice
4
4
 
5
+ == 0.4.0 [2014-10-31]
6
+
7
+ * Require at least Ruby 1.9.3.
8
+ * Only set prompt if left at default.
9
+ * Default package +added_methods+ now optional.
10
+
5
11
  == 0.0.1 [2008-11-14]
6
12
 
7
13
  * Birthday :-)
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to brice version 0.3.0
5
+ This documentation refers to brice version 0.4.0
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -15,12 +15,10 @@ in that regard.
15
15
 
16
16
  Add this to your <tt>~/.irbrc</tt> and receive the default goodness:
17
17
 
18
- require 'rubygems'
19
18
  require 'brice/init' # equivalent to: require 'brice'; Brice.init
20
19
 
21
20
  Or get some more control over the configuration:
22
21
 
23
- require 'rubygems'
24
22
  require 'brice'
25
23
 
26
24
  Brice.init { |config|
@@ -67,6 +65,7 @@ guaranteed to have any effect after <tt>Brice.init</tt> has been called.
67
65
  Documentation:: https://blackwinter.github.com/brice
68
66
  Source code:: https://github.com/blackwinter/brice
69
67
  RubyGem:: https://rubygems.org/gems/brice
68
+ Travis CI:: https://travis-ci.org/blackwinter/brice
70
69
 
71
70
 
72
71
  == AUTHORS
data/Rakefile CHANGED
@@ -1,18 +1,20 @@
1
- require File.expand_path(%q{../lib/brice/version}, __FILE__)
1
+ require_relative 'lib/brice/version'
2
2
 
3
3
  begin
4
4
  require 'hen'
5
5
 
6
6
  Hen.lay! {{
7
- :gem => {
8
- :name => %q{brice},
9
- :version => Brice::VERSION,
10
- :summary => %q{Extra cool IRb goodness for the masses},
11
- :author => %q{Jens Wille},
12
- :email => %q{jens.wille@gmail.com},
13
- :license => %q{AGPL-3.0},
14
- :homepage => :blackwinter,
15
- :dependencies => %w[nuggets]
7
+ gem: {
8
+ name: %q{brice},
9
+ version: Brice::VERSION,
10
+ summary: %q{Extra cool IRb goodness for the masses},
11
+ author: %q{Jens Wille},
12
+ email: %q{jens.wille@gmail.com},
13
+ license: %q{AGPL-3.0},
14
+ homepage: :blackwinter,
15
+ dependencies: %w[nuggets],
16
+
17
+ required_ruby_version: '>= 1.9.3'
16
18
  }
17
19
  }}
18
20
  rescue LoadError => err
data/lib/brice.rb CHANGED
@@ -27,16 +27,11 @@
27
27
  require 'irb'
28
28
  require 'nuggets/env/user_home'
29
29
 
30
- require 'brice/version'
30
+ require_relative 'brice/dsl'
31
+ require_relative 'brice/version'
31
32
 
32
33
  module Brice
33
34
 
34
- autoload :Config, 'brice/config'
35
- autoload :Colours, 'brice/colours'
36
- autoload :DSL, 'brice/dsl'
37
- autoload :History, 'brice/history'
38
- autoload :Shortcuts, 'brice/shortcuts'
39
-
40
35
  RC_DIR = __FILE__.sub(/\.rb\z/, '/rc')
41
36
 
42
37
  BRICE_HOME = File.join(ENV.user_home, '.brice')
@@ -59,18 +54,19 @@ module Brice
59
54
  def init(options = {})
60
55
  @irb_rc = []
61
56
 
62
- @config = Config.new(rc_files(true).map { |rc|
63
- File.basename(rc, '.rb').sub(/\A\d+_/, '')
64
- })
65
-
66
57
  options.each { |key, value|
67
- if respond_to?(method = "#{key}=")
68
- send(method, value)
69
- else
70
- raise ArgumentError, "illegal option: #{key}"
71
- end
58
+ respond_to?(set = "#{key}=") ? send(set, value) :
59
+ raise(ArgumentError, "illegal option: #{key}")
72
60
  }
73
61
 
62
+ packages = rc_files(true).map { |rc|
63
+ File.basename(rc, '.rb').sub(/\A\d+_/, '')
64
+ }.reject { |rc| rc.end_with?('?') }
65
+
66
+ warn "Default packages: #{packages.join(', ')}" if verbose
67
+
68
+ @config = Config.new(packages)
69
+
74
70
  yield config if block_given?
75
71
 
76
72
  load_rc_files(true)
@@ -85,11 +81,8 @@ module Brice
85
81
  # Set config to +config+. Raises a TypeError if +config+ is not a
86
82
  # Brice::Config.
87
83
  def config=(config)
88
- if config.is_a?(Config)
89
- @config = config
90
- else
91
- raise TypeError, "Brice::Config expected, got #{config.class}"
92
- end
84
+ config.is_a?(Config) ? @config = config :
85
+ raise(TypeError, "Brice::Config expected, got #{config.class}")
93
86
  end
94
87
 
95
88
  # call-seq:
@@ -178,3 +171,8 @@ module Brice
178
171
  end
179
172
 
180
173
  end
174
+
175
+ require_relative 'brice/config'
176
+ require_relative 'brice/colours'
177
+ require_relative 'brice/history'
178
+ require_relative 'brice/shortcuts'
data/lib/brice/colours.rb CHANGED
@@ -24,8 +24,6 @@
24
24
  ###############################################################################
25
25
  #++
26
26
 
27
- require 'brice'
28
-
29
27
  module Brice
30
28
 
31
29
  # Add colour support to IRb.
@@ -41,58 +39,58 @@ module Brice
41
39
  # Default IRb colour scheme.
42
40
  DEFAULT_COLOURS = {
43
41
  # delimiter colours
44
- :comma => :blue,
45
- :refers => :blue,
42
+ comma: :blue,
43
+ refers: :blue,
46
44
 
47
45
  # container colours (hash and array)
48
- :open_hash => :green,
49
- :close_hash => :green,
50
- :open_array => :green,
51
- :close_array => :green,
46
+ open_hash: :green,
47
+ close_hash: :green,
48
+ open_array: :green,
49
+ close_array: :green,
52
50
 
53
51
  # object colours
54
- :open_object => :light_red,
55
- :object_class => :white,
56
- :object_addr_prefix => :blue,
57
- :object_line_prefix => :blue,
58
- :close_object => :light_red,
52
+ open_object: :light_red,
53
+ object_class: :white,
54
+ object_addr_prefix: :blue,
55
+ object_line_prefix: :blue,
56
+ close_object: :light_red,
59
57
 
60
58
  # symbol colours
61
- :symbol => :yellow,
62
- :symbol_prefix => :yellow,
59
+ symbol: :yellow,
60
+ symbol_prefix: :yellow,
63
61
 
64
62
  # string colours
65
- :open_string => :red,
66
- :string => :cyan,
67
- :close_string => :red,
63
+ open_string: :red,
64
+ string: :cyan,
65
+ close_string: :red,
68
66
 
69
67
  # misc colours
70
- :number => :cyan,
71
- :keyword => :green,
72
- :class => :light_green,
73
- :range => :red,
74
- :unknown => :green
68
+ number: :cyan,
69
+ keyword: :green,
70
+ class: :light_green,
71
+ range: :red,
72
+ unknown: :green
75
73
  }
76
74
 
77
75
  # Fruity testing colours.
78
76
  TESTING_COLOURS = {
79
- :comma => :red,
80
- :refers => :red,
81
- :open_hash => :blue,
82
- :close_hash => :blue,
83
- :open_array => :green,
84
- :close_array => :green,
85
- :open_object => :light_red,
86
- :object_class => :light_green,
87
- :object_addr => :purple,
88
- :object_line => :light_purple,
89
- :close_object => :light_red,
90
- :symbol => :yellow,
91
- :symbol_prefix => :yellow,
92
- :number => :cyan,
93
- :string => :cyan,
94
- :keyword => :white,
95
- :range => :light_blue
77
+ comma: :red,
78
+ refers: :red,
79
+ open_hash: :blue,
80
+ close_hash: :blue,
81
+ open_array: :green,
82
+ close_array: :green,
83
+ open_object: :light_red,
84
+ object_class: :light_green,
85
+ object_addr: :purple,
86
+ object_line: :light_purple,
87
+ close_object: :light_red,
88
+ symbol: :yellow,
89
+ symbol_prefix: :yellow,
90
+ number: :cyan,
91
+ string: :cyan,
92
+ keyword: :white,
93
+ range: :light_blue
96
94
  }
97
95
 
98
96
  def init(opt = {})
@@ -109,51 +107,26 @@ module Brice
109
107
 
110
108
  # Enable colourized IRb results.
111
109
  def enable_irb
112
- if IRB.const_defined?(:Inspector)
113
- IRB::Inspector.class_eval {
114
- unless method_defined?(:inspect_value_with_colour)
115
- alias_method :inspect_value_without_colour, :inspect_value
116
-
117
- def inspect_value_with_colour(value)
118
- Colours.colourize(inspect_value_without_colour(value))
119
- end
120
- end
121
-
122
- alias_method :inspect_value, :inspect_value_with_colour
123
- }
124
- else
125
- IRB::Irb.class_eval {
126
- unless method_defined?(:output_value_with_colour)
127
- alias_method :output_value_without_colour, :output_value
110
+ IRB::Inspector.class_eval {
111
+ unless method_defined?(:inspect_value_with_colour)
112
+ alias_method :inspect_value_without_colour, :inspect_value
128
113
 
129
- def output_value_with_colour
130
- value = @context.last_value
131
- value = Colours.colourize(value.inspect) if @context.inspect?
132
-
133
- printf(@context.return_format, value)
134
- end
114
+ def inspect_value_with_colour(value)
115
+ Colours.colourize(inspect_value_without_colour(value))
135
116
  end
117
+ end
136
118
 
137
- alias_method :output_value, :output_value_with_colour
138
- }
139
- end
119
+ alias_method :inspect_value, :inspect_value_with_colour
120
+ }
140
121
  end
141
122
 
142
123
  # Disable colourized IRb results.
143
124
  def disable_irb
144
- if IRB.const_defined?(:Inspector)
145
- IRB::Inspector.class_eval {
146
- if method_defined?(:inspect_value_without_colour)
147
- alias_method :inspect_value, :inspect_value_without_colour
148
- end
149
- }
150
- else
151
- IRB::Irb.class_eval {
152
- if method_defined?(:output_value_without_colour)
153
- alias_method :output_value, :output_value_without_colour
154
- end
155
- }
156
- end
125
+ IRB::Inspector.class_eval {
126
+ if method_defined?(:inspect_value_without_colour)
127
+ alias_method :inspect_value, :inspect_value_without_colour
128
+ end
129
+ }
157
130
  end
158
131
 
159
132
  def enable_pp
@@ -233,23 +206,23 @@ module Brice
233
206
  extend self
234
207
 
235
208
  COLOURS = {
236
- :reset => '0;0',
237
- :black => '0;30',
238
- :red => '0;31',
239
- :green => '0;32',
240
- :brown => '0;33',
241
- :blue => '0;34',
242
- :cyan => '0;36',
243
- :purple => '0;35',
244
- :light_gray => '0;37',
245
- :dark_gray => '1;30',
246
- :light_red => '1;31',
247
- :light_green => '1;32',
248
- :yellow => '1;33',
249
- :light_blue => '1;34',
250
- :light_cyan => '1;36',
251
- :light_purple => '1;35',
252
- :white => '1;37'
209
+ reset: '0;0',
210
+ black: '0;30',
211
+ red: '0;31',
212
+ green: '0;32',
213
+ brown: '0;33',
214
+ blue: '0;34',
215
+ cyan: '0;36',
216
+ purple: '0;35',
217
+ light_gray: '0;37',
218
+ dark_gray: '1;30',
219
+ light_red: '1;31',
220
+ light_green: '1;32',
221
+ yellow: '1;33',
222
+ light_blue: '1;34',
223
+ light_cyan: '1;36',
224
+ light_purple: '1;35',
225
+ white: '1;37'
253
226
  }
254
227
 
255
228
  # Return the escape code for a given colour.
data/lib/brice/config.rb CHANGED
@@ -25,7 +25,6 @@
25
25
  #++
26
26
 
27
27
  require 'ostruct'
28
- require 'brice'
29
28
 
30
29
  module Brice
31
30
 
data/lib/brice/dsl.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2012 Jens Wille #
6
+ # Copyright (C) 2008-2014 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@gmail.com> #
@@ -27,8 +27,6 @@
27
27
  require 'nuggets/object/silence_mixin'
28
28
  require 'nuggets/env/set'
29
29
 
30
- require 'brice'
31
-
32
30
  module Brice
33
31
 
34
32
  # Certain global helper methods for use inside IRb extensions. Also
data/lib/brice/history.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2012 Jens Wille #
6
+ # Copyright (C) 2008-2014 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@gmail.com> #
@@ -24,8 +24,6 @@
24
24
  ###############################################################################
25
25
  #++
26
26
 
27
- require 'brice'
28
-
29
27
  module Brice
30
28
 
31
29
  # IRb history support.
data/lib/brice/loud.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'brice'
2
- Brice.init(:quiet => false)
2
+ Brice.init(quiet: false)
@@ -2,8 +2,6 @@
2
2
 
3
3
  brice 'init' => nil do |config|
4
4
 
5
- $KCODE = 'u' if RUBY_VERSION < '1.9'
6
-
7
5
  IRB.conf[:AUTO_INDENT] = true
8
6
 
9
7
  end
@@ -53,6 +53,6 @@ brice 'prompt' => nil do |config|
53
53
  }
54
54
  )
55
55
 
56
- IRB.conf[:PROMPT_MODE] = RUBY_VERSION < '1.9' ? :BRICE_SIMPLE : :BRICE_VERBOSE
56
+ IRB.conf[:PROMPT_MODE] = :BRICE_VERBOSE if IRB.conf[:PROMPT_MODE] == :DEFAULT
57
57
 
58
58
  end
@@ -1,2 +1,2 @@
1
1
  require 'brice'
2
- Brice.init(:quiet => false, :verbose => true)
2
+ Brice.init(quiet: false, verbose: true)
@@ -3,7 +3,7 @@
3
3
  # #
4
4
  # A component of brice, the extra cool IRb goodness donator #
5
5
  # #
6
- # Copyright (C) 2008-2012 Jens Wille #
6
+ # Copyright (C) 2008-2014 Jens Wille #
7
7
  # #
8
8
  # Authors: #
9
9
  # Jens Wille <jens.wille@gmail.com> #
@@ -25,10 +25,18 @@
25
25
  #++
26
26
 
27
27
  require 'nuggets/file/which'
28
- require 'brice'
29
28
 
30
29
  module Brice
31
30
 
31
+ EDITORS = %W[
32
+ #{ENV['VISUAL']}
33
+ #{ENV['EDITOR']}
34
+ /usr/bin/sensible-editor
35
+ /usr/bin/xdg-open
36
+ open
37
+ vi
38
+ ]
39
+
32
40
  # Convenient shortcut methods.
33
41
  #
34
42
  # Set <tt>config.shortcuts.opt = { :object => false }</tt> to disable
@@ -55,7 +63,7 @@ module Brice
55
63
  end
56
64
 
57
65
  def ri!(*args)
58
- opts, args = args.partition { |arg| arg.to_s =~ /\A--/ }
66
+ opts, args = args.partition { |arg| arg.to_s.start_with?('--') }
59
67
 
60
68
  args.empty? ? args << name : args.map! { |arg|
61
69
  arg, method = arg.to_s, nil
@@ -124,14 +132,7 @@ module Brice
124
132
  YAML.dump(obj, tempfile)
125
133
  tempfile.close
126
134
 
127
- if editor ||= File.which_command(%W[
128
- #{ENV['VISUAL']}
129
- #{ENV['EDITOR']}
130
- /usr/bin/sensible-editor
131
- /usr/bin/xdg-open
132
- open
133
- vi
134
- ])
135
+ if editor ||= File.which_command(EDITORS)
135
136
  system(editor, path = tempfile.path)
136
137
  return obj unless File.exists?(path)
137
138
  else
data/lib/brice/version.rb CHANGED
@@ -3,7 +3,7 @@ module Brice
3
3
  module Version
4
4
 
5
5
  MAJOR = 0
6
- MINOR = 3
6
+ MINOR = 4
7
7
  TINY = 0
8
8
 
9
9
  class << self
@@ -1,5 +1,3 @@
1
- require 'brice/history'
2
-
3
1
  describe Brice::History do
4
2
 
5
3
  def hist
@@ -7,7 +5,7 @@ describe Brice::History do
7
5
  end
8
6
 
9
7
  def init_hist(opt = {})
10
- @hist = Brice::History.new(opt.merge(:path => @path), hist)
8
+ @hist = Brice::History.new(opt.merge(path: @path), hist)
11
9
  end
12
10
 
13
11
  def saved_hist
@@ -23,8 +21,8 @@ describe Brice::History do
23
21
 
24
22
  describe 'no uniq, no merge' do
25
23
 
26
- before :each do
27
- init_hist(:uniq => false, :merge => false)
24
+ before do
25
+ init_hist(uniq: false, merge: false)
28
26
  end
29
27
 
30
28
  example { compare_hist(%w[]) }
@@ -37,8 +35,8 @@ describe Brice::History do
37
35
 
38
36
  describe 'uniq, no merge' do
39
37
 
40
- before :each do
41
- init_hist(:uniq => true, :merge => false)
38
+ before do
39
+ init_hist(uniq: true, merge: false)
42
40
  end
43
41
 
44
42
  example { compare_hist(%w[]) }
@@ -51,8 +49,8 @@ describe Brice::History do
51
49
 
52
50
  describe 'uniq, merge' do
53
51
 
54
- before :each do
55
- init_hist(:uniq => true, :merge => true)
52
+ before do
53
+ init_hist(uniq: true, merge: true)
56
54
  end
57
55
 
58
56
  example { compare_hist(%w[]) }
@@ -66,8 +64,8 @@ describe Brice::History do
66
64
 
67
65
  describe 'reverse uniq, no merge' do
68
66
 
69
- before :each do
70
- init_hist(:uniq => :reverse, :merge => false)
67
+ before do
68
+ init_hist(uniq: :reverse, merge: false)
71
69
  end
72
70
 
73
71
  example { compare_hist(%w[]) }
@@ -80,8 +78,8 @@ describe Brice::History do
80
78
 
81
79
  describe 'reverse uniq, merge' do
82
80
 
83
- before :each do
84
- init_hist(:uniq => :reverse, :merge => true)
81
+ before do
82
+ init_hist(uniq: :reverse, merge: true)
85
83
  end
86
84
 
87
85
  example { compare_hist(%w[]) }
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
- $:.unshift('lib') unless $:.first == 'lib'
2
-
1
+ require 'brice'
3
2
  require 'tempfile'
4
3
 
5
4
  RSpec.configure { |config|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-20 00:00:00.000000000 Z
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nuggets
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: hen
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
31
34
  - - ">="
32
35
  - !ruby/object:Gem::Version
33
- version: '0'
36
+ version: 0.8.0
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.8'
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 0.8.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -87,7 +93,7 @@ files:
87
93
  - lib/brice/history.rb
88
94
  - lib/brice/init.rb
89
95
  - lib/brice/loud.rb
90
- - lib/brice/rc/010_added_methods.rb
96
+ - lib/brice/rc/010_added_methods?.rb
91
97
  - lib/brice/rc/020_libs.rb
92
98
  - lib/brice/rc/030_history.rb
93
99
  - lib/brice/rc/040_colours.rb
@@ -105,10 +111,17 @@ homepage: http://github.com/blackwinter/brice
105
111
  licenses:
106
112
  - AGPL-3.0
107
113
  metadata: {}
108
- post_install_message:
114
+ post_install_message: |2+
115
+
116
+ brice-0.4.0 [2014-10-31]:
117
+
118
+ * Require at least Ruby 1.9.3.
119
+ * Only set prompt if left at default.
120
+ * Default package +added_methods+ now optional.
121
+
109
122
  rdoc_options:
110
123
  - "--title"
111
- - brice Application documentation (v0.3.0)
124
+ - brice Application documentation (v0.4.0)
112
125
  - "--charset"
113
126
  - UTF-8
114
127
  - "--line-numbers"
@@ -121,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
134
  requirements:
122
135
  - - ">="
123
136
  - !ruby/object:Gem::Version
124
- version: '0'
137
+ version: 1.9.3
125
138
  required_rubygems_version: !ruby/object:Gem::Requirement
126
139
  requirements:
127
140
  - - ">="
@@ -129,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
142
  version: '0'
130
143
  requirements: []
131
144
  rubyforge_project:
132
- rubygems_version: 2.3.0
145
+ rubygems_version: 2.4.2
133
146
  signing_key:
134
147
  specification_version: 4
135
148
  summary: Extra cool IRb goodness for the masses