ripl-rc 0.1.1 → 0.1.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.
data/CHANGES CHANGED
@@ -1,5 +1,13 @@
1
1
  = ripl-rc changes history
2
2
 
3
+ == ripl-rc 0.1.2 -- 2011-02-25
4
+
5
+ * [ rc] rearranged require order
6
+ * [ plugin] added anchor, like pry. usage: Ripl.anchor(binding) # or obj
7
+ * [ plugin] added multiline, which works better with anchor
8
+ * [ plugin] added mkdir_history, which tries to mkdir -p on history directory
9
+ * [strip_backtrace] fix functionality for custom name (anchor)
10
+
3
11
  == ripl-rc 0.1.1 -- 2011-02-24
4
12
 
5
13
  * [ plugin] added strip_backtrace
data/README.rdoc CHANGED
@@ -1,6 +1,5 @@
1
1
  = ripl-rc 0.1.1
2
2
  by Lin Jen-Shin (godfat[http://godfat.org])
3
- godfat (XD) godfat.org
4
3
 
5
4
  == LINKS:
6
5
 
@@ -13,11 +12,23 @@ ripl plugins collection
13
12
 
14
13
  == FEATURES:
15
14
 
15
+ # when session ends
16
16
  * require 'ripl/rc/squeeze_history'
17
+ * require 'ripl/rc/mkdir_history'
17
18
  * require 'ripl/rc/ctrld_newline'
18
- * require 'ripl/rc/eat_whites'
19
- * require 'ripl/rc/color'
19
+
20
+ # result format
20
21
  * require 'ripl/rc/strip_backtrace'
22
+ * require 'ripl/rc/color'
23
+
24
+ # input modification
25
+ * require 'ripl/rc/multiline' # work better with anchor...
26
+ * require 'ripl/rc/eat_whites'
27
+
28
+ # speical tool
29
+ * require 'ripl/rc/anchor' # pry like, use: Ripl.anchor(binding) # or obj
30
+
31
+ # for lazies
21
32
  * require 'ripl/rc' # for all of above
22
33
 
23
34
  == REQUIREMENTS:
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ ($LOAD_PATH << File.expand_path("#{File.dirname(__FILE__)}/lib")).uniq!
3
+
2
4
  gemspec = "#{File.dirname(__FILE__)}/ripl-rc.gemspec"
3
5
 
4
6
  if File.exist?(gemspec) && File.read(gemspec).strip != ''
@@ -19,25 +21,30 @@ if File.exist?(gemspec) && File.read(gemspec).strip != ''
19
21
 
20
22
  desc "Create tag #{b.version_tag} and build and push " \
21
23
  "#{b.name}-#{b.version}.gem to Rubygems"
22
- task :release => [:check_version, :gemspec] do
24
+ task :release => [:gemspec, :check_version] do
23
25
  b.release_gem
24
26
  end
25
27
 
26
28
  task :check_version do
27
29
  if ENV['VERSION'].nil?
28
- puts("\x1b[33mPlease provide " \
29
- "\x1b[36mVERSION\x1b[33m=\x1b[36mx.y.z\x1b[m")
30
+ puts("\x1b[32mPlease provide " \
31
+ "\x1b[36mVERSION\x1b[32m=\x1b[36mx.y.z\x1b[m")
30
32
  exit(1)
31
33
 
32
34
  elsif ENV['VERSION'] != b.version.to_s
33
- puts("\x1b[33mYou gave \x1b[36mVERSION\x1b[33m=\x1b[36m#{b.version} " \
34
- "\x1b[33mbut got\n \x1b[36m" \
35
- "VERSION\x1b[33m=\x1b[36m#{ENV['VERSION']}\x1b[m")
35
+ puts("\x1b[32mYou gave \x1b[36mVERSION\x1b[32m=\x1b[36m#{b.version} " \
36
+ "\x1b[32mbut got\n \x1b[36m" \
37
+ "VERSION\x1b[32m=\x1b[36m#{ENV['VERSION']}\x1b[m")
36
38
  exit(2)
37
39
  end
38
40
  end
39
41
  end
40
42
 
43
+ desc 'Generate rdoc'
44
+ task :rdoc do
45
+ sh('rdoc --output rdoc --main README.rdoc')
46
+ end
47
+
41
48
  desc 'Run tests'
42
49
  task :test do
43
50
  sh("#{Gem.ruby} -I lib -S bacon test/test_*.rb")
@@ -92,16 +99,16 @@ task :gemspec do
92
99
  s.authors = ['Lin Jen-Shin (godfat)']
93
100
  s.email = ['godfat (XD) godfat.org']
94
101
  s.homepage = "http://github.com/godfat/#{s.name}"
95
- s.summary = File.read("#{File.dirname(__FILE__)}/README").match(
96
- /== DESCRIPTION:\n\n(.+)?\n\n== FEATURES:/m)[1]
102
+ s.summary = File.read("#{File.dirname(__FILE__)}/README.rdoc").
103
+ match(/== DESCRIPTION:\n\n(.+)?\n\n== FEATURES:/m)[1]
97
104
  s.description = s.summary
98
105
 
99
106
  s.date = Time.now.strftime('%Y-%m-%d')
100
107
  s.rubygems_version = Gem::VERSION
101
108
  s.files = gem_files
102
109
  s.test_files = gem_files.grep(/test_.+?\.rb$/)
103
- s.extra_rdoc_files = ['CHANGES', 'README', "#{s.name}.gemspec"]
104
- s.rdoc_options = ['--main', 'README']
110
+ s.extra_rdoc_files = []
111
+ s.rdoc_options = ['--main', 'README.rdoc']
105
112
  s.require_paths = ['lib']
106
113
  end.to_ruby
107
114
  }
data/TODO CHANGED
@@ -1,5 +1,4 @@
1
1
  = ripl-rc todo list
2
2
 
3
3
  * tests for each plugin
4
- * refactoring color
5
4
  * doc
@@ -0,0 +1,59 @@
1
+
2
+ require 'ripl'
3
+
4
+ module Ripl::Rc; end
5
+ module Ripl::Rc::Anchor
6
+ def loop_eval(str)
7
+ case obj_or_binding = (config[:rc_anchor] ||= []).last
8
+ when NilClass
9
+ super
10
+
11
+ when Binding
12
+ @binding = obj_or_binding
13
+ super
14
+
15
+ else
16
+ obj_or_binding.instance_eval(str, "(#{@name})", @line)
17
+ end
18
+ end
19
+
20
+ def prompt
21
+ if Ripl::Rc.const_defined?(:Color) && kind_of?(Ripl::Rc::Color) &&
22
+ obj_or_binding = (config[:rc_anchor] ||= []).last
23
+
24
+ super.sub(obj_or_binding.inspect, format_result(obj_or_binding))
25
+ else
26
+ super
27
+ end
28
+ end
29
+
30
+ # if the object is the same, then we're exiting from an anchor,
31
+ # so don't print anything.
32
+ def print_result result
33
+ super unless result.object_id == Ripl.config[:rc_anchor_last].object_id
34
+ end
35
+
36
+ module Imp
37
+ def anchor obj_or_binding
38
+ if Ripl.config[:rc_init].nil?
39
+ Ripl::Runner.load_rc(Ripl.config[:riplrc])
40
+ Ripl.config[:rc_init] = true
41
+ end
42
+
43
+ (Ripl.config[:rc_anchor] ||= []) << obj_or_binding
44
+ Ripl::Shell.create(Ripl.config.merge(
45
+ :name => obj_or_binding.inspect,
46
+ :prompt => obj_or_binding.inspect +
47
+ "(#{Ripl.config[:rc_anchor].size})" +
48
+ Ripl.config[:prompt])).loop
49
+
50
+ # stores to check if we're exiting from an anchor
51
+ Ripl.config[:rc_anchor_last] = Ripl.config[:rc_anchor].pop
52
+ end
53
+ end
54
+ end
55
+
56
+ Ripl::Shell.include(Ripl::Rc::Anchor)
57
+
58
+ Ripl.extend(Ripl::Rc::Anchor::Imp)
59
+ Ripl.config[:prompt] ||= Ripl::Shell::OPTIONS[:prompt]
@@ -0,0 +1,14 @@
1
+
2
+ require 'ripl'
3
+
4
+ module Ripl::Rc; end
5
+ module Ripl::Rc::MkdirHistory
6
+ # ensure path existed
7
+ def write_history
8
+ require 'fileutils'
9
+ FileUtils.mkdir_p(File.dirname(history_file))
10
+ super
11
+ end
12
+ end
13
+
14
+ Ripl::Shell.include(Ripl::Rc::MkdirHistory)
@@ -0,0 +1,70 @@
1
+
2
+ require 'ripl'
3
+
4
+ # from https://github.com/janlelis/ripl-multi_line
5
+ module Ripl::Rc; end
6
+ module Ripl::Rc::Multiline
7
+ ERROR_REGEXP = /#{
8
+ [ %q%unexpected \$end%,
9
+ %q%unterminated [a-z]+ meets end of file%,
10
+ # rubinius
11
+ %q%expecting '\\n' or ';'%,
12
+ %q%missing 'end'%,
13
+ %q%expecting '}'%,
14
+ # jruby
15
+ %q%syntax error, unexpected end-of-file%,
16
+ ]*'|' }/
17
+
18
+ def before_loop
19
+ @rc_multiline_buffer = []
20
+ super
21
+ end
22
+
23
+ def prompt
24
+ if @rc_multiline_buffer.empty?
25
+ super
26
+ else
27
+ "#{' '*(@prompt.size-2)}| "
28
+ end
29
+ end
30
+
31
+ def loop_once
32
+ catch(:rc_multiline_cont) do
33
+ super
34
+ @rc_multiline_buffer.clear
35
+ end
36
+ end
37
+
38
+ def print_eval_error(e)
39
+ if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP
40
+ @rc_multiline_buffer << @input
41
+ throw :rc_multiline_cont
42
+ else
43
+ super
44
+ end
45
+ end
46
+
47
+ def loop_eval(input)
48
+ if @rc_multiline_buffer.empty?
49
+ super
50
+ else
51
+ super "#{@rc_multiline_buffer.join("\n")}\n#{input}"
52
+ end
53
+ end
54
+
55
+ def handle_interrupt
56
+ if @rc_multiline_buffer.empty?
57
+ super
58
+ else
59
+ line = @rc_multiline_buffer.pop
60
+ if @rc_multiline_buffer.empty?
61
+ super
62
+ else
63
+ puts "[removed this line: #{line}]"
64
+ throw :rc_multiline_cont
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ Ripl::Shell.include(Ripl::Rc::Multiline)
@@ -19,6 +19,10 @@ module Ripl::Rc::SqueezeHistory
19
19
  super
