ripl-rc 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "task"]
2
+ path = task
3
+ url = git://github.com/godfat/gemgem.git
data/CHANGES CHANGED
@@ -1,5 +1,10 @@
1
1
  = ripl-rc changes history
2
2
 
3
+ == ripl-rc 0.2.2 -- 2011-06-01
4
+
5
+ * [multiline_history ] fixed multiline_history
6
+ * [multiline_history_file] now we have persistent multiline_history
7
+
3
8
  == ripl-rc 0.2.1 -- 2011-04-11
4
9
 
5
10
  * [multiline] fixed history with editline (e.g. mac's build-in ruby)
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ task 'gem:spec' do
12
12
  s.version = Ripl::Rc::VERSION
13
13
  s.executables = [s.name]
14
14
 
15
- %w[ripl] .each{ |g| s.add_runtime_dependency(g) }
15
+ %w[ripl] .each{ |g| s.add_runtime_dependency(g, '>=0.4.1') }
16
16
  %w[bacon rr].each{ |g| s.add_development_dependency(g) }
17
17
  end
18
18
 
data/lib/ripl/rc.rb CHANGED
@@ -1,6 +1,19 @@
1
1
 
2
+ # this really messes thing up! should be loaded first if we're using
3
+ # ripl/rc/multiline_history_file, otherwise, history couldn't really
4
+ # be overridden...
5
+ require 'ripl'
6
+ if Ripl.config[:readline] == true
7
+ require 'readline'
8
+ require 'ripl/readline'
9
+ elsif Ripl.config[:readline]
10
+ require Ripl.config[:readline].to_s
11
+ require 'ripl/readline'
12
+ end
13
+
2
14
  # upon session ends
3
15
  require 'ripl/rc/squeeze_history'
16
+ require 'ripl/rc/multiline_history_file'
4
17
  require 'ripl/rc/mkdir_history'
5
18
  require 'ripl/rc/ctrld_newline'
6
19
 
@@ -13,6 +26,7 @@ require 'ripl/rc/color'
13
26
 
14
27
  # upon input
15
28
  require 'ripl/rc/multiline'
29
+ require 'ripl/rc/multiline_history'
16
30
  require 'ripl/rc/eat_whites'
17
31
 
18
32
  # speical tool
@@ -10,12 +10,13 @@ module Ripl::Rc::Multiline
10
10
  # ruby -e '{'
11
11
  # ruby -e '['
12
12
  # ruby -e '('
13
+ # ruby -e '/'
13
14
  # ruby -e 'class C'
14
15
  # ruby -e 'def f'
15
16
  # ruby -e 'begin'
16
17
  ERROR_REGEXP = Regexp.new(
17
- [ # string
18
- "unterminated string meets end of file",
18
+ [ # string or regexp
19
+ "unterminated \\w+ meets end of file",
19
20
  # mri and rubinius
20
21
  "syntax error, unexpected \\$end",
21
22
  # rubinius
@@ -51,7 +52,6 @@ module Ripl::Rc::Multiline
51
52
  return super if Multiline.disabled?
52
53
  if e.is_a?(SyntaxError) && e.message =~ ERROR_REGEXP
53
54
  @rc_multiline_buffer << @input if @rc_multiline_buffer.empty?
54
- history.pop
55
55
  throw :rc_multiline_cont
56
56
  else
57
57
  super
@@ -64,9 +64,7 @@ module Ripl::Rc::Multiline
64
64
  super
65
65
  else
66
66
  @rc_multiline_buffer << input
67
- history.pop
68
- history << "\n" + (str = @rc_multiline_buffer.join("\n"))
69
- super str
67
+ super @rc_multiline_buffer.join("\n")
70
68
  end
71
69
  end
72
70
 
@@ -76,12 +74,9 @@ module Ripl::Rc::Multiline
76
74
  super
77
75
  else
78
76
  line = @rc_multiline_buffer.pop
79
- if @rc_multiline_buffer.empty?
80
- super
81
- else
82
- puts "[removed this line: #{line}]"
83
- throw :rc_multiline_cont
84
- end
77
+ print "[removed this line: #{line}]"
78
+ super
79
+ throw :rc_multiline_cont
85
80
  end
86
81
  end
87
82
  end
@@ -0,0 +1,30 @@
1
+
2
+ require 'ripl/rc/u'
3
+ require 'ripl/rc/multiline' # dependency
4
+
5
+ module Ripl::Rc::MultilineHistory
6
+ include Ripl::Rc::U
7
+
8
+ def loop_eval(input)
9
+ return super if MultilineHistory.disabled?
10
+ result = super # might throw
11
+ unless @rc_multiline_buffer.empty?
12
+ (@rc_multiline_buffer.size + (@rc_multiline_trash || 0)).
13
+ times{ history.pop }
14
+ @rc_multiline_trash = 0
15
+ history << "\n" + @rc_multiline_buffer.join("\n")
16
+ end
17
+ result
18
+ end
19
+
20
+ def handle_interrupt
21
+ return super if MultilineHistory.disabled?
22
+ unless @rc_multiline_buffer.empty?
23
+ @rc_multiline_trash ||= 0
24
+ @rc_multiline_trash += 1
25
+ end
26
+ super
27
+ end
28
+ end
29
+
30
+ Ripl::Shell.include(Ripl::Rc::MultilineHistory)
@@ -0,0 +1,35 @@
1
+
2
+ require 'ripl/rc/u'
3
+ # require 'ripl/rc/history_ivar' # dependency
4
+
5
+ module Ripl::Rc::MultilineHistoryFile
6
+ include Ripl::Rc::U
7
+
8
+ def write_history
9
+ return super if MultilineHistoryFile.disabled?
10
+ @history = history.to_a.map{ |line|
11
+ line.gsub("\n", "#{Ripl.config[:rc_multiline_history_file_token]}\n")
12
+ }
13
+ super
14
+ end
15
+
16
+ def before_loop
17
+ return super if MultilineHistoryFile.disabled?
18
+ super # this would initilaize @history to [], nothing we can do here
19
+ buffer = []
20
+ File.exist?(history_file) &&
21
+ IO.readlines(history_file).each{ |line|
22
+ if line.end_with?(
23
+ "#{Ripl.config[:rc_multiline_history_file_token]}\n")
24
+ buffer << line[0...
25
+ -Ripl.config[:rc_multiline_history_file_token].size-1] + "\n"
26
+ else
27
+ history << (buffer.join + line).chomp
28
+ buffer = []
29
+ end
30
+ }
31
+ end
32
+ end
33
+
34
+ Ripl::Shell.include(Ripl::Rc::MultilineHistoryFile)
35
+ Ripl.config[:rc_multiline_history_file_token] ||= ' '
@@ -4,11 +4,6 @@ require 'ripl/rc/u'
4
4
  module Ripl::Rc::SqueezeHistory
5
5
  include Ripl::Rc::U
6
6
 
7
- # avoid some complicated conditions...
8
- def history
9
- super || (@history ||= [])
10
- end
11
-
12
7
  # write squeezed history
13
8
  def write_history
14
9
  return super if SqueezeHistory.disabled?
@@ -26,11 +21,6 @@ module Ripl::Rc::SqueezeHistory
26
21
  super
27
22
  end
28
23
 
29
- def before_loop
30
- return super if SqueezeHistory.disabled?
31
- super if history.empty?
32
- end
33
-
34
24
  module Imp
35
25
  def squeeze_history history
36
26
  history.to_a.inject([]){ |result, item|
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Ripl
3
3
  module Rc
4
- VERSION = '0.2.1'
4
+ VERSION = '0.2.2'
5
5
  end
6
6
  end
data/ripl-rc.gemspec CHANGED
@@ -2,37 +2,79 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ripl-rc}
5
- s.version = "0.2.1"
5
+ s.version = "0.2.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Lin Jen-Shin (godfat)"]
9
- s.date = %q{2011-04-11}
8
+ s.authors = [%q{Lin Jen-Shin (godfat)}]
9
+ s.date = %q{2011-06-01}
10
10
  s.description = %q{ripl plugins collection, take you want, leave you don't.}
11
- s.email = ["godfat (XD) godfat.org"]
12
- s.executables = ["ripl-rc"]
13
- s.extra_rdoc_files = ["CHANGES", "CONTRIBUTORS", "LICENSE", "TODO"]
14
- s.files = [".gitignore", "2011-02-28.md", "CHANGES", "CONTRIBUTORS", "Gemfile", "LICENSE", "README", "README.md", "Rakefile", "TODO", "bin/ripl-rc", "lib/ripl-rc.rb", "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/last_exception.rb", "lib/ripl/rc/mkdir_history.rb", "lib/ripl/rc/multiline.rb", "lib/ripl/rc/noirbrc.rb", "lib/ripl/rc/squeeze_history.rb", "lib/ripl/rc/strip_backtrace.rb", "lib/ripl/rc/test.rb", "lib/ripl/rc/u.rb", "lib/ripl/rc/version.rb", "ripl-rc.gemspec", "screenshot.png", "task/gemgem.rb", "test/test_disable_shortcut.rb", "test/test_squeeze_history.rb"]
15
- s.homepage = %q{http://github.com/godfat/}
16
- s.rdoc_options = ["--main", "README"]
17
- s.require_paths = ["lib"]
18
- s.rubygems_version = %q{1.7.2}
11
+ s.email = [%q{godfat (XD) godfat.org}]
12
+ s.executables = [%q{ripl-rc}]
13
+ s.extra_rdoc_files = [
14
+ %q{CHANGES},
15
+ %q{CONTRIBUTORS},
16
+ %q{LICENSE},
17
+ %q{TODO}]
18
+ s.files = [
19
+ %q{.gitignore},
20
+ %q{.gitmodules},
21
+ %q{2011-02-28.md},
22
+ %q{CHANGES},
23
+ %q{CONTRIBUTORS},
24
+ %q{Gemfile},
25
+ %q{LICENSE},
26
+ %q{README},
27
+ %q{README.md},
28
+ %q{Rakefile},
29
+ %q{TODO},
30
+ %q{bin/ripl-rc},
31
+ %q{lib/ripl-rc.rb},
32
+ %q{lib/ripl/rc.rb},
33
+ %q{lib/ripl/rc/anchor.rb},
34
+ %q{lib/ripl/rc/color.rb},
35
+ %q{lib/ripl/rc/ctrld_newline.rb},
36
+ %q{lib/ripl/rc/eat_whites.rb},
37
+ %q{lib/ripl/rc/last_exception.rb},
38
+ %q{lib/ripl/rc/mkdir_history.rb},
39
+ %q{lib/ripl/rc/multiline.rb},
40
+ %q{lib/ripl/rc/multiline_history.rb},
41
+ %q{lib/ripl/rc/multiline_history_file.rb},
42
+ %q{lib/ripl/rc/noirbrc.rb},
43
+ %q{lib/ripl/rc/squeeze_history.rb},
44
+ %q{lib/ripl/rc/strip_backtrace.rb},
45
+ %q{lib/ripl/rc/test.rb},
46
+ %q{lib/ripl/rc/u.rb},
47
+ %q{lib/ripl/rc/version.rb},
48
+ %q{ripl-rc.gemspec},
49
+ %q{screenshot.png},
50
+ %q{task/gemgem.rb},
51
+ %q{test/test_disable_shortcut.rb},
52
+ %q{test/test_squeeze_history.rb}]
53
+ s.homepage = %q{https://github.com/godfat/}
54
+ s.rdoc_options = [
55
+ %q{--main},
56
+ %q{README}]
57
+ s.require_paths = [%q{lib}]
58
+ s.rubygems_version = %q{1.8.5}
19
59
  s.summary = %q{ripl plugins collection, take you want, leave you don't.}
20
- s.test_files = ["test/test_disable_shortcut.rb", "test/test_squeeze_history.rb"]
60
+ s.test_files = [
61
+ %q{test/test_disable_shortcut.rb},
62
+ %q{test/test_squeeze_history.rb}]
21
63
 
22
64
  if s.respond_to? :specification_version then
23
65
  s.specification_version = 3
24
66
 
25
67
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
26
- s.add_runtime_dependency(%q<ripl>, [">= 0"])
68
+ s.add_runtime_dependency(%q<ripl>, [">= 0.4.1"])
27
69
  s.add_development_dependency(%q<bacon>, [">= 0"])
28
70
  s.add_development_dependency(%q<rr>, [">= 0"])
29
71
  else
30
- s.add_dependency(%q<ripl>, [">= 0"])
72
+ s.add_dependency(%q<ripl>, [">= 0.4.1"])
31
73
  s.add_dependency(%q<bacon>, [">= 0"])
32
74
  s.add_dependency(%q<rr>, [">= 0"])
33
75
  end
34
76
  else
35
- s.add_dependency(%q<ripl>, [">= 0"])
77
+ s.add_dependency(%q<ripl>, [">= 0.4.1"])
36
78
  s.add_dependency(%q<bacon>, [">= 0"])
37
79
  s.add_dependency(%q<rr>, [">= 0"])
38
80
  end
data/task/gemgem.rb CHANGED
@@ -11,7 +11,7 @@ module Gemgem
11
11
  yield(spec = Gem::Specification.new{ |s|
12
12
  s.authors = ['Lin Jen-Shin (godfat)']
13
13
  s.email = ['godfat (XD) godfat.org']
14
- s.homepage = "http://github.com/godfat/#{s.name}"
14
+ s.homepage = "https://github.com/godfat/#{s.name}"
15
15
 
16
16
  s.summary = File.read("#{Gemgem.dir}/README").
17
17
  match(/DESCRIPTION:\n\n(.+?)\n\n/m)[1]
@@ -33,7 +33,18 @@ module Gemgem
33
33
  end
34
34
 
35
35
  def write
36
- File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f| f << spec.to_ruby }
36
+ File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
37
+ f << split_lines(spec.to_ruby) }
38
+ end
39
+
40
+ def split_lines ruby
41
+ ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
42
+ if $2.index(',')
43
+ "#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
44
+ else
45
+ s
46
+ end
47
+ }
37
48
  end
38
49
 
39
50
  def all_files
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.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-11 00:00:00.000000000Z
12
+ date: 2011-06-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ripl
16
- requirement: &2156654560 !ruby/object:Gem::Requirement
16
+ requirement: &2168485380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 0.4.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156654560
24
+ version_requirements: *2168485380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bacon
27
- requirement: &2156654080 !ruby/object:Gem::Requirement
27
+ requirement: &2168484900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156654080
35
+ version_requirements: *2168484900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rr
38
- requirement: &2156653600 !ruby/object:Gem::Requirement
38
+ requirement: &2168484420 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156653600
46
+ version_requirements: *2168484420
47
47
  description: ripl plugins collection, take you want, leave you don't.
48
48
  email:
49
49
  - godfat (XD) godfat.org
@@ -57,6 +57,7 @@ extra_rdoc_files:
57
57
  - TODO
58
58
  files:
59
59
  - .gitignore
60
+ - .gitmodules
60
61
  - 2011-02-28.md
61
62
  - CHANGES
62
63
  - CONTRIBUTORS
@@ -76,6 +77,8 @@ files:
76
77
  - lib/ripl/rc/last_exception.rb
77
78
  - lib/ripl/rc/mkdir_history.rb
78
79
  - lib/ripl/rc/multiline.rb
80
+ - lib/ripl/rc/multiline_history.rb
81
+ - lib/ripl/rc/multiline_history_file.rb
79
82
  - lib/ripl/rc/noirbrc.rb
80
83
  - lib/ripl/rc/squeeze_history.rb
81
84
  - lib/ripl/rc/strip_backtrace.rb
@@ -87,7 +90,7 @@ files:
87
90
  - task/gemgem.rb
88
91
  - test/test_disable_shortcut.rb
89
92
  - test/test_squeeze_history.rb
90
- homepage: http://github.com/godfat/
93
+ homepage: https://github.com/godfat/
91
94
  licenses: []
92
95
  post_install_message:
93
96
  rdoc_options:
@@ -109,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
112
  version: '0'
110
113
  requirements: []
111
114
  rubyforge_project:
112
- rubygems_version: 1.7.2
115
+ rubygems_version: 1.8.5
113
116
  signing_key:
114
117
  specification_version: 3
115
118
  summary: ripl plugins collection, take you want, leave you don't.