readline_buffer 0.9.2 → 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b5031b695f35a688e56ddddef6a2624b35a737af1e99c5005de1e4369d374fd6
4
+ data.tar.gz: c3e31b1a03f0e16bb63c01c5076b726349be5c318087f7e1a2d4360da94eb509
5
+ SHA512:
6
+ metadata.gz: fca9473a4dddb0774510ceee58542a8285048ed03e842909ce205189df82c4ea42ffaa42eb20c93e5b6972598a7a0b4e796ee23742d364b0f2650c5cb5ed8bd7
7
+ data.tar.gz: 20abbbdbe5e71d570ad3d2b50c6658c556a8f17e8f39f1ebee3826e51e334081a9f181f4edca7569ec94e5fe12237ad2741ac6e52f2cbabdcf9ee97df140b728
data/.gitignore CHANGED
@@ -1,2 +1,2 @@
1
- pkg
1
+ /pkg/
2
2
  *.rbc
data/CHANGES.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # readline_buffer CHANGES
2
2
 
3
+ ## readline_buffer 1.0.0 -- 2020-01-23
4
+
5
+ * Removed the call to rb_secure because it's deprecated in Ruby 2.7
6
+
3
7
  ## readline_buffer 0.9.2 -- 2011-12-14
4
8
 
5
9
  * Puts a warning for Editline (libedit) instead of failing to install it.
