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