binding.repl 1.0.0 → 1.0.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
- ---
2
- SHA1:
3
- metadata.gz: c545da807e38567cab20601c50fdd8ffd36f8fad
4
- data.tar.gz: 623dd1a001140557e2f1ee8821bf2d0630fe5384
5
- SHA512:
6
- metadata.gz: ceb58d6786c6d564cea9b3f9c37ef251b4494d1f9547b2a18e7c202ab7d6f02cfb200c2da165156b3e239a10528c5d06b11024d28670f896e534d287ff2b27b1
7
- data.tar.gz: d211a14e759a9d1cf1a5c747bdd38ba9dc3178c1512de577bb5d0f6b2315110b779f2d28d7b73b9a98f8a2cc4857d86781e003b9c25a707c71384b5abaa92540
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cffcaf44dd2b6fa21dc2193251407a26f8bbd8be
4
+ data.tar.gz: 992180899557219bc351a42762061616c19e7242
5
+ SHA512:
6
+ metadata.gz: 4d27fb0d57feb67ba74c351043d3512b6a9edc942d607a95a1f0fdf0069d6d4b75e8017b3b15a017491c77d8b6d15ebbe6a68077fd465f25a9d88594fabbc750
7
+ data.tar.gz: 405ccf998fc7816a63033e694170058eddb2dd3a0d7a83bd9a5172a2d62a5bcf82584e073d1f94896b7c7d46510db7d43cc29984bade4406e624036fa2730a03
data/.pryrc CHANGED
@@ -1,3 +1,2 @@
1
- ENV["BINDING_REPL_RC"] = "0"
2
- require "bundler/setup"
3
- require "binding.repl"
1
+ require "bundler"
2
+ Bundler.require :default
@@ -1,3 +1,8 @@
1
+ == v1.0.1 (2014-02-10)
2
+ - BindingRepl::ENV.auto_order is lazy loaded and not on 'require'.
3
+ - remove sample file ".binding.repl.rc" from repository and rubygem. (forgot in v1.0.0)
4
+ - remove BindingRepl::ENV.enable_rc_file? (forgot in v1.0.0)
5
+
1
6
  == v1.0.0 (2014-02-09)
2
7
  - add binding.repl!