20
20
  end
21
21
 
22
+ def before_loop
23
+ super if history.empty?
24
+ end
25
+
22
26
  module Imp
23
27
  def squeeze_history history
24
28
  history.to_a.inject([]){ |result, item|
@@ -27,7 +31,7 @@ module Ripl::Rc::SqueezeHistory
27
31
  else
28
32
  result << item
29
33
  end
30
- }
34
+ }.last(Ripl.config[:rc_squeeze_history_size] ||= 500)
31
35
  end
32
36
  end
33
37
  end
@@ -7,12 +7,12 @@ module Ripl::Rc::StripBacktrace
7
7
 
8
8
  # strip backtrace until ripl
9
9
  def format_error e
10
- "#{e.class}: #{e.message}\n #{U.strip_backtrace(e).join("\n ")}"
10
+ "#{e.class}: #{e.message}\n #{U.strip_backtrace(e, @name).join("\n ")}"
11
11
  end
12
12
 
13
13
  module Imp
14
- def strip_backtrace e
15
- home(cwd(snip(e)))
14
+ def strip_backtrace e, name
15
+ home(cwd(snip(e, name)))
16
16
  end
17
17
 
18
18
  def home b
@@ -23,9 +23,10 @@ module Ripl::Rc::StripBacktrace
23
23
  b.map{ |p| p.sub(Dir.pwd, './') }
