rib 1.3.1 → 1.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: e2cc6e3966230aac382f90352549a7545c8e27ff
4
- data.tar.gz: 6bb97f019cc41dffbc900fa2d5aa1f44024d65a8
3
+ metadata.gz: 2179819cb0fd07bfd02d5fff9313d0b72a6d3bfe
4
+ data.tar.gz: cb65c6407da421a2a6013bce9d3de585a73175f4
5
5
  SHA512:
6
- metadata.gz: 0a0519f630b28351cf2d6f636c976eea2d904b1703fbf63c9ad1824944cb204dd5490f39d7d3ebffa1ffe81e994324135e8c5176eb3f905172d259bb3902a76b
7
- data.tar.gz: 87d41ae852dfb60039bd785fcc9b141fd01cc1bfc304f5b2047891d29ab04ccc05d989075cbec8068b6b35c1a2e7c6bf2a0013c489290b4322d9c132ce639e20
6
+ metadata.gz: 2d3e07839f36a11e48295a8b6b4fc605941acf1ad2dd0cfdc37b33d873393e287a3e62bcc69eae106ea8e5623c1a2250d01d8d367658adc629cb8947865a260b
7
+ data.tar.gz: b183b7adae908696abf296133f2cce5cecd21fa8a6cd7dffe0cc62fffb239e887ad8ba2edd8082b3aeccebe0cf7fa76352aaba4e25e5bbea579802cbf86c0d0d
data/.travis.yml CHANGED
@@ -12,3 +12,7 @@ before_install:
12
12
  - rvm use --install $TRAVIS_RUBY_VERSION --binary --latest
13
13
  install: 'gem install bundler; bundle install --retry=3'
14
14
  script: 'ruby -r bundler/setup -S rake test'
15
+
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: rbx
data/CHANGES.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGES
2
2
 
3
+ ## Rib 1.4.0 -- 2016-11-11
4
+
5
+ * Search Rib home by directories rather than config/history file.
6
+ * Respect prefix option for detecting Rib home.
7
+ * Update help message for `-n`, which won't load any config.
8
+ * Change `Rib.config[:config]` to `Rib.config_path`.
9
+ * [app/rails] Fix loading boot file when using prefix option.
10
+ * [app/auto] Fix two variable shadowing warnings.
11
+
3
12
  ## Rib 1.3.1 -- 2016-11-03
4
13
 
5
14
  * [core/strip_backtrace], [more/color] No longer show `./` for current path.
