readline_buffer 0.9.0
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/.gitignore +2 -0
- data/.gitmodules +3 -0
- data/README +44 -0
- data/README.md +44 -0
- data/Rakefile +20 -0
- data/ext/readline_buffer_ext/extconf.rb +14 -0
- data/ext/readline_buffer_ext/readline_buffer_ext.c +25 -0
- data/lib/readline_buffer.rb +3 -0
- data/lib/readline_buffer/version.rb +4 -0
- data/readline_buffer.gemspec +44 -0
- data/task/.gitignore +1 -0
- data/task/gemgem.rb +184 -0
- metadata +63 -0
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/README
ADDED
@@ -0,0 +1,44 @@
|
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
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.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
require "#{dir = File.dirname(__FILE__)}/task/gemgem"
|
3
|
+
Gemgem.dir = dir
|
4
|
+
|
5
|
+
($LOAD_PATH << File.expand_path("#{Gemgem.dir}/lib")).uniq!
|
6
|
+
|
7
|
+
desc 'Generate gemspec'
|
8
|
+
task 'gem:spec' do
|
9
|
+
Gemgem.spec = Gemgem.create do |s|
|
10
|
+
require 'readline_buffer/version'
|
11
|
+
s.name = 'readline_buffer'
|
12
|
+
s.version = ReadlineBuffer::VERSION
|
13
|
+
|
14
|
+
s.extensions = 'ext/readline_buffer_ext/extconf.rb'
|
15
|
+
%w[].each{ |g| s.add_runtime_dependency(g) }
|
16
|
+
%w[].each{ |g| s.add_development_dependency(g) }
|
17
|
+
end
|
18
|
+
|
19
|
+
Gemgem.write
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
require 'mkmf'
|
3
|
+
dir_config('readline')
|
4
|
+
have_library('readline')
|
5
|
+
|
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
|
12
|
+
else
|
13
|
+
abort 'Readline not found'
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
#ifdef HAVE_READLINE_READLINE_H
|
3
|
+
#include "ruby.h"
|
4
|
+
#include <errno.h>
|
5
|
+
#include <stdio.h>
|
6
|
+
#include <readline/readline.h>
|
7
|
+
|
8
|
+
static VALUE readline_buffer_ext(VALUE self, VALUE str){
|
9
|
+
rb_secure(4);
|
10
|
+
StringValue(str);
|
11
|
+
|
12
|
+
rl_delete_text(0, rl_end);
|
13
|
+
rl_insert_text(RSTRING_PTR(str));
|
14
|
+
rl_redisplay();
|
15
|
+
|
16
|
+
return rb_str_new(rl_line_buffer, strlen(rl_line_buffer));
|
17
|
+
}
|
18
|
+
|
19
|
+
void Init_readline_buffer_ext() {
|
20
|
+
rb_define_singleton_method(rb_const_get(rb_cObject, rb_intern("Readline")),
|
21
|
+
"line_buffer=",
|
22
|
+
readline_buffer_ext, 1);
|
23
|
+
}
|
24
|
+
|
25
|
+
#endif
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{readline_buffer}
|
5
|
+
s.version = "0.9.0"
|
6
|
+
|
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-18}
|
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.files = [
|
16
|
+
%q{.gitignore},
|
17
|
+
%q{.gitmodules},
|
18
|
+
%q{README},
|
19
|
+
%q{README.md},
|
20
|
+
%q{Rakefile},
|
21
|
+
%q{ext/readline_buffer_ext/extconf.rb},
|
22
|
+
%q{ext/readline_buffer_ext/readline_buffer_ext.c},
|
23
|
+
%q{lib/readline_buffer.rb},
|
24
|
+
%q{lib/readline_buffer/version.rb},
|
25
|
+
%q{readline_buffer.gemspec},
|
26
|
+
%q{task/.gitignore},
|
27
|
+
%q{task/gemgem.rb}]
|
28
|
+
s.homepage = %q{https://github.com/godfat/readline_buffer}
|
29
|
+
s.rdoc_options = [
|
30
|
+
%q{--main},
|
31
|
+
%q{README}]
|
32
|
+
s.require_paths = [%q{lib}]
|
33
|
+
s.rubygems_version = %q{1.8.7}
|
34
|
+
s.summary = %q{Let you manipulate Readline.line_buffer}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
40
|
+
else
|
41
|
+
end
|
42
|
+
else
|
43
|
+
end
|
44
|
+
end
|
data/task/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.rbc
|
data/task/gemgem.rb
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module Gemgem
|
5
|
+
class << self
|
6
|
+
attr_accessor :dir, :spec
|
7
|
+
end
|
8
|
+
|
9
|
+
module_function
|
10
|
+
def create
|
11
|
+
yield(spec = Gem::Specification.new{ |s|
|
12
|
+
s.authors = ['Lin Jen-Shin (godfat)']
|
13
|
+
s.email = ['godfat (XD) godfat.org']
|
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
|
+
s.description = description.join
|
20
|
+
s.summary = description.first
|
21
|
+
|
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
|
+
s.rubygems_version = Gem::VERSION
|
27
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
28
|
+
s.files = gem_files
|
29
|
+
s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
30
|
+
s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
|
31
|
+
s.require_paths = %w[lib]
|
32
|
+
})
|
33
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
34
|
+
spec
|
35
|
+
end
|
36
|
+
|
37
|
+
def gem_tag
|
38
|
+
"#{spec.name}-#{spec.version}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def write
|
42
|
+
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
|
43
|
+
f << split_lines(spec.to_ruby) }
|
44
|
+
end
|
45
|
+
|
46
|
+
def split_lines ruby
|
47
|
+
ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
|
48
|
+
if $2.index(',')
|
49
|
+
"#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
|
50
|
+
else
|
51
|
+
s
|
52
|
+
end
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def all_files
|
57
|
+
@all_files ||= find_files(Pathname.new(dir)).map{ |file|
|
58
|
+
if file.to_s =~ %r{\.git/}
|
59
|
+
nil
|
60
|
+
else
|
61
|
+
file.to_s
|
62
|
+
end
|
63
|
+
}.compact.sort
|
64
|
+
end
|
65
|
+
|
66
|
+
def gem_files
|
67
|
+
@gem_files ||= all_files - ignored_files
|
68
|
+
end
|
69
|
+
|
70
|
+
def ignored_files
|
71
|
+
@ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
|
72
|
+
path =~ ignore && !git_files.include?(path)}}
|
73
|
+
end
|
74
|
+
|
75
|
+
def git_files
|
76
|
+
@git_files ||= if File.exist?("#{dir}/.git")
|
77
|
+
`git ls-files`.split("\n")
|
78
|
+
else
|
79
|
+
[]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# protected
|
84
|
+
def find_files path
|
85
|
+
path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
|
86
|
+
path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
|
87
|
+
end
|
88
|
+
|
89
|
+
def ignore_patterns
|
90
|
+
@ignore_files ||= expand_patterns(
|
91
|
+
File.read("#{dir}/.gitignore").split("\n").reject{ |pattern|
|
92
|
+
pattern.strip == ''
|
93
|
+
}).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
|
94
|
+
end
|
95
|
+
|
96
|
+
def expand_patterns pathes
|
97
|
+
pathes.map{ |path|
|
98
|
+
if path !~ /\*/
|
99
|
+
path
|
100
|
+
else
|
101
|
+
expand_patterns(
|
102
|
+
Dir[path] +
|
103
|
+
Pathname.new(File.dirname(path)).children.select(&:directory?).
|
104
|
+
map{ |prefix| "#{prefix}/#{File.basename(path)}" })
|
105
|
+
end
|
106
|
+
}.flatten
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
namespace :gem do
|
111
|
+
|
112
|
+
desc 'Install gem'
|
113
|
+
task :install => [:build] do
|
114
|
+
sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
|
115
|
+
end
|
116
|
+
|
117
|
+
desc 'Build gem'
|
118
|
+
task :build => [:spec] do
|
119
|
+
sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
|
120
|
+
sh("mkdir -p pkg")
|
121
|
+
sh("mv #{Gemgem.gem_tag}.gem pkg/")
|
122
|
+
end
|
123
|
+
|
124
|
+
desc 'Release gem'
|
125
|
+
task :release => [:spec, :check, :build] do
|
126
|
+
sh("git tag #{Gemgem.gem_tag}")
|
127
|
+
sh("git push")
|
128
|
+
sh("git push --tags")
|
129
|
+
sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
|
130
|
+
end
|
131
|
+
|
132
|
+
task :check do
|
133
|
+
ver = Gemgem.spec.version.to_s
|
134
|
+
|
135
|
+
if ENV['VERSION'].nil?
|
136
|
+
puts("\x1b[35mExpected " \
|
137
|
+
"\x1b[33mVERSION\x1b[35m=\x1b[33m#{ver}\x1b[m")
|
138
|
+
exit(1)
|
139
|
+
|
140
|
+
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")
|
144
|
+
exit(2)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end # of gem namespace
|
149
|
+
|
150
|
+
desc 'Run tests in memory'
|
151
|
+
task :test do
|
152
|
+
require 'bacon'
|
153
|
+
Bacon.extend(Bacon::TestUnitOutput)
|
154
|
+
Bacon.summary_on_exit
|
155
|
+
$LOAD_PATH.unshift('lib')
|
156
|
+
Dir['test/**/test_*.rb'].each{ |file| load file }
|
157
|
+
end
|
158
|
+
|
159
|
+
desc 'Run tests with shell'
|
160
|
+
task 'test:shell', :RUBY_OPTS do |t, args|
|
161
|
+
files = Dir['test/**/test_*.rb'].join(' ')
|
162
|
+
|
163
|
+
cmd = [Gem.ruby, args[:RUBY_OPTS],
|
164
|
+
'-I', 'lib', '-S', 'bacon', '--quiet', files]
|
165
|
+
|
166
|
+
sh(cmd.compact.join(' '))
|
167
|
+
end
|
168
|
+
|
169
|
+
desc 'Generate rdoc'
|
170
|
+
task :doc => ['gem:spec'] do
|
171
|
+
sh("yardoc -o rdoc --main README.md" \
|
172
|
+
" --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
|
173
|
+
end
|
174
|
+
|
175
|
+
desc 'Removed ignored files'
|
176
|
+
task :clean => ['gem:spec'] do
|
177
|
+
trash = "~/.Trash/#{Gemgem.spec.name}/"
|
178
|
+
sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
|
179
|
+
Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
|
180
|
+
end
|
181
|
+
|
182
|
+
task :default do
|
183
|
+
puts `#{Gem.ruby} -S #{$PROGRAM_NAME} -T`
|
184
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: readline_buffer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lin Jen-Shin (godfat)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-18 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! 'Let you manipulate Readline.line_buffer
|
15
|
+
|
16
|
+
|
17
|
+
Note, only GNU Readline is supported'
|
18
|
+
email:
|
19
|
+
- godfat (XD) godfat.org
|
20
|
+
executables: []
|
21
|
+
extensions:
|
22
|
+
- ext/readline_buffer_ext/extconf.rb
|
23
|
+
extra_rdoc_files: []
|
24
|
+
files:
|
25
|
+
- .gitignore
|
26
|
+
- .gitmodules
|
27
|
+
- README
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- ext/readline_buffer_ext/extconf.rb
|
31
|
+
- ext/readline_buffer_ext/readline_buffer_ext.c
|
32
|
+
- lib/readline_buffer.rb
|
33
|
+
- lib/readline_buffer/version.rb
|
34
|
+
- readline_buffer.gemspec
|
35
|
+
- task/.gitignore
|
36
|
+
- task/gemgem.rb
|
37
|
+
homepage: https://github.com/godfat/readline_buffer
|
38
|
+
licenses: []
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --main
|
42
|
+
- README
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.7
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Let you manipulate Readline.line_buffer
|
63
|
+
test_files: []
|