24
24
  end
25
25
 
26
- def snip e
27
- e.backtrace[0..e.backtrace.rindex{ |l| l =~ /\(ripl\):\d+:in `.+?'/ } ||
28
- -1]
26
+ def snip e, name
27
+ e.backtrace[
28
+ 0..
29
+ e.backtrace.rindex{ |l| l =~ /\(#{name}\):\d+:in `.+?'/ } || -1]
29
30
  end
30
31
  end
31
32
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Ripl
3
3
  module Rc
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
6
6
  end
data/lib/ripl/rc.rb CHANGED
@@ -1,6 +1,16 @@
1
1
 
2
+ # when session ends
2
3
  require 'ripl/rc/squeeze_history'
4
+ require 'ripl/rc/mkdir_history'
3
5
  require 'ripl/rc/ctrld_newline'
4
- require 'ripl/rc/eat_whites'
5
- require 'ripl/rc/color'
6
+
7
+ # result format
6
8
  require 'ripl/rc/strip_backtrace'
9
+ require 'ripl/rc/color'
10
+
11
+ # input modification
12
+ require 'ripl/rc/multiline'
13
+ require 'ripl/rc/eat_whites'
14
+
15
+ # speical tool
16
+ require 'ripl/rc/anchor'
data/ripl-rc.gemspec CHANGED
@@ -2,17 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ripl-rc}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = %q{2011-02-24}
9
+ s.date = %q{2011-02-25}
10
10
  s.description = %q{ripl plugins collection}
11
11
  s.email = ["godfat (XD) godfat.org"]
12
- s.extra_rdoc_files = ["CHANGES", "README", "ripl-rc.gemspec"]
13
- s.files = [".gitignore", "CHANGES", "Gemfile", "LICENSE", "README", "README.rdoc", "Rakefile", "TODO", "ripl-rc.gemspec", "lib/ripl/rc.rb", "lib/ripl/rc/color.rb", "lib/ripl/rc/ctrld_newline.rb", "lib/ripl/rc/eat_whites.rb", "lib/ripl/rc/squeeze_history.rb", "lib/ripl/rc/strip_backtrace.rb", "lib/ripl/rc/version.rb", "test/test_squeeze_history.rb"]
12
+ s.files = [".gitignore", "CHANGES", "Gemfile", "LICENSE", "README.rdoc", "Rakefile", "TODO", "ripl-rc.gemspec", "lib/ripl/rc.rb", "lib/ripl/rc/anchor.rb", "lib/ripl/rc/color.rb", "lib/ripl/rc/ctrld_newline.rb", "lib/ripl/rc/eat_whites.rb", "lib/ripl/rc/mkdir_history.rb", "lib/ripl/rc/multiline.rb", "lib/ripl/rc/squeeze_history.rb", "lib/ripl/rc/strip_backtrace.rb", "lib/ripl/rc/version.rb", "test/test_squeeze_history.rb"]
14
13
  s.homepage = %q{http://github.com/godfat/ripl-rc}
15
- s.rdoc_options = ["--main", "README"]
14
+ s.rdoc_options = ["--main", "README.rdoc"]
16
15
  s.require_paths = ["lib"]
17
16
  s.rubygems_version = %q{1.5.2}
18
17
  s.summary = %q{ripl plugins collection}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripl-rc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-02-24 00:00:00.000000000 +08:00
12
+ date: 2011-02-25 00:00:00.000000000 +08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ripl
17
- requirement: &2152294800 !ruby/object:Gem::Requirement
17
+ requirement: &2152358620 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152294800
25
+ version_requirements: *2152358620
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bacon
28
- requirement: &2152262760 !ruby/object:Gem::Requirement
28
+ requirement: &2152357840 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2152262760
36
+ version_requirements: *2152357840
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rr
39
- requirement: &2152171240 !ruby/object:Gem::Requirement
39
+ requirement: &2152357040 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,30 +44,29 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2152171240
47
+ version_requirements: *2152357040
48
48
  description: ripl plugins collection
49
49
  email:
50
50
  - godfat (XD) godfat.org
51
51
  executables: []
52
52
  extensions: []
53
- extra_rdoc_files:
54
- - CHANGES
55
- - README
56
- - ripl-rc.gemspec
53
+ extra_rdoc_files: []
57
54
  files:
58
55
  - .gitignore
59
56
  - CHANGES
60
57
  - Gemfile
61
58
  - LICENSE
62
- - README
63
59
  - README.rdoc
64
60
  - Rakefile
65
61
  - TODO
66
62
  - ripl-rc.gemspec
67
63
  - lib/ripl/rc.rb
64
+ - lib/ripl/rc/anchor.rb
68
65
  - lib/ripl/rc/color.rb
69
66
  - lib/ripl/rc/ctrld_newline.rb
70
67
  - lib/ripl/rc/eat_whites.rb
68
+ - lib/ripl/rc/mkdir_history.rb
69
+ - lib/ripl/rc/multiline.rb
71
70
  - lib/ripl/rc/squeeze_history.rb
72
71
  - lib/ripl/rc/strip_backtrace.rb
73
72
  - lib/ripl/rc/version.rb
@@ -78,7 +77,7 @@ licenses: []
78
77
  post_install_message:
79
78
  rdoc_options:
80
79
  - --main
81
- - README
80
+ - README.rdoc
82
81
  require_paths:
83
82
  - lib
84
83
  required_ruby_version: !ruby/object:Gem::Requirement
data/README DELETED
@@ -1,47 +0,0 @@
1
- = ripl-rc 0.1.1
2
- by Lin Jen-Shin (godfat[http://godfat.org])
3
- godfat (XD) godfat.org
4
-
5
- == LINKS:
6
-
7
- * {github}[http://github.com/godfat/ripl-rc]
8
- * {rubygems}[http://rubygems.org/gems/ripl-rc]
9
-
10
- == DESCRIPTION:
11
-
12
- ripl plugins collection
13
-
14
- == FEATURES:
15
-
16
- * require 'ripl/rc/squeeze_history'
17
- * require 'ripl/rc/ctrld_newline'
18
- * require 'ripl/rc/eat_whites'
19
- * require 'ripl/rc/color'
20
- * require 'ripl/rc/strip_backtrace'
21
- * require 'ripl/rc' # for all of above
22
-
23
- == REQUIREMENTS:
24
-
25
- * ripl
26
-
27
- == INSTALL:
28
-
29
- gem install ripl-rc
30
-
31
- == LICENSE:
32
-
33
- Apache License 2.0
34
-
35
- Copyright (c) 2010, Lin Jen-Shin (godfat)
36
-
37
- Licensed under the Apache License, Version 2.0 (the "License");
38
- you may not use this file except in compliance with the License.
39
- You may obtain a copy of the License at
40
-
41
- http://www.apache.org/licenses/LICENSE-2.0
42
-
43
- Unless required by applicable law or agreed to in writing, software
44
- distributed under the License is distributed on an "AS IS" BASIS,
45
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
46
- See the License for the specific language governing permissions and
47
- limitations under the License.