readline_buffer 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # readline_buffer CHANGES
2
2
 
3
+ ## readline_buffer 0.9.2 -- 2011-12-14
4
+
5
+ * Puts a warning for Editline (libedit) instead of failing to install it.
6
+ If you're using Editline, then readline_buffer would do nothing at all.
7
+
3
8
  ## readline_buffer 0.9.1 -- 2011-08-19
4
9
 
5
10
  * Fixed a segfault whenever rl_line_buffer is NULL
data/README.md CHANGED
@@ -9,13 +9,13 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
9
9
 
10
10
  ## DESCRIPTION:
11
11
 
12
- Let you manipulate Readline.line_buffer
12
+ Let you manipulate `Readline.line_buffer`
13
13
 
14
- Note, only GNU Readline is supported
14
+ Note, only GNU Readline is supported at the moment.
15
15
 
16
16
  ## REQUIREMENTS:
17
17
 
18
- * GNU Readline, not EditLine
18
+ * GNU Readline, not Editline
19
19
 
20
20
  ## INSTALLATION:
21
21
 
@@ -27,18 +27,7 @@ Note, only GNU Readline is supported
27
27
 
28
28
  ## LICENSE:
29
29
 
30
- Apache License 2.0
30
+ GPL 3 if you're compiling against Readline,
31
+ otherwise Apache License 2.0
31
32
 
32
33
  Copyright (c) 2011, Lin Jen-Shin (godfat)
33
-
34
- Licensed under the Apache License, Version 2.0 (the "License");
35
- you may not use this file except in compliance with the License.
36
- You may obtain a copy of the License at
37
-
38
- <http://www.apache.org/licenses/LICENSE-2.0>
39
-
40
- Unless required by applicable law or agreed to in writing, software
41
- distributed under the License is distributed on an "AS IS" BASIS,
42
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
- See the License for the specific language governing permissions and
44
- limitations under the License.
@@ -4,11 +4,10 @@ dir_config('readline')
4
4
  have_library('readline')
5
5
 
6
6
  if have_header('readline/readline.h')
7
- if have_func('rl_delete_text', 'readline/readline.h')
8
- create_makefile 'readline_buffer_ext'
9
- else
10
- abort 'Only Readline (not EditLine) is supported'
11
- end
7
+ # editline (libedit) doesn't have rl_delete_text
8
+ have_func('rl_delete_text', 'readline/readline.h')
9
+ create_makefile 'readline_buffer_ext'
10
+
12
11
  else
13
12
  abort 'Readline not found'
14
13
  end
@@ -1,8 +1,5 @@
1
1
 
2
- #ifdef HAVE_READLINE_READLINE_H
3
2
  #include "ruby.h"
4
- #include <errno.h>
5
- #include <stdio.h>
6
3
  #include <readline/readline.h>
7
4
 