3
8
  a shortcut to `binding.repl.auto`. (#26)
@@ -1,20 +1,23 @@
1
- __ENABLE/DISABLE AT RUNTIME__
1
+ __ENABLE OR DISABLE AT RUNTIME__
2
2
 
3
- binding.repl can be enabled or disabled at runtime. by default, it is enabled.
4
- to disable, you'd write something like:
3
+ binding.repl can be enabled or disabled at runtime. <br>
4
+ the default state is 'enabled'.
5
+
6
+ __DISABLE__
5
7
 
6
8
  ```ruby
7
9
  class Foo
8
- Binding.repl.disable!
9
- binding.repl.irb # does nothing. execution continues.
10
+ BindingRepl.disable!
11
+ value = binding.repl.irb
12
+ p value.disabled? # => true
10
13
  end
11
14
  ```
12
15
 
13
- it can be re-enabled just as easily:
16
+ __ENABLE__
14
17
 
15
18
  ```ruby
16
19
  class Foo
17
- Binding.repl.enable!
18
- binding.repl.irb # opens an IRB session inside class 'Foo'
20
+ BindingRepl.enable!
21
+ value = binding.repl.irb # opens irb on 'Foo'.
19
22
  end
20
23
  ```
@@ -1,42 +1,46 @@
1
1
  __RUNTIME OPTIONS__
2
2
 
3
- __pry__
3
+ _pry_
4
4
 
5
- pry can be started with options that are forwarded to [Pry.start(…)](http://rubydoc.info/github/banister/pry/Pry#start-class_method) (API docs).
5
+ [pry](https://github.com/pry/pry) supports a large number of options for runtime configuration. <br>
6
+ a full list of options are available at [Pry.start(…) (API Docs)](http://rubydoc.info/github/banister/pry/Pry#start-class_method)
6
7
 
7
8
  ```ruby
8
- class Foo
9
+ class Person
9
10
  binding.repl.pry quiet: true
10
11
  end
11
12
  ```
12
13
 
13
- __ripl__
14
+ _rib_
14
15
 
15
- ripl can be started with options that are forwarded to `Ripl.start(…)`.
16
- unfortunately, `Ripl.start(…)` has no API documentation.
17
- check out [its github page](https://github.com/cldwalker/ripl) for more information.
16
+ [rib](https://github.com/godfat/rib) is a little less well known ruby repl that binding.repl supports since v0.8.0. <br>
17
+ a full list of options are available at [Rib.anchor(…) (API Docs)](http://rdoc.info/github/godfat/rib/Rib/Anchor/Imp#anchor-instance_method)
18
18
 
19
19
  ```ruby
20
- class Foo
21
- binding.repl.ripl riplrc: false
20
+ class Alien
21
+ binding.repl.rib prompt: ">> ", result_prompt: "# => "
22
22
  end
23
23
  ```
24
24
 
25
- __rib__
26
-
27
- [rib](https://github.com/godfat/rib) is a little less well known ruby console that binding.repl
28
- supports since v0.8.0. it can be configured to change the prompt and the prefix inserted before
29
- a return value.
25
+ _ripl_
30
26
 
31
- rib can be started with options that are forwarded to
32
- [Rib.anchor()](http://rdoc.info/github/godfat/rib/Rib/Anchor/Imp#anchor-instance_method) (API docs).
27
+ [ripl](https://github.com/cldwalker/ripl) supports (some) runtime configuration. <br>
28
+ I couldn't find API docs for `Ripl.start(..)`, so I recommend checking out the github
29
+ page to learn more.
33
30
 
34
31
  ```ruby
35
- class Foo
36
- binding.repl.rib prompt: ">> ", result_prompt: "# => "
32
+ class Sink
33
+ binding.repl.ripl riplrc: false
37
34
  end
38
35
  ```
39
36
 
40
- __irb__
37
+ _note about irb_
41
38
 
42
- binding.repl doesn't implement any runtime options for IRB.
39
+ binding.repl doesn't implement runtime options for IRB because it wasn't immediately obvious
40
+ how IRB is configured at runtime (it looks like `IRB.conf` might be used)
41
+
42
+ ```ruby
43
+ class Car
44
+ binding.repl.irb
45
+ end
46
+ ```
@@ -1,7 +1,15 @@
1
1
  class BindingRepl
2
2
  LOOKUP = {}
3
3
  LOOKUP.default = [proc { true }, proc { :'binding.repl.unknown_console' }]
4
- singleton_class.class_eval { attr_accessor :auto_order }
4
+ DEFAULT_AUTO_ORDER = ["pry", "ripl", "rib", "irb"].freeze
5
+
6
+ def self.auto_order=(list)
7
+ @auto_order = list
8
+ end
9
+
10
+ def self.auto_order
11
+ @auto_order or BindingRepl::ENV.auto_order or DEFAULT_AUTO_ORDER
12
+ end
5
13
 
6
14
  #
7
15
  # returns true when binding.repl is disabled.
@@ -74,10 +82,10 @@ class BindingRepl
74
82
  # returns an instance of {BindingRepl::ExitValue} when the repl has exited.
75
83
  #
76
84
  def auto
77
- consoles = Binding.repl.auto_order
85
+ consoles = BindingRepl.auto_order
78
86
  value = run_any_console(consoles)
79
87
  if consoles.empty?
80
- raise LoadError, "no consoles available to load. Binding.repl.auto_order is empty"
88
+ raise LoadError, "no consoles available to load. BindingRepl.auto_order is empty"
81
89
  elsif value.nil?
82
90
  consoles_str = consoles.join(", ")
83
91
  raise LoadError, "attempts to require any of the following consoles failed: #{consoles_str}"
@@ -101,7 +109,7 @@ private
101
109
 
102
110
  def run_console(console, options = {})
103
111
  console = console.to_s
104
- if Binding.repl.disabled?
112
+ if BindingRepl.disabled?
105
113
  value = BindingRepl::ExitValue.disabled_value
106
114
  else
107
115
  initializer, runner = @lookup[console]
@@ -115,7 +123,6 @@ private
115
123
  return BindingRepl::ExitValue.new(value)
116
124
  end
117
125
  end
118
-
119
126
  require_relative "binding.repl/core_ext/binding"
120
127
  require_relative "binding.repl/env"
121
128
  require_relative "binding.repl/exit_value"
@@ -124,4 +131,3 @@ require_relative "binding.repl/console/pry"
124
131
  require_relative "binding.repl/console/irb"
125
132
  require_relative "binding.repl/console/ripl"
126
133
  require_relative "binding.repl/console/rib"
127
- BindingRepl.auto_order = BindingRepl::ENV.auto_order
@@ -8,4 +8,4 @@ runner = lambda do |binding, options|
8
8
  trap("SIGINT") { irb.signal_handle }
9
9
  catch(:IRB_EXIT) { irb.eval_input }
10
10
  end
11
- Binding.repl.add :irb, initializer, runner
11
+ BindingRepl.add :irb, initializer, runner
@@ -4,4 +4,4 @@ end
4
4
  runner = lambda do |binding, options|
5
5
  binding.pry(options)
6
6
  end
7
- Binding.repl.add :pry, initializer, runner
7
+ BindingRepl.add :pry, initializer, runner
@@ -5,4 +5,4 @@ end
5
5
  runner = lambda do |binding, options|
6
6
  Rib.anchor binding, options
7
7
  end
8
- Binding.repl.add :rib, initializer, runner
8
+ BindingRepl.add :rib, initializer, runner
@@ -4,4 +4,4 @@ end
4
4
  runner = lambda do |binding, options|
5
5
  Ripl.start options.merge(binding: binding)
6
6
  end
7
- Binding.repl.add :ripl, initializer, runner
7
+ BindingRepl.add :ripl, initializer, runner
@@ -4,7 +4,7 @@ class Binding
4
4
  end
5
5
 
6
6
  def repl
7
- Binding.repl.new(self)
7
+ BindingRepl.new(self)
8
8
  end
9
9
 
10
10
  def repl!
@@ -1,15 +1,10 @@
1
1
  module BindingRepl::ENV
2
2
  @env = ::ENV
3
- DEFAULT_AUTO_ORDER = ["pry", "ripl", "rib", "irb"]
4
3
  DELIMITER_REGEXP = /[:,]/
5
4
 
6
- module_function
7
- def enable_rc_file?
8
- @env['disable_rc'] != 'true' and @env['disable_rc'] != '1'
9
- end
10
-
11
5
  def auto_order
12
- env_order = @env['auto_order'].to_s.split(DELIMITER_REGEXP)
13
- env_order.empty? ? DEFAULT_AUTO_ORDER : env_order
6
+ list = @env['auto_order'].to_s.split(DELIMITER_REGEXP)
7
+ list.empty? ? nil : list
14
8
  end
9
+ module_function :auto_order
15
10
  end
@@ -1,5 +1,5 @@
1
1
  class BindingRepl
2
- VERSION = "1.0.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  def self.version
4
4
  VERSION
5
5
  end
@@ -26,7 +26,7 @@ class BindingReplAutoTest < MiniTest::Test
26
26
  def test_no_matches_on_auto
27
27
  BindingRepl.auto_order = []
28
28
  e = assert_raises(LoadError) {binding.repl.auto}
29
- assert_equal "no consoles available to load. Binding.repl.auto_order is empty", e.message
29
+ assert_equal "no consoles available to load. BindingRepl.auto_order is empty", e.message
30
30
  end
31
31
 
32
32
  def test_no_requireable_console_on_auto
@@ -1,26 +1,12 @@
1
1
  require_relative "setup"
2
2
  class BindingReplEnvTest < MiniTest::Test
3
3
  def teardown
4
- ENV.delete "disable_rc"
5
4
  ENV.delete "auto_order"
6
5
  end
7
6
 
8
- def test_default_of_enable_rc_file?
9
- assert_equal true, BindingRepl::ENV.enable_rc_file?
10
- end
11
-
12
- def test_disable_of_rc_file_with_true
13
- ENV["disable_rc"] = 'true'
14
- assert_equal false, BindingRepl::ENV.enable_rc_file?
15
- end
16
-
17
- def test_disable_of_rc_file_with_one
18
- ENV["disable_rc"] = '1'
19
- assert_equal false, BindingRepl::ENV.enable_rc_file?
20
- end
21
-
22
- def test_default_of_auto_order
23
- assert_equal BindingRepl::ENV::DEFAULT_AUTO_ORDER, BindingRepl.auto_order
7
+ def test_unset_auto_order_shell_var
8
+ ENV["auto_order"] = nil
9
+ assert_equal nil, BindingRepl::ENV.auto_order
24
10
  end
25
11
 
26
12
  def test_auto_order_defined_by_shell
@@ -0,0 +1,24 @@
1
+ require_relative "setup"
2
+ class BindingReplTest < MiniTest::Test
3
+ def setup
4
+ @before = BindingRepl.auto_order.dup
5
+ end
6
+
7
+ def teardown
8
+ BindingRepl.auto_order = @before
9
+ end
10
+
11
+ def test_default_return_value_of_auto_order
12
+ assert_equal BindingRepl::DEFAULT_AUTO_ORDER, BindingRepl.auto_order
13
+ end
14
+
15
+ def test_set_of_new_auto_order
16
+ BindingRepl.auto_order = ["a", "b"]
17
+ assert_equal ["a", "b"], BindingRepl.auto_order
18
+ end
19
+
20
+ def test_set_of_nil_on_auto_order
21
+ BindingRepl.auto_order = nil
22
+ assert_equal BindingRepl::DEFAULT_AUTO_ORDER, BindingRepl.auto_order
23
+ end
24
+ end
metadata CHANGED
@@ -1,26 +1,30 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: binding.repl
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Public Domain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-09 00:00:00.000000000 Z
11
+
12
+ date: 2014-02-10 00:00:00 Z
12
13
  dependencies: []
14
+
13
15
  description: binding.repl can start a number of different ruby consoles at runtime
14
- email:
16
+ email:
15
17
  - robert@flowof.info
16
18
  executables: []
19
+
17
20
  extensions: []
21
+
18
22
  extra_rdoc_files: []
19
- files:
20
- - ".binding.repl.rc"
21
- - ".gitignore"
22
- - ".pryrc"
23
- - ".travis.yml"
23
+
24
+ files:
25
+ - .gitignore
26
+ - .pryrc
27
+ - .travis.yml
24
28
  - ChangeLog.txt
25
29
  - Gemfile
26
30
  - README.md
@@ -46,6 +50,7 @@ files:
46
50
  - test/binding_repl_pry_test.rb
47
51
  - test/binding_repl_rib_test.rb
48
52
  - test/binding_repl_ripl_test.rb
53
+ - test/binding_repl_test.rb
49
54
  - test/binding_test.rb
50
55
  - test/isolation/lazy_irb_require_test.rb
51
56
  - test/isolation/lazy_pry_require_test.rb
@@ -54,39 +59,40 @@ files:
54
59
  - test/setup.rb
55
60
  - test/support/binding.repl/rspec_mocks.rb
56
61
  homepage: https://github.com/robgleeson/binding.repl
57
- licenses:
62
+ licenses:
58
63
  - Public Domain
59
64
  metadata: {}
60
- post_install_message: |2
61
- == binding.repl v1.0.0
62
- ChangeLog.txt:
63
- https://github.com/robgleeson/binding.repl/blob/v1.0.0/ChangeLog.txt
65
+
66
+ post_install_message: " == binding.repl v1.0.1\n ChangeLog.txt:\n https://github.com/robgleeson/binding.repl/blob/v1.0.1/ChangeLog.txt\n"
64
67
  rdoc_options: []
65
- require_paths:
68
+
69
+ require_paths:
66
70
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
68
- requirements:
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
69
73
  - - ">="
70
- - !ruby/object:Gem::Version
74
+ - !ruby/object:Gem::Version
71
75
  version: 1.9.2
72
- required_rubygems_version: !ruby/object:Gem::Requirement
73
- requirements:
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
74
78
  - - ">="
75
- - !ruby/object:Gem::Version
76
- version: '0'
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
77
81
  requirements: []
82
+
78
83
  rubyforge_project:
79
84
  rubygems_version: 2.2.2
80
85
  signing_key:
81
86
  specification_version: 4
82
87
  summary: binding.repl can start a number of different ruby consoles at runtime
83
- test_files:
88
+ test_files:
84
89
  - test/binding_repl_auto_test.rb
85
90
  - test/binding_repl_env_test.rb
86
91
  - test/binding_repl_irb_test.rb
87
92
  - test/binding_repl_pry_test.rb
88
93
  - test/binding_repl_rib_test.rb
89
94
  - test/binding_repl_ripl_test.rb
95
+ - test/binding_repl_test.rb
90
96
  - test/binding_test.rb
91
97
  - test/isolation/lazy_irb_require_test.rb
92
98
  - test/isolation/lazy_pry_require_test.rb
@@ -94,3 +100,4 @@ test_files:
94
100
  - test/isolation/lazy_ripl_require_test.rb
95
101
  - test/setup.rb
96
102
  - test/support/binding.repl/rspec_mocks.rb
103
+ has_rdoc:
@@ -1,3 +0,0 @@
1
- # sample file.
2
- [auto]
3
- order = ["irb", "rib", "pry", "ripl"]