amalgalite 1.6.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +49 -0
- data/HISTORY.md +346 -0
- data/LICENSE +31 -0
- data/Manifest.txt +104 -0
- data/README.md +65 -0
- data/Rakefile +26 -0
- data/TODO.md +57 -0
- data/bin/amalgalite-pack +147 -0
- data/examples/a.rb +9 -0
- data/examples/blob.rb +88 -0
- data/examples/bootstrap.rb +36 -0
- data/examples/define_aggregate.rb +75 -0
- data/examples/define_function.rb +104 -0
- data/examples/fts5.rb +152 -0
- data/examples/gem-db.rb +94 -0
- data/examples/require_me.rb +11 -0
- data/examples/requires.rb +42 -0
- data/examples/schema-info.rb +34 -0
- data/ext/amalgalite/c/amalgalite.c +355 -0
- data/ext/amalgalite/c/amalgalite.h +151 -0
- data/ext/amalgalite/c/amalgalite_blob.c +240 -0
- data/ext/amalgalite/c/amalgalite_constants.c +1226 -0
- data/ext/amalgalite/c/amalgalite_database.c +1178 -0
- data/ext/amalgalite/c/amalgalite_requires_bootstrap.c +282 -0
- data/ext/amalgalite/c/amalgalite_statement.c +649 -0
- data/ext/amalgalite/c/extconf.rb +62 -0
- data/ext/amalgalite/c/gen_constants.rb +330 -0
- data/ext/amalgalite/c/notes.txt +134 -0
- data/ext/amalgalite/c/sqlite3.c +205352 -0
- data/ext/amalgalite/c/sqlite3.h +10727 -0
- data/ext/amalgalite/c/sqlite3_options.h +4 -0
- data/ext/amalgalite/c/sqlite3ext.h +578 -0
- data/lib/amalgalite.rb +51 -0
- data/lib/amalgalite/2.0/amalgalite.so +0 -0
- data/lib/amalgalite/2.1/amalgalite.so +0 -0
- data/lib/amalgalite/2.2/amalgalite.so +0 -0
- data/lib/amalgalite/2.3/amalgalite.so +0 -0
- data/lib/amalgalite/2.4/amalgalite.so +0 -0
- data/lib/amalgalite/aggregate.rb +67 -0
- data/lib/amalgalite/blob.rb +186 -0
- data/lib/amalgalite/boolean.rb +42 -0
- data/lib/amalgalite/busy_timeout.rb +47 -0
- data/lib/amalgalite/column.rb +99 -0
- data/lib/amalgalite/core_ext/kernel/require.rb +21 -0
- data/lib/amalgalite/csv_table_importer.rb +74 -0
- data/lib/amalgalite/database.rb +984 -0
- data/lib/amalgalite/function.rb +61 -0
- data/lib/amalgalite/index.rb +43 -0
- data/lib/amalgalite/memory_database.rb +15 -0
- data/lib/amalgalite/packer.rb +231 -0
- data/lib/amalgalite/paths.rb +80 -0
- data/lib/amalgalite/profile_tap.rb +131 -0
- data/lib/amalgalite/progress_handler.rb +21 -0
- data/lib/amalgalite/requires.rb +151 -0
- data/lib/amalgalite/schema.rb +225 -0
- data/lib/amalgalite/sqlite3.rb +6 -0
- data/lib/amalgalite/sqlite3/constants.rb +95 -0
- data/lib/amalgalite/sqlite3/database/function.rb +48 -0
- data/lib/amalgalite/sqlite3/database/status.rb +68 -0
- data/lib/amalgalite/sqlite3/status.rb +60 -0
- data/lib/amalgalite/sqlite3/version.rb +55 -0
- data/lib/amalgalite/statement.rb +418 -0
- data/lib/amalgalite/table.rb +91 -0
- data/lib/amalgalite/taps.rb +2 -0
- data/lib/amalgalite/taps/console.rb +27 -0
- data/lib/amalgalite/taps/io.rb +71 -0
- data/lib/amalgalite/trace_tap.rb +35 -0
- data/lib/amalgalite/type_map.rb +63 -0
- data/lib/amalgalite/type_maps/default_map.rb +166 -0
- data/lib/amalgalite/type_maps/storage_map.rb +38 -0
- data/lib/amalgalite/type_maps/text_map.rb +21 -0
- data/lib/amalgalite/version.rb +8 -0
- data/lib/amalgalite/view.rb +26 -0
- data/spec/aggregate_spec.rb +154 -0
- data/spec/amalgalite_spec.rb +4 -0
- data/spec/blob_spec.rb +78 -0
- data/spec/boolean_spec.rb +24 -0
- data/spec/busy_handler.rb +157 -0
- data/spec/data/iso-3166-country.txt +242 -0
- data/spec/data/iso-3166-schema.sql +22 -0
- data/spec/data/iso-3166-subcountry.txt +3995 -0
- data/spec/data/make-iso-db.sh +12 -0
- data/spec/database_spec.rb +508 -0
- data/spec/default_map_spec.rb +92 -0
- data/spec/function_spec.rb +78 -0
- data/spec/integeration_spec.rb +97 -0
- data/spec/iso_3166_database.rb +58 -0
- data/spec/packer_spec.rb +60 -0
- data/spec/paths_spec.rb +28 -0
- data/spec/progress_handler_spec.rb +91 -0
- data/spec/requires_spec.rb +54 -0
- data/spec/rtree_spec.rb +66 -0
- data/spec/schema_spec.rb +131 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/sqlite3/constants_spec.rb +108 -0
- data/spec/sqlite3/database_status_spec.rb +36 -0
- data/spec/sqlite3/status_spec.rb +22 -0
- data/spec/sqlite3/version_spec.rb +28 -0
- data/spec/sqlite3_spec.rb +53 -0
- data/spec/statement_spec.rb +168 -0
- data/spec/storage_map_spec.rb +38 -0
- data/spec/tap_spec.rb +57 -0
- data/spec/text_map_spec.rb +20 -0
- data/spec/type_map_spec.rb +14 -0
- data/spec/version_spec.rb +8 -0
- data/tasks/custom.rake +102 -0
- data/tasks/default.rake +240 -0
- data/tasks/extension.rake +38 -0
- data/tasks/this.rb +208 -0
- metadata +318 -0
data/tasks/default.rake
ADDED
@@ -0,0 +1,240 @@
|
|
1
|
+
# vim: syntax=ruby
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'digest'
|
4
|
+
#------------------------------------------------------------------------------
|
5
|
+
# If you want to Develop on this project just run 'rake develop' and you'll
|
6
|
+
# have all you need to get going. If you want to use bundler for development,
|
7
|
+
# then run 'rake develop:using_bundler'
|
8
|
+
#------------------------------------------------------------------------------
|
9
|
+
namespace :develop do
|
10
|
+
|
11
|
+
# Install all the development and runtime dependencies of this gem using the
|
12
|
+
# gemspec.
|
13
|
+
task :default => 'Gemfile' do
|
14
|
+
require 'rubygems/dependency_installer'
|
15
|
+
installer = ::Gem::DependencyInstaller.new
|
16
|
+
puts "Installing bundler..."
|
17
|
+
installer.install 'bundler'
|
18
|
+
sh 'bundle install'
|
19
|
+
puts "\n\nNow run 'rake test'"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create a Gemfile that just references the gemspec
|
23
|
+
file 'Gemfile' => :gemspec do
|
24
|
+
File.open( "Gemfile", "w+" ) do |f|
|
25
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
26
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
27
|
+
f.puts 'source "https://rubygems.org"'
|
28
|
+
f.puts 'gemspec'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
desc "Bootstrap development"
|
33
|
+
task :develop => "develop:default"
|
34
|
+
|
35
|
+
#------------------------------------------------------------------------------
|
36
|
+
# RSpec - standard TestTask
|
37
|
+
#------------------------------------------------------------------------------
|
38
|
+
begin
|
39
|
+
require 'rspec/core/rake_task'
|
40
|
+
RSpec::Core::RakeTask.new( :test ) do |t|
|
41
|
+
t.ruby_opts = %w[ -w ]
|
42
|
+
t.rspec_opts = %w[ --color --format documentation ]
|
43
|
+
end
|
44
|
+
task :test_requirements
|
45
|
+
task :test => :test_requirements
|
46
|
+
task :default => :test
|
47
|
+
rescue LoadError
|
48
|
+
This.task_warning( 'test' )
|
49
|
+
end
|
50
|
+
|
51
|
+
#------------------------------------------------------------------------------
|
52
|
+
# RDoc - standard rdoc rake task, although we must make sure to use a more
|
53
|
+
# recent version of rdoc since it is the one that has 'tomdoc' markup
|
54
|
+
#------------------------------------------------------------------------------
|
55
|
+
begin
|
56
|
+
gem 'rdoc' # otherwise we get the wrong task from stdlib
|
57
|
+
require 'rdoc/task'
|
58
|
+
RDoc::Task.new do |t|
|
59
|
+
t.markup = 'tomdoc'
|
60
|
+
t.rdoc_dir = 'doc'
|
61
|
+
t.main = 'README.md'
|
62
|
+
t.title = "#{This.name} #{This.version}"
|
63
|
+
t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
|
64
|
+
FileList['lib/**/*.rb'] )
|
65
|
+
end
|
66
|
+
rescue StandardError, LoadError
|
67
|
+
This.task_warning( 'rdoc' )
|
68
|
+
end
|
69
|
+
|
70
|
+
#------------------------------------------------------------------------------
|
71
|
+
# Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
|
72
|
+
# for the moment only rcov is listed.
|
73
|
+
#------------------------------------------------------------------------------
|
74
|
+
begin
|
75
|
+
require 'simplecov'
|
76
|
+
desc 'Run tests with code coverage'
|
77
|
+
task :coverage do
|
78
|
+
ENV['COVERAGE'] = 'true'
|
79
|
+
Rake::Task[:test].execute
|
80
|
+
end
|
81
|
+
CLOBBER << 'coverage' if File.directory?( 'coverage' )
|
82
|
+
rescue LoadError
|
83
|
+
This.task_warning( 'simplecov' )
|
84
|
+
end
|
85
|
+
|
86
|
+
#------------------------------------------------------------------------------
|
87
|
+
# Manifest - We want an explicit list of thos files that are to be packaged in
|
88
|
+
# the gem. Most of this is from Hoe.
|
89
|
+
#------------------------------------------------------------------------------
|
90
|
+
namespace 'manifest' do
|
91
|
+
desc "Check the manifest"
|
92
|
+
task :check => :clean do
|
93
|
+
files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
|
94
|
+
files = files.select{ |f| File.file?( f ) }
|
95
|
+
|
96
|
+
tmp = "Manifest.tmp"
|
97
|
+
File.open( tmp, 'w' ) do |f|
|
98
|
+
f.puts files.join("\n")
|
99
|
+
end
|
100
|
+
|
101
|
+
begin
|
102
|
+
sh "diff -du Manifest.txt #{tmp}"
|
103
|
+
ensure
|
104
|
+
rm tmp
|
105
|
+
end
|
106
|
+
puts "Manifest looks good"
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "Generate the manifest"
|
110
|
+
task :generate => :clean do
|
111
|
+
files = %x[ git ls-files ].split("\n").sort
|
112
|
+
files.reject! { |f| f =~ This.exclude_from_manifest }
|
113
|
+
File.open( "Manifest.txt", "w" ) do |f|
|
114
|
+
f.puts files.join("\n")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
#------------------------------------------------------------------------------
|
120
|
+
# Fixme - look for fixmes and report them
|
121
|
+
#------------------------------------------------------------------------------
|
122
|
+
namespace :fixme do
|
123
|
+
task :default => 'manifest:check' do
|
124
|
+
This.manifest.each do |file|
|
125
|
+
next if file == __FILE__
|
126
|
+
next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
|
127
|
+
puts "FIXME: Rename #{file}" if file =~ /fixme/i
|
128
|
+
IO.readlines( file ).each_with_index do |line, idx|
|
129
|
+
prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
|
130
|
+
puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def fixme_project_root
|
136
|
+
This.project_path( '../fixme' )
|
137
|
+
end
|
138
|
+
|
139
|
+
def fixme_project_path( subtree )
|
140
|
+
fixme_project_root.join( subtree )
|
141
|
+
end
|
142
|
+
|
143
|
+
def local_fixme_files
|
144
|
+
This.manifest.select { |p| p =~ %r|^tasks/| }
|
145
|
+
end
|
146
|
+
|
147
|
+
def outdated_fixme_files
|
148
|
+
local_fixme_files.select do |local|
|
149
|
+
upstream = fixme_project_path( local )
|
150
|
+
upstream.exist? &&
|
151
|
+
( Digest::SHA256.file( local ) != Digest::SHA256.file( upstream ) )
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def fixme_up_to_date?
|
156
|
+
outdated_fixme_files.empty?
|
157
|
+
end
|
158
|
+
|
159
|
+
desc "See if the fixme tools are outdated"
|
160
|
+
task :outdated => :release_check do
|
161
|
+
if fixme_up_to_date? then
|
162
|
+
puts "Fixme files are up to date."
|
163
|
+
else
|
164
|
+
outdated_fixme_files.each do |f|
|
165
|
+
puts "#{f} is outdated"
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
desc "Update outdated fixme files"
|
171
|
+
task :update => :release_check do
|
172
|
+
if fixme_up_to_date? then
|
173
|
+
puts "Fixme files are already up to date."
|
174
|
+
else
|
175
|
+
puts "Updating fixme files:"
|
176
|
+
outdated_fixme_files.each do |local|
|
177
|
+
upstream = fixme_project_path( local )
|
178
|
+
puts " * #{local}"
|
179
|
+
FileUtils.cp( upstream, local )
|
180
|
+
end
|
181
|
+
puts "Use your git commands as appropriate."
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
desc "Look for fixmes and report them"
|
186
|
+
task :fixme => "fixme:default"
|
187
|
+
|
188
|
+
#------------------------------------------------------------------------------
|
189
|
+
# Gem Specification
|
190
|
+
#------------------------------------------------------------------------------
|
191
|
+
# Really this is only here to support those who use bundler
|
192
|
+
desc "Build the #{This.name}.gemspec file"
|
193
|
+
task :gemspec do
|
194
|
+
File.open( This.gemspec_file, "wb+" ) do |f|
|
195
|
+
f.puts "# DO NOT EDIT - This file is automatically generated"
|
196
|
+
f.puts "# Make changes to Manifest.txt and/or Rakefile and regenerate"
|
197
|
+
f.write This.platform_gemspec.to_ruby
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# .rbc files from ruby 2.0
|
202
|
+
CLOBBER << FileList["**/*.rbc"]
|
203
|
+
|
204
|
+
# The standard gem packaging task, everyone has it.
|
205
|
+
require 'rubygems/package_task'
|
206
|
+
::Gem::PackageTask.new( This.platform_gemspec ) do
|
207
|
+
# nothing
|
208
|
+
end
|
209
|
+
|
210
|
+
#------------------------------------------------------------------------------
|
211
|
+
# Release - the steps we go through to do a final release, this is pulled from
|
212
|
+
# a compbination of mojombo's rakegem, hoe and hoe-git
|
213
|
+
#
|
214
|
+
# 1) make sure we are on the master branch
|
215
|
+
# 2) make sure there are no uncommitted items
|
216
|
+
# 3) check the manifest and make sure all looks good
|
217
|
+
# 4) build the gem
|
218
|
+
# 5) do an empty commit to have the commit message of the version
|
219
|
+
# 6) tag that commit as the version
|
220
|
+
# 7) push master
|
221
|
+
# 8) push the tag
|
222
|
+
# 7) pus the gem
|
223
|
+
#------------------------------------------------------------------------------
|
224
|
+
task :release_check do
|
225
|
+
unless `git branch` =~ /^\* master$/
|
226
|
+
abort "You must be on the master branch to release!"
|
227
|
+
end
|
228
|
+
unless `git status` =~ /^nothing to commit/m
|
229
|
+
abort "Nope, sorry, you have unfinished business"
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
|
234
|
+
task :release => [ :release_check, 'manifest:check', :gem ] do
|
235
|
+
sh "git commit --allow-empty -a -m 'Release #{This.version}'"
|
236
|
+
sh "git tag -a -m 'v#{This.version}' v#{This.version}"
|
237
|
+
sh "git push origin master"
|
238
|
+
sh "git push origin v#{This.version}"
|
239
|
+
sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
|
240
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# To be used if the gem has extensions.
|
2
|
+
# If this task set is inclueded then you will need to also have
|
3
|
+
#
|
4
|
+
# spec.add_development_dependency( 'rake-compiler', '~> 0.8.1' )
|
5
|
+
#
|
6
|
+
# in your top level rakefile
|
7
|
+
begin
|
8
|
+
require 'rake/extensiontask'
|
9
|
+
require 'rake/javaextensiontask'
|
10
|
+
|
11
|
+
if RUBY_PLATFORM == "java" then
|
12
|
+
|
13
|
+
Rake::JavaExtensionTask.new( This.name) do |ext|
|
14
|
+
ext.ext_dir = File.join( 'ext', This.name, "java" )
|
15
|
+
ext.lib_dir = File.join( 'lib', This.name )
|
16
|
+
ext.gem_spec = This.java_gemspec
|
17
|
+
end
|
18
|
+
|
19
|
+
else
|
20
|
+
|
21
|
+
Rake::ExtensionTask.new( This.name ) do |ext|
|
22
|
+
ext.ext_dir = File.join( 'ext', This.name, "c" )
|
23
|
+
ext.lib_dir = File.join( 'lib', This.name )
|
24
|
+
ext.gem_spec = This.ruby_gemspec
|
25
|
+
|
26
|
+
ext.cross_compile = true # enable cross compilation (requires cross compile toolchain)
|
27
|
+
ext.cross_platform = %w[x86-mingw32 x64-mingw32] # forces the Windows platform instead of the default one
|
28
|
+
# configure options only for cross compile
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
task :test_requirements => :compile
|
33
|
+
rescue LoadError
|
34
|
+
This.task_warning( 'extension' )
|
35
|
+
end
|
36
|
+
|
37
|
+
CLOBBER << FileList["lib/**/*.{jar,so,bundle}"]
|
38
|
+
CLOBBER << FileList["lib/#{This.name}/{1,2}.*/"]
|
data/tasks/this.rb
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
# Public: A Class containing all the metadata and utilities needed to manage a
|
4
|
+
# ruby project.
|
5
|
+
class ThisProject
|
6
|
+
# The name of this project
|
7
|
+
attr_accessor :name
|
8
|
+
|
9
|
+
# The author's name
|
10
|
+
attr_accessor :author
|
11
|
+
|
12
|
+
# The email address of the author(s)
|
13
|
+
attr_accessor :email
|
14
|
+
|
15
|
+
# The homepage of this project
|
16
|
+
attr_accessor :homepage
|
17
|
+
|
18
|
+
# The regex of files to exclude from the manifest
|
19
|
+
attr_accessor :exclude_from_manifest
|
20
|
+
|
21
|
+
# The hash of Gem::Specifications keyed' by platform
|
22
|
+
attr_accessor :gemspecs
|
23
|
+
|
24
|
+
# Public: Initialize ThisProject
|
25
|
+
#
|
26
|
+
# Yields self
|
27
|
+
def initialize(&block)
|
28
|
+
@exclude_from_manifest = Regexp.union(/\.(git|DS_Store)/,
|
29
|
+
/^(doc|coverage|pkg|tmp|Gemfile(\.lock)?)/,
|
30
|
+
/^[^\/]+\.gemspec/,
|
31
|
+
/\.(swp|jar|bundle|so|rvmrc|travis.yml)$/,
|
32
|
+
/~$/)
|
33
|
+
@gemspecs = Hash.new
|
34
|
+
yield self if block_given?
|
35
|
+
end
|
36
|
+
|
37
|
+
# Public: return the version of ThisProject
|
38
|
+
#
|
39
|
+
# Search the ruby files in the project looking for the one that has the
|
40
|
+
# version string in it. This does not eval any code in the project, it parses
|
41
|
+
# the source code looking for the string.
|
42
|
+
#
|
43
|
+
# Returns a String version
|
44
|
+
def version
|
45
|
+
[ "lib/#{ name }.rb", "lib/#{ name }/version.rb" ].each do |v|
|
46
|
+
path = project_path( v )
|
47
|
+
line = path.read[/^\s*VERSION\s*=\s*.*/]
|
48
|
+
if line then
|
49
|
+
return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Internal: Return a section of an RDoc file with the given section name
|
55
|
+
#
|
56
|
+
# path - the relative path in the project of the file to parse
|
57
|
+
# section_name - the section out of the file from which to parse data
|
58
|
+
#
|
59
|
+
# Retuns the text of the section as an array of paragrphs.
|
60
|
+
def section_of( file, section_name )
|
61
|
+
re = /^[=#]+ (.*)$/
|
62
|
+
sectional = project_path( file )
|
63
|
+
parts = sectional.read.split( re )[1..-1]
|
64
|
+
parts.map! { |p| p.strip }
|
65
|
+
|
66
|
+
sections = Hash.new
|
67
|
+
Hash[*parts].each do |k,v|
|
68
|
+
sections[k] = v.split("\n\n")
|
69
|
+
end
|
70
|
+
return sections[section_name]
|
71
|
+
end
|
72
|
+
|
73
|
+
# Internal: print out a warning about the give task
|
74
|
+
def task_warning( task )
|
75
|
+
warn "WARNING: '#{task}' tasks are not defined. Please run 'rake develop'"
|
76
|
+
end
|
77
|
+
|
78
|
+
# Internal: Return the full path to the file that is relative to the project
|
79
|
+
# root.
|
80
|
+
#
|
81
|
+
# path - the relative path of the file from the project root
|
82
|
+
#
|
83
|
+
# Returns the Pathname of the file
|
84
|
+
def project_path( *relative_path )
|
85
|
+
project_root.join( *relative_path )
|
86
|
+
end
|
87
|
+
|
88
|
+
# Internal: The absolute path of this file
|
89
|
+
#
|
90
|
+
# Returns the Pathname of this file.
|
91
|
+
def this_file_path
|
92
|
+
Pathname.new( __FILE__ ).expand_path
|
93
|
+
end
|
94
|
+
|
95
|
+
# Internal: The root directory of this project
|
96
|
+
#
|
97
|
+
# This is defined as being the directory that is in the path of this project
|
98
|
+
# that has the first Rakefile
|
99
|
+
#
|
100
|
+
# Returns the Pathname of the directory
|
101
|
+
def project_root
|
102
|
+
this_file_path.ascend do |p|
|
103
|
+
rakefile = p.join( 'Rakefile' )
|
104
|
+
return p if rakefile.exist?
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Internal: Returns the contents of the Manifest.txt file as an array
|
109
|
+
#
|
110
|
+
# Returns an Array of strings
|
111
|
+
def manifest
|
112
|
+
manifest_file = project_path( "Manifest.txt" )
|
113
|
+
abort "You need a Manifest.txt" unless manifest_file.readable?
|
114
|
+
manifest_file.readlines.map { |l| l.strip }
|
115
|
+
end
|
116
|
+
|
117
|
+
# Internal: Return the files that define the extensions
|
118
|
+
#
|
119
|
+
# Returns an Array
|
120
|
+
def extension_conf_files
|
121
|
+
manifest.grep( /extconf.rb\Z/ )
|
122
|
+
end
|
123
|
+
|
124
|
+
# Internal: Returns the gemspace associated with the current ruby platform
|
125
|
+
def platform_gemspec
|
126
|
+
gemspecs.fetch(platform) { This.ruby_gemspec }
|
127
|
+
end
|
128
|
+
|
129
|
+
def core_gemspec
|
130
|
+
Gem::Specification.new do |spec|
|
131
|
+
spec.name = name
|
132
|
+
spec.version = version
|
133
|
+
spec.author = author
|
134
|
+
spec.email = email
|
135
|
+
spec.homepage = homepage
|
136
|
+
|
137
|
+
spec.summary = summary
|
138
|
+
spec.description = description
|
139
|
+
spec.license = license
|
140
|
+
|
141
|
+
spec.files = manifest
|
142
|
+
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
143
|
+
spec.test_files = spec.files.grep(/^spec/)
|
144
|
+
|
145
|
+
spec.extra_rdoc_files += spec.files.grep(/(txt|rdoc|md)$/)
|
146
|
+
spec.rdoc_options = [ "--main" , 'README.md',
|
147
|
+
"--markup", "tomdoc" ]
|
148
|
+
|
149
|
+
spec.required_ruby_version = '>= 1.9.3'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# Internal: Return the gemspec for the ruby platform
|
154
|
+
def ruby_gemspec( core = core_gemspec, &block )
|
155
|
+
yielding_gemspec( 'ruby', core, &block )
|
156
|
+
end
|
157
|
+
|
158
|
+
# Internal: Return the gemspec for the jruby platform
|
159
|
+
def java_gemspec( core = core_gemspec, &block )
|
160
|
+
yielding_gemspec( 'java', core, &block )
|
161
|
+
end
|
162
|
+
|
163
|
+
# Internal: give an initial spec and a key, create a new gemspec based off of
|
164
|
+
# it.
|
165
|
+
#
|
166
|
+
# This will force the new gemspecs 'platform' to be that of the key, since the
|
167
|
+
# only reason you would have multiple gemspecs at this point is to deal with
|
168
|
+
# different platforms.
|
169
|
+
def yielding_gemspec( key, core )
|
170
|
+
spec = gemspecs[key] ||= core.dup
|
171
|
+
spec.platform = key
|
172
|
+
yield spec if block_given?
|
173
|
+
return spec
|
174
|
+
end
|
175
|
+
|
176
|
+
# Internal: Return the platform of ThisProject at the current moment in time.
|
177
|
+
def platform
|
178
|
+
(RUBY_PLATFORM == "java") ? 'java' : Gem::Platform::RUBY
|
179
|
+
end
|
180
|
+
|
181
|
+
# Internal: Return the DESCRIPTION section of the README.rdoc file
|
182
|
+
def description_section
|
183
|
+
section_of( 'README.md', 'DESCRIPTION')
|
184
|
+
end
|
185
|
+
|
186
|
+
# Internal: Return the summary text from the README
|
187
|
+
def summary
|
188
|
+
description_section.first
|
189
|
+
end
|
190
|
+
|
191
|
+
# Internal: Return the full description text from the README
|
192
|
+
def description
|
193
|
+
description_section.join(" ").tr("\n", ' ').gsub(/[{}]/,'').gsub(/\[[^\]]+\]/,'') # strip rdoc
|
194
|
+
end
|
195
|
+
|
196
|
+
def license
|
197
|
+
license_file = project_path("LICENSE")
|
198
|
+
line = license_file.readlines.first
|
199
|
+
line.split(/\s+/).first
|
200
|
+
end
|
201
|
+
|
202
|
+
# Internal: The path to the gemspec file
|
203
|
+
def gemspec_file
|
204
|
+
project_path( "#{ name }.gemspec" )
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
This = ThisProject.new
|