8
5
  static VALUE readline_buffer_ext(VALUE self, VALUE str){
@@ -12,7 +9,11 @@ static VALUE readline_buffer_ext(VALUE self, VALUE str){
12
9
  if(rl_line_buffer == NULL)
13
10
  return Qnil;
14
11
 
12
+ #ifdef HAVE_RL_DELETE_TEXT
15
13
  rl_delete_text(0, rl_end);
14
+ #else
15
+ rl_line_buffer[rl_end = 0] = '\0';
16
+ #endif
16
17
  rl_insert_text(RSTRING_PTR(str));
17
18
  rl_redisplay();
18
19
 
@@ -24,5 +25,3 @@ void Init_readline_buffer_ext() {
24
25
  "line_buffer=",
25
26
  readline_buffer_ext, 1);
26
27
  }
27
-
28
- #endif
@@ -1,3 +1,9 @@
1
1
 
2
2
  require 'readline'
3
3
  require 'readline_buffer_ext'
4
+
5
+ if Readline::VERSION =~ /EditLine/i
6
+ puts "WARN: Editline (libedit) doesn't work with readline_buffer."
7
+ puts " A working patch is wanted, please submit to:"
8
+ puts " https://github.com/godfat/readline_buffer Thanks!!"
9
+ end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module ReadlineBuffer
3
- VERSION = '0.9.1'
3
+ VERSION = '0.9.2'
4
4
  end
@@ -1,39 +1,32 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  Gem::Specification.new do |s|
4
- s.name = %q{readline_buffer}
5
- s.version = "0.9.1"
4
+ s.name = "readline_buffer"
5
+ s.version = "0.9.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = [%q{Lin Jen-Shin (godfat)}]
9
- s.date = %q{2011-08-19}
10
- s.description = %q{Let you manipulate Readline.line_buffer
11
-
12
- Note, only GNU Readline is supported}
13
- s.email = [%q{godfat (XD) godfat.org}]
14
- s.extensions = [%q{ext/readline_buffer_ext/extconf.rb}]
15
- s.extra_rdoc_files = [%q{CHANGES.md}]
8
+ s.authors = ["Lin Jen-Shin (godfat)"]
9
+ s.date = "2011-12-14"
10
+ s.description = "Let you manipulate `Readline.line_buffer`\n\nNote, only GNU Readline is supported at the moment."
11
+ s.email = ["godfat (XD) godfat.org"]
12
+ s.extensions = ["ext/readline_buffer_ext/extconf.rb"]
16
13
  s.files = [
17
- %q{.gitignore},
18
- %q{.gitmodules},
19
- %q{CHANGES.md},
20
- %q{README},
21
- %q{README.md},
22
- %q{Rakefile},
23
- %q{ext/readline_buffer_ext/extconf.rb},
24
- %q{ext/readline_buffer_ext/readline_buffer_ext.c},
25
- %q{lib/readline_buffer.rb},
26
- %q{lib/readline_buffer/version.rb},
27
- %q{readline_buffer.gemspec},
28
- %q{task/.gitignore},
29
- %q{task/gemgem.rb}]
30
- s.homepage = %q{https://github.com/godfat/readline_buffer}
31
- s.rdoc_options = [
32
- %q{--main},
33
- %q{README}]
34
- s.require_paths = [%q{lib}]
35
- s.rubygems_version = %q{1.8.7}
36
- s.summary = %q{Let you manipulate Readline.line_buffer}
14
+ ".gitignore",
15
+ ".gitmodules",
16
+ "CHANGES.md",
17
+ "README.md",
18
+ "Rakefile",
19
+ "ext/readline_buffer_ext/extconf.rb",
20
+ "ext/readline_buffer_ext/readline_buffer_ext.c",
21
+ "lib/readline_buffer.rb",
22
+ "lib/readline_buffer/version.rb",
23
+ "readline_buffer.gemspec",
24
+ "task/.gitignore",
25
+ "task/gemgem.rb"]
26
+ s.homepage = "https://github.com/godfat/readline_buffer"
27
+ s.require_paths = ["lib"]
28
+ s.rubygems_version = "1.8.12"
29
+ s.summary = "Let you manipulate `Readline.line_buffer`"
37
30
 
38
31
  if s.respond_to? :specification_version then
39
32
  s.specification_version = 3
@@ -12,17 +12,9 @@ module Gemgem
12
12
  s.authors = ['Lin Jen-Shin (godfat)']
13
13
  s.email = ['godfat (XD) godfat.org']
14
14
 
15
- description = File.read("#{Gemgem.dir}/README").
16
- match(/DESCRIPTION:\n\n(.+?)(?=\n\n[^\n]+:\n)/m)[1].
17
- lines.to_a
18
-
19
15
  s.description = description.join
20
16
  s.summary = description.first
21
17
 
22
- s.extra_rdoc_files = %w[CHANGES TODO CONTRIBUTORS LICENSE
23
- CHANGES.md TODO.md CONTRIBUTORS].select{ |f|
24
- File.exist?(f) }
25
- s.rdoc_options = %w[--main README]
26
18
  s.rubygems_version = Gem::VERSION
27
19
  s.date = Time.now.strftime('%Y-%m-%d')
28
20
  s.files = gem_files
@@ -34,6 +26,72 @@ module Gemgem
34
26
  spec
35
27
  end
36
28
 
29
+ def readme
30
+ path = %w[README.md README].find{ |name|
31
+ File.exist?("#{Gemgem.dir}/#{name}")
32
+ }
33
+ @readme ||=
34
+ if path
35
+ ps = File.read(path).scan(/#+[^\n]+\n\n.+?(?=\n\n#+[^\n]+\n)/m)
36
+ ps.inject({'HEADER' => ps.first}){ |r, s, i|
37
+ r[s[/\w+/]] = s
38
+ r
39
+ }
40
+ else
41
+ {}
42
+ end
43
+ end
44
+
45
+ def description
46
+ @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
47
+ end
48
+
49
+ def changes
50
+ path = %w[CHANGES.md CHANGES].find{ |name|
51
+ File.exist?("#{Gemgem.dir}/#{name}")
52
+ }
53
+ @changes ||=
54
+ if path
55
+ date = '\d+{4}\-\d+{2}\-\d{2}'
56
+ File.read(path).match(
57
+ /([^\n]+#{date}\n\n(.+?))(?=\n\n[^\n]+#{date}\n|\Z)/m)[1]
58
+ else
59
+ ''
60
+ end
61
+ end
62
+
63
+ def ann_md
64
+ "##{readme['HEADER'].sub(/([\w\-]+)/, "[\\1](#{spec.homepage})")}\n\n" \
65
+ "##{readme['DESCRIPTION'][/[^\n]+\n\n[^\n]+/]}\n\n" \
66
+ "### CHANGES:\n\n" \
67
+ "###{changes}\n\n" \
68
+ "##{readme['INSTALLATION']}\n\n" +
69
+ if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}" else '' end
70
+ end
71
+
72
+ def ann_html
73
+ gem 'nokogiri'
74
+ gem 'kramdown'
75
+
76
+ IO.popen('kramdown', 'r+') do |md|
77
+ md.puts Gemgem.ann_md
78
+ md.close_write
79
+ require 'nokogiri'
80
+ html = Nokogiri::XML.parse("<gemgem>#{md.read}</gemgem>")
81
+ html.css('*').each{ |n| n.delete('id') }
82
+ html.root.children.to_html
83
+ end
84
+ end
85
+
86
+ def ann_email
87
+ "#{readme['HEADER'].sub(/([\w\-]+)/, "\\1 <#{spec.homepage}>")}\n\n" \
88
+ "#{readme['DESCRIPTION']}\n\n" \
89
+ "#{readme['INSTALLATION']}\n\n" +
90
+ if readme['SYNOPSIS'] then "##{readme['SYNOPSIS']}\n\n" else '' end +
91
+ "## CHANGES:\n\n" \
92
+ "##{changes}\n\n"
93
+ end
94
+
37
95
  def gem_tag
38
96
  "#{spec.name}-#{spec.version}"
39
97
  end
@@ -88,7 +146,7 @@ module Gemgem
88
146
 
89
147
  def ignore_patterns
90
148
  @ignore_files ||= expand_patterns(
91
- File.read("#{dir}/.gitignore").split("\n").reject{ |pattern|
149
+ gitignore.split("\n").reject{ |pattern|
92
150
  pattern.strip == ''
93
151
  }).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
94
152
  end
@@ -105,6 +163,14 @@ module Gemgem
105
163
  end
106
164
  }.flatten
107
165
  end
166
+
167
+ def gitignore
168
+ if File.exist?(path = "#{dir}/.gitignore")
169
+ File.read(path)
170
+ else
171
+ ''
172
+ end
173
+ end
108
174
  end
109
175
 
110
176
  namespace :gem do
@@ -133,14 +199,14 @@ task :check do
133
199
  ver = Gemgem.spec.version.to_s
134
200
 
135
201
  if ENV['VERSION'].nil?
136
- puts("\x1b[35mExpected " \
137
- "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
202
+ puts("\e[35mExpected " \
203
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
138
204
  exit(1)
139
205
 
140
206
  elsif ENV['VERSION'] != ver
141
- puts("\x1b[35mExpected \x1b[33mVERSION\x1b[35m=\x1b[33m#{ver} " \
142
- "\x1b[35mbut got\n " \
143
- "\x1b[33mVERSION\x1b[35m=\x1b[33m#{ENV['VERSION']}\x1b[m")
207
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
208
+ "\e[35mbut got\n " \
209
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
144
210
  exit(2)
145
211
  end
146
212
  end
@@ -153,7 +219,7 @@ task :test do
153
219
  Bacon.extend(Bacon::TestUnitOutput)
154
220
  Bacon.summary_on_exit
155
221
  $LOAD_PATH.unshift('lib')
156
- Dir['test/**/test_*.rb'].each{ |file| load file }
222
+ Dir['./test/**/test_*.rb'].each{ |file| require file[0..-4] }
157
223
  end
158
224
 
159
225
  desc 'Run tests with shell'
@@ -166,13 +232,28 @@ task 'test:shell', :RUBY_OPTS do |t, args|
166
232
  sh(cmd.compact.join(' '))
167
233
  end
168
234
 
235
+ desc 'Generate ann markdown'
236
+ task 'ann:md' => ['gem:spec'] do
237
+ puts Gemgem.ann_md
238
+ end
239
+
240
+ desc 'Generate ann html'
241
+ task 'ann:html' => ['gem:spec'] do
242
+ puts Gemgem.ann_html
243
+ end
244
+
245
+ desc 'Generate ann email'
246
+ task 'ann:email' => ['gem:spec'] do
247
+ puts Gemgem.ann_email
248
+ end
249
+
169
250
  desc 'Generate rdoc'
170
251
  task :doc => ['gem:spec'] do
171
252
  sh("yardoc -o rdoc --main README.md" \
172
253
  " --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
173
254
  end
174
255
 
175
- desc 'Removed ignored files'
256
+ desc 'Remove ignored files'
176
257
  task :clean => ['gem:spec'] do
177
258
  trash = "~/.Trash/#{Gemgem.spec.name}/"
178
259
  sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readline_buffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,24 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-19 00:00:00.000000000Z
12
+ date: 2011-12-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! 'Let you manipulate Readline.line_buffer
14
+ description: ! 'Let you manipulate `Readline.line_buffer`
15
15
 
16
16
 
17
- Note, only GNU Readline is supported'
17
+ Note, only GNU Readline is supported at the moment.'
18
18
  email:
19
19
  - godfat (XD) godfat.org
20
20
  executables: []
21
21
  extensions:
22
22
  - ext/readline_buffer_ext/extconf.rb
23
- extra_rdoc_files:
24
- - CHANGES.md
23
+ extra_rdoc_files: []
25
24
  files:
26
25
  - .gitignore
27
26
  - .gitmodules
28
27
  - CHANGES.md
29
- - README
30
28
  - README.md
31
29
  - Rakefile
32
30
  - ext/readline_buffer_ext/extconf.rb
@@ -39,9 +37,7 @@ files:
39
37
  homepage: https://github.com/godfat/readline_buffer
40
38
  licenses: []
41
39
  post_install_message:
42
- rdoc_options:
43
- - --main
44
- - README
40
+ rdoc_options: []
45
41
  require_paths:
46
42
  - lib
47
43
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -58,8 +54,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
54
  version: '0'
59
55
  requirements: []
60
56
  rubyforge_project:
61
- rubygems_version: 1.8.7
57
+ rubygems_version: 1.8.12
62
58
  signing_key:
63
59
  specification_version: 3
64
- summary: Let you manipulate Readline.line_buffer
60
+ summary: Let you manipulate `Readline.line_buffer`
65
61
  test_files: []
data/README DELETED
@@ -1,44 +0,0 @@
1
- # readline_buffer
2
-
3
- by Lin Jen-Shin ([godfat](http://godfat.org))
4
-
5
- ## LINKS:
6
-
7
- * [github](https://github.com/godfat/readline_buffer)
8
- * [rubygems](http://rubygems.org/gems/readline_buffer)
9
-
10
- ## DESCRIPTION:
11
-
12
- Let you manipulate Readline.line_buffer
13
-
14
- Note, only GNU Readline is supported
15
-
16
- ## REQUIREMENTS:
17
-
18
- * GNU Readline, not EditLine
19
-
20
- ## INSTALLATION:
21
-
22
- gem install readline_buffer
23
-
24
- ## SYNOPSIS:
25
-
26
- Readline.line_buffer = 'p "replace rl_line_buffer"'
27
-
28
- ## LICENSE:
29
-
30
- Apache License 2.0
31
-
32
- Copyright (c) 2011, Lin Jen-Shin (godfat)
33
-
34
- Licensed under the Apache License, Version 2.0 (the "License");
35
- you may not use this file except in compliance with the License.
36
- You may obtain a copy of the License at
37
-
38
- <http://www.apache.org/licenses/LICENSE-2.0>
39
-
40
- Unless required by applicable law or agreed to in writing, software
41
- distributed under the License is distributed on an "AS IS" BASIS,
42
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
- See the License for the specific language governing permissions and
44
- limitations under the License.