data/README.md CHANGED
@@ -5,7 +5,7 @@ by Lin Jen-Shin ([godfat](http://godfat.org))
5
5
  ## LINKS:
6
6
 
7
7
  * [github](https://github.com/godfat/readline_buffer)
8
- * [rubygems](http://rubygems.org/gems/readline_buffer)
8
+ * [rubygems](https://rubygems.org/gems/readline_buffer)
9
9
 
10
10
  ## DESCRIPTION:
11
11
 
@@ -15,7 +15,7 @@ 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 (libedit)
19
19
 
20
20
  ## INSTALLATION:
21
21
 
@@ -30,4 +30,4 @@ Note, only GNU Readline is supported at the moment.
30
30
  GPL 3 if you're compiling against Readline,
31
31
  otherwise Apache License 2.0
32
32
 
33
- Copyright (c) 2011, Lin Jen-Shin (godfat)
33
+ Copyright (c) 2011-2020, Lin Jen-Shin (godfat)
data/Rakefile CHANGED
@@ -1,20 +1,17 @@
1
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
2
+ begin
3
+ require "#{dir = File.dirname(__FILE__)}/task/gemgem"
4
+ rescue LoadError
5
+ sh 'git submodule update --init'
6
+ exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
7
+ end
13
8
 
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
9
+ Gemgem.init(dir) do |s|
10
+ require 'readline_buffer/version'
11
+ s.name = 'readline_buffer'
12
+ s.version = ReadlineBuffer::VERSION
18
13
 
19
- Gemgem.write
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) }
20
17
  end
@@ -3,7 +3,6 @@
3
3
  #include <readline/readline.h>
4
4
 
5
5
  static VALUE readline_buffer_ext(VALUE self, VALUE str){
6
- rb_secure(4);
7
6
  StringValue(str);
8
7
 
9
8
  if(rl_line_buffer == NULL)
@@ -1,4 +1,4 @@
1
1
 
2
2
  module ReadlineBuffer
3
- VERSION = '0.9.2'
3
+ VERSION = '1.0.0'
4
4
  end
@@ -1,39 +1,35 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: readline_buffer 1.0.0 ruby lib
3
+ # stub: ext/readline_buffer_ext/extconf.rb
2
4
 
3
5
  Gem::Specification.new do |s|
4
- s.name = "readline_buffer"
5
- s.version = "0.9.2"
6
+ s.name = "readline_buffer".freeze
7
+ s.version = "1.0.0"
6
8
 
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 = "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"]
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
10
+ s.require_paths = ["lib".freeze]
11
+ s.authors = ["Lin Jen-Shin (godfat)".freeze]
12
+ s.date = "2020-01-23"
13
+ s.description = "Let you manipulate `Readline.line_buffer`\n\nNote, only GNU Readline is supported at the moment.".freeze
14
+ s.email = ["godfat (XD) godfat.org".freeze]
15
+ s.extensions = ["ext/readline_buffer_ext/extconf.rb".freeze]
13
16
  s.files = [
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`"
30
-
31
- if s.respond_to? :specification_version then
32
- s.specification_version = 3
33
-
34
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
35
- else
36
- end
37
- else
38
- end
17
+ ".gitignore".freeze,
18
+ ".gitmodules".freeze,
19
+ "CHANGES.md".freeze,
20
+ "README.md".freeze,
21
+ "Rakefile".freeze,
22
+ "ext/readline_buffer_ext/extconf.rb".freeze,
23
+ "ext/readline_buffer_ext/readline_buffer_ext.c".freeze,
24
+ "lib/readline_buffer.rb".freeze,
25
+ "lib/readline_buffer/version.rb".freeze,
26
+ "readline_buffer.gemspec".freeze,
27
+ "task/README.md".freeze,
28
+ "task/gemgem.rb".freeze]
29
+ s.homepage = "https://github.com/godfat/readline_buffer".freeze
30
+ s.licenses = [
31
+ "GPL 3 if you're compiling against Readline,
32
+ ".freeze]
33
+ s.rubygems_version = "3.0.6".freeze
34
+ s.summary = "Let you manipulate `Readline.line_buffer`".freeze
39
35
  end
@@ -0,0 +1,54 @@
1
+ # Gemgem
2
+
3
+ ## DESCRIPTION:
4
+
5
+ Provided tasks:
6
+
7
+ rake clean # Trash ignored files
8
+ rake gem:build # Build gem
9
+ rake gem:install # Install gem
10
+ rake gem:release # Release gem
11
+ rake gem:spec # Generate gemspec
12
+ rake test # Run tests
13
+
14
+ ## REQUIREMENTS:
15
+
16
+ * Tested with MRI (official CRuby) and JRuby.
17
+
18
+ ## INSTALLATION:
19
+
20
+ git submodule add git://github.com/godfat/gemgem.git task
21
+
22
+ And in Rakefile:
23
+
24
+ ``` ruby
25
+ begin
26
+ require "#{__dir__}/task/gemgem"
27
+ rescue LoadError
28
+ sh 'git submodule update --init --recursive'
29
+ exec Gem.ruby, '-S', $PROGRAM_NAME, *ARGV
30
+ end
31
+
32
+ Gemgem.init(__dir__, :submodules => %w[your-dep]) do |s|
33
+ s.name = 'your-gem'
34
+ s.version = '0.1.0'
35
+ end
36
+ ```
37
+
38
+ ## LICENSE:
39
+
40
+ Apache License 2.0 (Apache-2.0)
41
+
42
+ Copyright (c) 2011-2019, Lin Jen-Shin (godfat)
43
+
44
+ Licensed under the Apache License, Version 2.0 (the "License");
45
+ you may not use this file except in compliance with the License.
46
+ You may obtain a copy of the License at
47
+
48
+ <http://www.apache.org/licenses/LICENSE-2.0>
49
+
50
+ Unless required by applicable law or agreed to in writing, software
51
+ distributed under the License is distributed on an "AS IS" BASIS,
52
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ See the License for the specific language governing permissions and
54
+ limitations under the License.
@@ -1,175 +1,295 @@
1
1
 
2
- require 'pathname'
3
-
4
2
  module Gemgem
5
3
  class << self
6
- attr_accessor :dir, :spec
4
+ attr_accessor :dir, :spec, :submodules, :spec_create
7
5
  end
8
6
 
9
7
  module_function
8
+ def gem_tag ; "#{spec.name}-#{spec.version}" ; end
9
+ def gem_path ; "#{pkg_dir}/#{gem_tag}.gem" ; end
10
+ def spec_path ; "#{dir}/#{spec.name}.gemspec" ; end
11
+ def pkg_dir ; "#{dir}/pkg" ; end
12
+ def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
13
+
14
+ def init dir, options={}, &block
15
+ self.dir = dir
16
+ ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
17
+ ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
18
+ self.submodules = options[:submodules] || []
19
+ self.spec_create = block
20
+
21
+ $LOAD_PATH.unshift("#{dir}/lib", *submodules_libs)
22
+ end
23
+
10
24
  def create
11
- yield(spec = Gem::Specification.new{ |s|
25
+ spec = Gem::Specification.new do |s|
12
26
  s.authors = ['Lin Jen-Shin (godfat)']
13
27
  s.email = ['godfat (XD) godfat.org']
14
28
 
15
29
  s.description = description.join
16
30
  s.summary = description.first
31
+ s.license = license
17
32
 
18
- s.rubygems_version = Gem::VERSION
19
- s.date = Time.now.strftime('%Y-%m-%d')
20
- s.files = gem_files
21
- s.test_files = gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
22
- s.executables = Dir['bin/*'].map{ |f| File.basename(f) }
23
- s.require_paths = %w[lib]
24
- })
33
+ s.date = Time.now.strftime('%Y-%m-%d')
34
+ s.files = gem_files
35
+ s.test_files = test_files
36
+ s.executables = bin_files
37
+ end
38
+ spec_create.call(spec)
25
39
  spec.homepage ||= "https://github.com/godfat/#{spec.name}"
26
- spec
40
+ self.spec = spec
27
41
  end
28
42
 
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
+ def gem_install
44
+ require 'rubygems/commands/install_command'
45
+ # read ~/.gemrc
46
+ Gem.use_paths(Gem.configuration[:gemhome], Gem.configuration[:gempath])
47
+ Gem::Command.extra_args = Gem.configuration[:gem]
48
+
49
+ # setup install options
50
+ cmd = Gem::Commands::InstallCommand.new
51
+ cmd.handle_options([])
52
+
53
+ # install
54
+ install = Gem::Installer.new(gem_path, cmd.options)
55
+ install.install
56
+ puts "\e[35mGem installed: \e[33m#{strip_path(install.gem_dir)}\e[0m"
43
57
  end
44
58
 
45
- def description
46
- @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
59
+ def gem_spec
60
+ create
61
+ write
47
62
  end
48
63
 
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
64
+ def gem_build
65
+ require 'fileutils'
66
+ require 'rubygems/package'
67
+ gem = nil
68
+ Dir.chdir(dir) do
69
+ gem = Gem::Package.build(Gem::Specification.load(spec_path))
70
+ FileUtils.mkdir_p(pkg_dir)
71
+ FileUtils.mv(gem, pkg_dir) # gem is relative path, but might be ok
72
+ end
73
+ puts "\e[35mGem built: \e[33m#{strip_path("#{pkg_dir}/#{gem}")}\e[0m"
61
74
  end
62
75
 
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
76
+ def gem_release
77
+ sh_git('tag', gem_tag)
78
+ sh_git('push')
79
+ sh_git('push', '--tags')
80
+ sh_gem('push', gem_path)
70
81
  end
71
82
 
72
- def ann_html
73
- gem 'nokogiri'
74
- gem 'kramdown'
83
+ def gem_check
84
+ unless git('status', '--porcelain').empty?
85
+ puts("\e[35mWorking copy is not clean.\e[0m")
86
+ exit(3)
87
+ end
88
+
89
+ ver = spec.version.to_s
90
+
91
+ if ENV['VERSION'].nil?
92
+ puts("\e[35mExpected " \
93
+ "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
94
+ exit(1)
75
95
 
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
96
+ elsif ENV['VERSION'] != ver
97
+ puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
98
+ "\e[35mbut got\n " \
99
+ "\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
100
+ exit(2)
83
101
  end
84
102
  end
85
103
 
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"
104
+ def test
105
+ return if test_files.empty?
106
+
107
+ if ENV['COV'] || ENV['CI']
108
+ require 'simplecov'
109
+ if ENV['CI']
110
+ begin
111
+ require 'coveralls'
112
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
113
+ rescue LoadError => e
114
+ puts "Cannot load coveralls, skip: #{e}"
115
+ end
116
+ end
117
+ SimpleCov.start do
118
+ add_filter('test/')
119
+ add_filter('test.rb')
120
+ submodules_libs.each(&method(:add_filter))
121
+ end
122
+ end
123
+
124
+ test_files.each{ |file| require "#{dir}/#{file[0..-4]}" }
93
125
  end
94
126
 
95
- def gem_tag
96
- "#{spec.name}-#{spec.version}"
127
+ def clean
128
+ return if ignored_files.empty?
129
+
130
+ require 'fileutils'
131
+ trash = File.expand_path("~/.Trash/#{spec.name}")
132
+ puts "Move the following files into: \e[35m#{strip_path(trash)}\e[33m"
133
+
134
+ ignored_files.each do |file|
135
+ from = "#{dir}/#{file}"
136
+ to = "#{trash}/#{File.dirname(file)}"
137
+ puts strip_path(from)
138
+
139
+ FileUtils.mkdir_p(to)
140
+ FileUtils.mv(from, to)
141
+ end
142
+
143
+ print "\e[0m"
97
144
  end
98
145
 
99
146
  def write
100
- File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
101
- f << split_lines(spec.to_ruby) }
147
+ File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
102
148
  end
103
149
 
104
150
  def split_lines ruby
105
- ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
151
+ ruby.gsub(/(.+?)\s*=\s*\[(.+?)\]/){ |s|
106
152
  if $2.index(',')
107
- "#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
153
+ "#{$1} = [\n #{$2.split(',').map(&:strip).join(",\n ")}]"
108
154
  else
109
155
  s
110
156
  end
111
157
  }
112
158
  end
113
159
 
160
+ def strip_path path
161
+ strip_home_path(strip_cwd_path(path))
162
+ end
163
+
164
+ def strip_home_path path
165
+ path.sub(/\A#{Regexp.escape(ENV['HOME'])}\//, '~/')
166
+ end
167
+
168
+ def strip_cwd_path path
169
+ path.sub(/\A#{Regexp.escape(Dir.pwd)}\//, '')
170
+ end
171
+
172
+ def submodules_libs
173
+ submodules.map{ |path| "#{dir}/#{path}/lib" }
174
+ end
175
+
176
+ def git *args
177
+ `git --git-dir=#{dir}/.git #{args.join(' ')}`
178
+ end
179
+
180
+ def sh_git *args
181
+ Rake.sh('git', "--git-dir=#{dir}/.git", *args)
182
+ end
183
+
184
+ def sh_gem *args
185
+ Rake.sh(Gem.ruby, '-S', 'gem', *args)
186
+ end
187
+
188
+ def glob path=dir
189
+ Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
190
+ end
191
+
192
+ def readme
193
+ @readme ||=
194
+ if (path = "#{Gemgem.dir}/README.md") && File.exist?(path)
195
+ ps = "##{File.read(path)}".
196
+ scan(/((#+)[^\n]+\n\n.+?(?=(\n\n\2[^#\n]+\n)|\Z))/m).map(&:first)
197
+ ps.inject('HEADER' => ps.first){ |r, s, i|
198
+ r[s[/\w+/]] = s
199
+ r
200
+ }
201
+ else
202
+ {}
203
+ end
204
+ end
205
+
206
+ def description
207
+ # JRuby String#lines is returning an enumerator
208
+ @description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
209
+ end
210
+
211
+ def license
212
+ readme['LICENSE'].sub(/.+\n\n/, '').lines.first.
213
+ split(/[()]/).map(&:strip).reject(&:empty?).last
214
+ end
215
+
114
216
  def all_files
115
- @all_files ||= find_files(Pathname.new(dir)).map{ |file|
116
- if file.to_s =~ %r{\.git/}
117
- nil
217
+ @all_files ||= fold_files(glob).sort
218
+ end
219
+
220
+ def fold_files files
221
+ files.inject([]){ |r, path|
222
+ if File.file?(path) && path !~ %r{/\.git(/|$)} &&
223
+ (rpath = path[%r{^#{escaped_dir}/(.*$)}, 1])
224
+ r << rpath
225
+ elsif File.symlink?(path) # walk into symlinks...
226
+ r.concat(fold_files(glob(File.expand_path(path,
227
+ File.readlink(path)))))
118
228
  else
119
- file.to_s
229
+ r
120
230
  end
121
- }.compact.sort
231
+ }
122
232
  end
123
233
 
124
234
  def gem_files
125
- @gem_files ||= all_files - ignored_files
235
+ @gem_files ||= all_files.reject{ |f|
236
+ f =~ submodules_pattern ||
237
+ (f =~ ignored_pattern && !git_files.include?(f))
238
+ }
126
239
  end
127
240
 
128
- def ignored_files
129
- @ignored_file ||= all_files.select{ |path| ignore_patterns.find{ |ignore|
130
- path =~ ignore && !git_files.include?(path)}}
241
+ def test_files
242
+ @test_files ||= gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
243
+ end
244
+
245
+ def bin_files
246
+ @bin_files ||= gem_files.grep(%r{^bin/}).map{ |f| File.basename(f) }
131
247
  end
132
248
 
133
249
  def git_files
134
250
  @git_files ||= if File.exist?("#{dir}/.git")
135
- `git ls-files`.split("\n")
251
+ git('ls-files').split("\n")
136
252
  else
137
253
  []
138
254
  end
139
255
  end
140
256
 
141
- # protected
142
- def find_files path
143
- path.children.select(&:file?).map{|file| file.to_s[(dir.size+1)..-1]} +
144
- path.children.select(&:directory?).map{|dir| find_files(dir)}.flatten
257
+ def ignored_files
258
+ @ignored_files ||= all_files.grep(ignored_pattern)
259
+ end
260
+
261
+ def ignored_pattern
262
+ @ignored_pattern ||= if gitignore.empty?
263
+ /^$/
264
+ else
265
+ Regexp.new(expand_patterns(gitignore).join('|'))
266
+ end
145
267
  end
146
268
 
147
- def ignore_patterns
148
- @ignore_files ||= expand_patterns(
149
- gitignore.split("\n").reject{ |pattern|
150
- pattern.strip == ''
151
- }).map{ |pattern| %r{^([^/]+/)*?#{Regexp.escape(pattern)}(/[^/]+)*?$} }
269
+ def submodules_pattern
270
+ @submodules_pattern ||= if submodules.empty?
271
+ /^$/
272
+ else
273
+ Regexp.new(submodules.map{ |path|
274
+ "^#{Regexp.escape(path)}/" }.join('|'))
275
+ end
152
276
  end
153
277
 
154
278
  def expand_patterns pathes
155
- pathes.map{ |path|
156
- if path !~ /\*/
157
- path
158
- else
159
- expand_patterns(
160
- Dir[path] +
161
- Pathname.new(File.dirname(path)).children.select(&:directory?).
162
- map{ |prefix| "#{prefix}/#{File.basename(path)}" })
163
- end
164
- }.flatten
279
+ # http://git-scm.com/docs/gitignore
280
+ pathes.flat_map{ |path|
281
+ # we didn't implement negative pattern for now
282
+ Regexp.escape(path).sub(%r{^/}, '^').gsub(/\\\*/, '[^/]*')
283
+ }
165
284
  end
166
285
 
167
286
  def gitignore
168
- if File.exist?(path = "#{dir}/.gitignore")
169
- File.read(path)
170
- else
171
- ''
172
- end
287
+ @gitignore ||= if File.exist?(path = "#{dir}/.gitignore")
288
+ File.read(path).lines.
289
+ reject{ |l| l == /^\s*(#|\s+$)/ }.map(&:strip)
290
+ else
291
+ []
292
+ end
173
293
  end
174
294
  end
175
295
 
@@ -177,89 +297,42 @@ namespace :gem do
177
297
 
178
298
  desc 'Install gem'
179
299
  task :install => [:build] do
180
- sh("#{Gem.ruby} -S gem install pkg/#{Gemgem.gem_tag}")
300
+ Gemgem.gem_install
181
301
  end
182
302
 
183
303
  desc 'Build gem'
184
304
  task :build => [:spec] do
185
- sh("#{Gem.ruby} -S gem build #{Gemgem.spec.name}.gemspec")
186
- sh("mkdir -p pkg")
187
- sh("mv #{Gemgem.gem_tag}.gem pkg/")
305
+ Gemgem.gem_build
306
+ end
307
+
308
+ desc 'Generate gemspec'
309
+ task :spec do
310
+ Gemgem.gem_spec
188
311
  end
189
312
 
190
313
  desc 'Release gem'
191
314
  task :release => [:spec, :check, :build] do
192
- sh("git tag #{Gemgem.gem_tag}")
193
- sh("git push")
194
- sh("git push --tags")
195
- sh("#{Gem.ruby} -S gem push pkg/#{Gemgem.gem_tag}.gem")
315
+ Gemgem.gem_release
196
316
  end
197
317
 
198
318
  task :check do
199
- ver = Gemgem.spec.version.to_s
200
-
201
- if ENV['VERSION'].nil?
202
- puts("\e[35mExpected " \
203
- "\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
204
- exit(1)
205
-
206
- elsif ENV['VERSION'] != ver
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")
210
- exit(2)
211
- end
319
+ Gemgem.gem_check
212
320
  end
213
321
 
214
322
  end # of gem namespace
215
323
 
216
- desc 'Run tests in memory'
324
+ desc 'Run tests'
217
325
  task :test do
218
- require 'bacon'
219
- Bacon.extend(Bacon::TestUnitOutput)
220
- Bacon.summary_on_exit
221
- $LOAD_PATH.unshift('lib')
222
- Dir['./test/**/test_*.rb'].each{ |file| require file[0..-4] }
223
- end
224
-
225
- desc 'Run tests with shell'
226
- task 'test:shell', :RUBY_OPTS do |t, args|
227
- files = Dir['test/**/test_*.rb'].join(' ')
228
-
229
- cmd = [Gem.ruby, args[:RUBY_OPTS],
230
- '-I', 'lib', '-S', 'bacon', '--quiet', files]
231
-
232
- sh(cmd.compact.join(' '))
233
- end
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
-
250
- desc 'Generate rdoc'
251
- task :doc => ['gem:spec'] do
252
- sh("yardoc -o rdoc --main README.md" \
253
- " --files #{Gemgem.spec.extra_rdoc_files.join(',')}")
326
+ Gemgem.test
254
327
  end
255
328
 
256
- desc 'Remove ignored files'
329
+ desc 'Trash ignored files'
257
330
  task :clean => ['gem:spec'] do
258
- trash = "~/.Trash/#{Gemgem.spec.name}/"
259
- sh "mkdir -p #{trash}" unless File.exist?(File.expand_path(trash))
260
- Gemgem.ignored_files.each{ |file| sh "mv #{file} #{trash}" }
331
+ Gemgem.clean
261
332
  end
262
333
 
263
334
  task :default do
264
- puts `#{Gem.ruby} -S #{$PROGRAM_NAME} -T`
335
+ # Is there a reliable way to do this in the current process?
336
+ # It failed miserably before between Rake versions...
337
+ exec "#{Gem.ruby} -S #{$PROGRAM_NAME} -f #{Rake.application.rakefile} -T"
265
338
  end
metadata CHANGED
@@ -1,20 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readline_buffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Lin Jen-Shin (godfat)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-12-14 00:00:00.000000000 Z
11
+ date: 2020-01-23 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: ! 'Let you manipulate `Readline.line_buffer`
13
+ description: |-
14
+ Let you manipulate `Readline.line_buffer`
15
15
 
16
-
17
- Note, only GNU Readline is supported at the moment.'
16
+ Note, only GNU Readline is supported at the moment.
18
17
  email:
19
18
  - godfat (XD) godfat.org
20
19
  executables: []
@@ -22,8 +21,8 @@ extensions:
22
21
  - ext/readline_buffer_ext/extconf.rb
23
22
  extra_rdoc_files: []
24
23
  files:
25
- - .gitignore
26
- - .gitmodules
24
+ - ".gitignore"
25
+ - ".gitmodules"
27
26
  - CHANGES.md
28
27
  - README.md
29
28
  - Rakefile
@@ -32,30 +31,29 @@ files:
32
31
  - lib/readline_buffer.rb
33
32
  - lib/readline_buffer/version.rb
34
33
  - readline_buffer.gemspec
35
- - task/.gitignore
34
+ - task/README.md
36
35
  - task/gemgem.rb
37
36
  homepage: https://github.com/godfat/readline_buffer
38
- licenses: []
37
+ licenses:
38
+ - "GPL 3 if you're compiling against Readline,\n "
39
+ metadata: {}
39
40
  post_install_message:
40
41
  rdoc_options: []
41
42
  require_paths:
42
43
  - lib
43
44
  required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
45
  requirements:
46
- - - ! '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
- none: false
51
50
  requirements:
52
- - - ! '>='
51
+ - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
54
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 1.8.12
55
+ rubygems_version: 3.0.6
58
56
  signing_key:
59
- specification_version: 3
57
+ specification_version: 4
60
58
  summary: Let you manipulate `Readline.line_buffer`
61
59
  test_files: []
@@ -1 +0,0 @@
1
- *.rbc