data/README.md CHANGED
@@ -7,6 +7,7 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
7
7
  * [github](https://github.com/godfat/rib)
8
8
  * [rubygems](https://rubygems.org/gems/rib)
9
9
  * [rdoc](http://rdoc.info/github/godfat/rib)
10
+ * [issues](https://github.com/godfat/rib/issues) (feel free to ask for support)
10
11
 
11
12
  ## DESCRIPTION:
12
13
 
@@ -87,12 +88,15 @@ As a fully featured app console (yes, some commands could be used together)
87
88
 
88
89
  rib all auto # or `rib auto all`, the order doesn't really matter
89
90
 
91
+ #### Customization
92
+
90
93
  You can customize Rib's behaviour by setting a config file located at
91
- `~/.rib/config.rb` or `~/.config/rib/config.rb`, or `$RIB_HOME/config.rb` by
92
- setting `$RIB_HOME` environment variable. Since it's merely a Ruby script
93
- which would be loaded into memory before launching Rib shell session, You can
94
- put any customization or monkey patch there. Personally, I use all plugins
95
- provided by Rib.
94
+ `$RIB_HOME/config.rb`, or `./.rib/config.rb`, or `~/.rib/config.rb`, or
95
+ `~/.config/rib/config.rb`, searched by respected order. The default
96
+ would be `~/.rib/config.rb`. Since it's merely a Ruby script which would
97
+ be loaded into memory before launching Rib shell session, You can put any
98
+ customization or monkey patch there. Personally, I use all plugins provided
99
+ by Rib.
96
100
 
97
101
  My Personal [~/.config/rib/config](https://github.com/godfat/dev-tool/blob/master/.config/rib/config.rb)
98
102
 
@@ -132,12 +136,77 @@ file. To see a list of overridable API, please read [api.rb][]
132
136
 
133
137
  [api.rb]: https://github.com/godfat/rib/blob/master/lib/rib/api.rb
134
138
 
139
+ #### Rib home and history file
140
+
141
+ Rib home is used to store a config file and a history file, which is
142
+ searched in this order:
143
+
144
+ * $RIB_HOME
145
+ * ./.rib
146
+ * ~/.rib
147
+ * ~/.config/rib
148
+
149
+ Rib would stop searching whenever the directory is found. If none could be
150
+ found, the default would be:
151
+
152
+ * ~/.rib
153
+
154
+ So the default history file would be located at `~/.rib/history.rb`.
155
+
156
+ #### Project config and history
157
+
158
+ Since `./.rib` would be searched before `~/.rib`, you could create project
159
+ level config at the project directory, and the history would also be
160
+ separated from each other, located at the respected `./.rib/history.rb`.
161
+
162
+ To do this, you don't really have to create a project config. Creating an
163
+ empty directory for Rib home at the project directory would also work.
164
+
165
+ #### Project directory and command line options
166
+
167
+ You could set the project directory by using `-p, --prefix` command line
168
+ option. So consider this:
169
+
170
+ cd ~/project
171
+ rib auto
172
+
173
+ Would work the same as:
174
+
175
+ cd /tmp
176
+ rib -p ~/project auto
177
+
178
+ And the project config and history would be located at `~/project/.rib`.
179
+
180
+ To check for more command line options, run `rib -h`:
181
+
182
+ ```
183
+ Usage: rib [ruby OPTIONS] [rib OPTIONS] [rib COMMANDS]
184
+ ruby options:
185
+ -e, --eval LINE Evaluate a LINE of code
186
+ -d, --debug Set debugging flags (set $DEBUG to true)
187
+ -w, --warn Turn warnings on (set $-w and $VERBOSE to true)
188
+ -I, --include PATH Specify $LOAD_PATH (may be used more than once)
189
+ -r, --require LIBRARY Require the library, before executing your script
190
+ rib options:
191
+ -c, --config FILE Load config from FILE
192
+ -p, --prefix PATH Prefix to locate the app. Default to .
193
+ -n, --no-config Suppress loading ~/.config/rib/config.rb
194
+ -h, --help Print this message
195
+ -v, --version Print the version
196
+ rib commands:
197
+ min Run the minimum essence
198
+ auto Run as Rails or Ramaze console (auto-detect)
199
+ all Load all recommended plugins
200
+ rails Run as Rails console
201
+ rack Run as Rack console
202
+ ramaze Run as Ramaze console
203
+ ```
204
+
135
205
  #### Basic configuration
136
206
 
137
207
  Rib.config | Functionality
138
208
  -------------------------- | -------------------------------------------------
139
209
  ENV['RIB_HOME'] | Specify where Rib should store config and history
140
- Rib.config[:config] | The path where config should be located
141
210
  Rib.config[:name] | The name of this shell
142
211
  Rib.config[:result_prompt] | Default is "=>"
143
212
  Rib.config[:prompt] | Default is ">>"
@@ -149,7 +218,7 @@ Rib.config[:exit] | Commands to exit, default [nil] # control+d
149
218
  Rib.config | Functionality
150
219
  ------------------------------ | ---------------------------------------------
151
220
  Rib.config[:completion] | Completion: Bond config
152
- Rib.config[:history_file] | Default is "~/.rib/config/history.rb"
221
+ Rib.config[:history_file] | Default is "~/.rib/history.rb"
153
222
  Rib.config[:history_size] | Default is 500
154
223
  Rib.config[:color] | A hash of Class => :color mapping
155
224
  Rib.config[:autoindent_spaces] | How to indent? Default is two spaces: ' '
data/lib/rib/app/auto.rb CHANGED
@@ -3,12 +3,10 @@ module Rib; end
3
3
  module Rib::Auto
4
4
  module_function
5
5
  def load
6
- app, name = %w[ramaze rails rack].find{ |name|
7
- require "rib/app/#{name}"
8
- app = Rib.const_get(name.capitalize)
9
- if app.send("#{name}?")
10
- break app, name
11
- end
6
+ app, name = %w[ramaze rails rack].find{ |n|
7
+ require "rib/app/#{n}"
8
+ a = Rib.const_get(n.capitalize)
9
+ break a, n if a.public_send("#{n}?")
12
10
  }
13
11
 
14
12
  if app
data/lib/rib/app/rails.rb CHANGED
@@ -111,6 +111,6 @@ module Rib::Rails
111
111
  end
112
112
 
113
113
  def path_for file
114
- "#{Rib.config[:prefix]}/config/#{file}"
114
+ File.expand_path("#{Rib.config[:prefix]}/config/#{file}")
115
115
  end
116
116
  end
data/lib/rib/runner.rb CHANGED
@@ -5,28 +5,28 @@ module Rib::Runner
5
5
  module_function
6
6
  def options
7
7
  @options ||=
8
- [['ruby options:' , '' ],
9
- ['-e, --eval LINE' ,
10
- 'Evaluate a LINE of code' ],
8
+ [['ruby options:' , '' ],
9
+ ['-e, --eval LINE' ,
10
+ 'Evaluate a LINE of code' ],
11
11
 
12
- ['-d, --debug' ,
13
- 'Set debugging flags (set $DEBUG to true)' ],
12
+ ['-d, --debug' ,
13
+ 'Set debugging flags (set $DEBUG to true)' ],
14
14
 
15
- ['-w, --warn' ,
16
- 'Turn warnings on (set $-w and $VERBOSE to true)' ],
15
+ ['-w, --warn' ,
16
+ 'Turn warnings on (set $-w and $VERBOSE to true)' ],
17
17
 
18
- ['-I, --include PATH' ,
19
- 'Specify $LOAD_PATH (may be used more than once)' ],
18
+ ['-I, --include PATH' ,
19
+ 'Specify $LOAD_PATH (may be used more than once)' ],
20
20
 
21
- ['-r, --require LIBRARY' ,
22
- 'Require the library, before executing your script' ],
21
+ ['-r, --require LIBRARY' ,
22
+ 'Require the library, before executing your script' ],
23
23
 
24
- ['rib options:' , '' ],
25
- ['-c, --config FILE', 'Load config from FILE' ],
26
- ['-p, --prefix PATH', 'Prefix to locate the app. Default to .' ],
27
- ['-n, --no-config' , 'Suppress loading ~/.config/rib/config.rb'],
28
- ['-h, --help' , 'Print this message' ],
29
- ['-v, --version' , 'Print the version' ]] +
24
+ ['rib options:' , '' ],
25
+ ['-c, --config FILE', 'Load config from FILE' ],
26
+ ['-p, --prefix PATH', 'Prefix to locate the app. Default to .'],
27
+ ['-n, --no-config' , 'Suppress loading any config' ],
28
+ ['-h, --help' , 'Print this message' ],
29
+ ['-v, --version' , 'Print the version' ]] +
30
30
 
31
31
  [['rib commands:' , '']] + commands
32
32
  end
@@ -120,13 +120,13 @@ module Rib::Runner
120
120
  require($1 || argv.shift)
121
121
 
122
122
  when /^-c=?(.+)?/, /^--config=?(.+)?/
123
- Rib.config[:config] = $1 || argv.shift
123
+ Rib.config_path = $1 || argv.shift
124
124
 
125
125
  when /^-p=?(.+)?/, /^--prefix=?(.+)?/
126
126
  Rib.config[:prefix] = $1 || argv.shift
127
127
 
128
128
  when /^-n/, '--no-config'
129
- Rib.config.delete(:config)
129
+ Rib.config_path = Rib::Skip
130
130
  parse_next(argv, arg)
131
131
 
132
132
  when /^-h/, '--help'
data/lib/rib/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rib
3
- VERSION = '1.3.1'
3
+ VERSION = '1.4.0'
4
4
  end
data/lib/rib.rb CHANGED
@@ -11,9 +11,7 @@ module Rib
11
11
  #
12
12
  # @api public
13
13
  def config
14
- @config ||= {:name => 'rib',
15
- :config => File.join(home, 'config.rb'),
16
- :prefix => '.'}
14
+ @config ||= {:name => 'rib', :prefix => '.'}
17
15
  end
18
16
 
19
17
  # All shells in the memory
@@ -33,13 +31,11 @@ module Rib
33
31
  #
34
32
  # @api public
35
33
  def home
36
- ENV['RIB_HOME'] ||= begin
37
- ['./.rib', '~/.rib', '~/.config/rib'].find{ |path|
38
- p = File.expand_path(path)
39
- File.exist?(File.join(p, 'config.rb')) ||
40
- File.exist?(File.join(p, 'history.rb'))
34
+ ENV['RIB_HOME'] ||= File.expand_path(
35
+ ["#{config[:prefix]}/.rib", '~/.rib', '~/.config/rib'].find{ |path|
36
+ File.exist?(File.expand_path(path))
41
37
  } || '~/.rib'
42
- end
38
+ )
43
39
  end
44
40
 
45
41
  # Convenient shell accessor, which would just give you current last shell
@@ -49,7 +45,7 @@ module Rib
49
45
  # @api public
50
46
  def shell
51
47
  shells.last || begin
52
- require_config if config_path
48
+ require_config if config_path && config_path != Skip
53
49
  (shells << Shell.new(config)).last
54
50
  end
55
51
  end
@@ -59,7 +55,7 @@ module Rib
59
55
  #
60
56
  # @api public
61
57
  def plugins
62
- Shell.ancestors[1..-1].select{ |a| a.singleton_class < Plugin }
58
+ Shell.ancestors.drop(1).select{ |a| a.singleton_class < Plugin }
63
59
  end
64
60
 
65
61
  # Convenient way to disable all plugins in the memory.
@@ -85,29 +81,25 @@ module Rib
85
81
  #
86
82
  # @api public
87
83
  def require_config
88
- return unless config_path
89
- result = require(config_path)
84
+ result = require(config_path) if File.exist?(config_path)
90
85
  Rib.say("Config loaded from: #{config_path}") if $VERBOSE && result
91
86
  result
92
87
  rescue StandardError, LoadError, SyntaxError => e
93
- Rib.warn("Error loading #{config[:config]}\n" \
88
+ Rib.warn("Error loading #{config_path}\n" \
94
89
  " #{Rib::API.format_error(e)}")
95
90
  end
96
91
 
97
- # The config path where Rib tries to load upon Rib.shell or
98
- # Rib.require_config. It is depending on where Rib.home was discovered
99
- # if no specific config path was specified via -c or --config command
100
- # line option. See also Rib.config.
92
+ # The config path where Rib tries to load upon Rib.shell.
93
+ # It is depending on where Rib.home was discovered if
94
+ # no specific config path was specified via -c or --config command
101
95
  #
102
96
  # @api public
103
97
  def config_path
104
- return nil unless config[:config]
105
- path = File.expand_path(config[:config])
106
- if File.exist?(path)
107
- path
108
- else
109
- nil
110
- end
98
+ @config_path ||= File.join(home, 'config.rb')
99
+ end
100
+
101
+ def config_path= new_path
102
+ @config_path = new_path
111
103
  end
112
104
 
113
105
  # Say (print to $stdout, with colors in the future, maybe)
data/rib.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rib 1.3.1 ruby lib
2
+ # stub: rib 1.4.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rib".freeze
6
- s.version = "1.3.1"
6
+ s.version = "1.4.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Lin Jen-Shin (godfat)".freeze]
11
- s.date = "2016-11-03"
11
+ s.date = "2016-11-11"
12
12
  s.description = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell\n\nRib is based on the design of [ripl][] and the work of [ripl-rc][], some of\nthe features are also inspired by [pry][]. The aim of Rib is to be fully\nfeatured and yet very easy to opt-out or opt-in other features. It shall\nbe simple, lightweight and modular so that everyone could customize Rib.\n\n[ripl]: https://github.com/cldwalker/ripl\n[ripl-rc]: https://github.com/godfat/ripl-rc\n[pry]: https://github.com/pry/pry".freeze
13
13
  s.email = ["godfat (XD) godfat.org".freeze]
14
14
  s.executables = [
@@ -89,7 +89,7 @@ Gem::Specification.new do |s|
89
89
  "test/test_shell.rb".freeze]
90
90
  s.homepage = "https://github.com/godfat/rib".freeze
91
91
  s.licenses = ["Apache License 2.0".freeze]
92
- s.rubygems_version = "2.6.7".freeze
92
+ s.rubygems_version = "2.6.8".freeze
93
93
  s.summary = "Ruby-Interactive-ruBy -- Yet another interactive Ruby shell".freeze
94
94
  s.test_files = [
95
95
  "test/core/test_completion.rb".freeze,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin Jen-Shin (godfat)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-03 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |-
14
14
  Ruby-Interactive-ruBy -- Yet another interactive Ruby shell
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.7
124
+ rubygems_version: 2.6.8
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Ruby-Interactive-ruBy -- Yet another interactive Ruby shell