amalgalite 1.1.2-x86-mswin32 → 1.3.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +49 -0
  3. data/{HISTORY.rdoc → HISTORY.md} +96 -73
  4. data/LICENSE +2 -2
  5. data/Manifest.txt +104 -0
  6. data/README.md +73 -0
  7. data/Rakefile +25 -0
  8. data/TODO.md +50 -0
  9. data/ext/amalgalite/{amalgalite3.c → c/amalgalite.c} +12 -12
  10. data/ext/amalgalite/{amalgalite3.h → c/amalgalite.h} +5 -5
  11. data/ext/amalgalite/{amalgalite3_blob.c → c/amalgalite_blob.c} +2 -2
  12. data/ext/amalgalite/{amalgalite3_constants.c → c/amalgalite_constants.c} +2 -2
  13. data/ext/amalgalite/{amalgalite3_database.c → c/amalgalite_database.c} +49 -21
  14. data/ext/amalgalite/{amalgalite3_requires_bootstrap.c → c/amalgalite_requires_bootstrap.c} +131 -58
  15. data/ext/amalgalite/{amalgalite3_statement.c → c/amalgalite_statement.c} +2 -2
  16. data/ext/amalgalite/{extconf.rb → c/extconf.rb} +4 -4
  17. data/ext/amalgalite/{gen_constants.rb → c/gen_constants.rb} +3 -3
  18. data/ext/amalgalite/c/notes.txt +134 -0
  19. data/ext/amalgalite/{sqlite3.c → c/sqlite3.c} +94602 -80497
  20. data/ext/amalgalite/{sqlite3.h → c/sqlite3.h} +1047 -216
  21. data/ext/amalgalite/{sqlite3_options.h → c/sqlite3_options.h} +0 -0
  22. data/ext/amalgalite/{sqlite3ext.h → c/sqlite3ext.h} +40 -13
  23. data/lib/amalgalite.rb +13 -6
  24. data/lib/amalgalite/1.8/amalgalite.so +0 -0
  25. data/lib/amalgalite/1.9/amalgalite.so +0 -0
  26. data/lib/amalgalite/2.0/amalgalite.so +0 -0
  27. data/lib/amalgalite/column.rb +7 -5
  28. data/lib/amalgalite/database.rb +18 -10
  29. data/lib/amalgalite/packer.rb +5 -2
  30. data/lib/amalgalite/requires.rb +47 -16
  31. data/lib/amalgalite/schema.rb +63 -36
  32. data/lib/amalgalite/sqlite3/version.rb +0 -1
  33. data/lib/amalgalite/statement.rb +7 -5
  34. data/lib/amalgalite/table.rb +9 -8
  35. data/lib/amalgalite/type_maps/default_map.rb +0 -1
  36. data/lib/amalgalite/type_maps/storage_map.rb +0 -2
  37. data/lib/amalgalite/type_maps/text_map.rb +0 -1
  38. data/lib/amalgalite/version.rb +3 -32
  39. data/spec/aggregate_spec.rb +1 -1
  40. data/spec/amalgalite_spec.rb +1 -1
  41. data/spec/blob_spec.rb +1 -1
  42. data/spec/boolean_spec.rb +2 -1
  43. data/spec/busy_handler.rb +1 -1
  44. data/spec/database_spec.rb +16 -11
  45. data/spec/default_map_spec.rb +1 -1
  46. data/spec/function_spec.rb +1 -1
  47. data/spec/integeration_spec.rb +2 -1
  48. data/spec/packer_spec.rb +4 -4
  49. data/spec/paths_spec.rb +1 -1
  50. data/spec/progress_handler_spec.rb +4 -5
  51. data/spec/requires_spec.rb +36 -2
  52. data/spec/rtree_spec.rb +6 -5
  53. data/spec/schema_spec.rb +28 -20
  54. data/spec/spec_helper.rb +2 -7
  55. data/spec/sqlite3/constants_spec.rb +1 -1
  56. data/spec/sqlite3/database_status_spec.rb +4 -4
  57. data/spec/sqlite3/status_spec.rb +5 -5
  58. data/spec/sqlite3/version_spec.rb +7 -7
  59. data/spec/sqlite3_spec.rb +3 -3
  60. data/spec/statement_spec.rb +3 -4
  61. data/spec/storage_map_spec.rb +1 -1
  62. data/spec/tap_spec.rb +4 -4
  63. data/spec/text_map_spec.rb +1 -1
  64. data/spec/type_map_spec.rb +1 -1
  65. data/spec/version_spec.rb +2 -9
  66. data/tasks/custom.rake +99 -0
  67. data/tasks/default.rake +277 -0
  68. data/tasks/extension.rake +28 -202
  69. data/tasks/this.rb +209 -0
  70. metadata +102 -191
  71. data/README.rdoc +0 -54
  72. data/gemspec.rb +0 -63
  73. data/lib/amalgalite/1.8/amalgalite3.so +0 -0
  74. data/lib/amalgalite/1.9/amalgalite3.so +0 -0
  75. data/tasks/announce.rake +0 -44
  76. data/tasks/config.rb +0 -107
  77. data/tasks/distribution.rake +0 -77
  78. data/tasks/documentation.rake +0 -36
  79. data/tasks/rspec.rake +0 -30
  80. data/tasks/utils.rb +0 -80
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,5 @@
1
- require 'rubygems'
2
1
  require 'rspec'
3
2
 
4
- $:.unshift File.expand_path(File.join(File.dirname(__FILE__),"..","lib"))
5
- require 'amalgalite/paths'
6
- $:.unshift Amalgalite::Paths.root_dir
7
-
8
3
  require 'amalgalite'
9
4
  require Amalgalite::Paths.spec_path( "iso_3166_database.rb" )
10
5
 
@@ -19,7 +14,7 @@ class SpecInfo
19
14
  end
20
15
 
21
16
  def make_clone_iso_db
22
- new_path = make_master_iso_db.duplicate( 'testing' )
17
+ make_master_iso_db.duplicate( 'testing' )
23
18
  end
24
19
  end
25
20
  end
@@ -36,7 +31,7 @@ RSpec.configure do |config|
36
31
  config.before( :each ) do
37
32
  @iso_db_path = SpecInfo.make_clone_iso_db
38
33
  @iso_db = Amalgalite::Database.new( @iso_db_path )
39
- @schema = IO.read( Amalgalite::Iso3166Database.schema_file )
34
+ @schema = IO.read( Amalgalite::Iso3166Database.schema_file )
40
35
  end
41
36
 
42
37
  config.after( :each ) do
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),%w[ .. spec_helper.rb ]))
1
+ require 'spec_helper'
2
2
 
3
3
  require 'amalgalite/sqlite3/constants'
4
4
 
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/sqlite3'
3
3
  require 'rbconfig'
4
4
 
@@ -18,14 +18,14 @@ describe "Amalgalite::SQLite3::Database::Status" do
18
18
 
19
19
 
20
20
  it "knows how much lookaside memory it has used" do
21
- @db.api.status.lookaside_used.highwater.should > 0
22
- @db.api.status.lookaside_used.current.should >= 0
21
+ @db.api.status.lookaside_used.highwater.should be > 0
22
+ @db.api.status.lookaside_used.current.should be >= 0
23
23
  end
24
24
 
25
25
  it "can reset the highwater value" do
26
26
  stat = @db.api.status.lookaside_used
27
27
  before = stat.highwater
28
- before.should > 0
28
+ before.should be > 0
29
29
 
30
30
  stat.reset!
31
31
  after = stat.highwater
@@ -1,20 +1,20 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/sqlite3'
3
3
  require 'rbconfig'
4
4
 
5
5
  describe "Amalgalite::SQLite3::Status" do
6
6
  it "knows how much memory it has used" do
7
- Amalgalite::SQLite3.status.memory_used.current.should >= 0
8
- Amalgalite::SQLite3.status.memory_used.highwater.should >= 0
7
+ Amalgalite::SQLite3.status.memory_used.current.should be >= 0
8
+ Amalgalite::SQLite3.status.memory_used.highwater.should be >= 0
9
9
  end
10
10
 
11
11
  it "can reset the highwater value" do
12
12
  before = Amalgalite::SQLite3.status.memory_used.highwater
13
- before.should > 0
13
+ before.should be > 0
14
14
 
15
15
  current = Amalgalite::SQLite3.status.memory_used.current
16
16
  Amalgalite::SQLite3.status.memory_used.reset!
17
- Amalgalite::SQLite3.status.memory_used.highwater.should == current
17
+ Amalgalite::SQLite3.status.memory_used.highwater.should be == current
18
18
 
19
19
  after = Amalgalite::SQLite3.status.memory_used.highwater
20
20
  after.should_not eql(before)
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),"..","spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/sqlite3/version'
3
3
 
4
4
  describe "Amalgalite::SQLite3::Version" do
@@ -7,16 +7,16 @@ describe "Amalgalite::SQLite3::Version" do
7
7
  Amalgalite::SQLite3::Version.to_s.should =~ /\d\.\d\.\d/
8
8
  Amalgalite::SQLite3::Version.runtime_version.should =~ /\d\.\d\.\d/
9
9
 
10
- Amalgalite::SQLite3::Version.to_i.should eql(3007005)
11
- Amalgalite::SQLite3::Version.runtime_version_number.should eql(3007005)
10
+ Amalgalite::SQLite3::Version.to_i.should eql(3007015)
11
+ Amalgalite::SQLite3::Version.runtime_version_number.should eql(3007015)
12
12
 
13
13
  Amalgalite::SQLite3::Version::MAJOR.should eql(3)
14
14
  Amalgalite::SQLite3::Version::MINOR.should eql(7)
15
- Amalgalite::SQLite3::Version::RELEASE.should eql(5)
15
+ Amalgalite::SQLite3::Version::RELEASE.should eql(15)
16
16
  Amalgalite::SQLite3::Version.to_a.should have(3).items
17
17
 
18
- Amalgalite::SQLite3::Version.compiled_version.should == "3.7.5"
19
- Amalgalite::SQLite3::Version.compiled_version_number.should == 3007005
20
- Amalgalite::SQLite3::Version.compiled_matches_runtime?.should == true
18
+ Amalgalite::SQLite3::Version.compiled_version.should be == "3.7.15.2"
19
+ Amalgalite::SQLite3::Version.compiled_version_number.should be == 3007015
20
+ Amalgalite::SQLite3::Version.compiled_matches_runtime?.should be == true
21
21
  end
22
22
  end
data/spec/sqlite3_spec.rb CHANGED
@@ -1,10 +1,10 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/sqlite3'
3
3
  require 'rbconfig'
4
4
 
5
5
  describe "Amalgalite::SQLite3" do
6
- it "is threadsafe is ruby is compiled with pthread support, in this case that is (#{Config::CONFIG['configure_args'].include?( "--enable-pthread" )})" do
7
- Amalgalite::SQLite3.threadsafe?.should eql(Config::CONFIG['configure_args'].include?( "--enable-pthread" ))
6
+ it "is threadsafe is ruby is compiled with pthread support, in this case that is (#{RbConfig::CONFIG['configure_args'].include?( "--enable-pthread" )})" do
7
+ Amalgalite::SQLite3.threadsafe?.should eql(RbConfig::CONFIG['configure_args'].include?( "--enable-pthread" ))
8
8
  end
9
9
 
10
10
  it "knows if an SQL statement is complete" do
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
 
3
3
  describe Amalgalite::Statement do
4
4
  before(:each) do
@@ -125,10 +125,9 @@ describe Amalgalite::Statement do
125
125
  end
126
126
 
127
127
  it "can execute a single sql command and say if there is remaining sql to execute" do
128
- db = Amalgalite::Database.new( SpecInfo.test_db )
129
128
  stmt = @db.prepare( @schema )
130
129
  stmt.execute
131
- stmt.remaining_sql.size.should > 0
130
+ stmt.remaining_sql.size.should be > 0
132
131
  stmt.close
133
132
  end
134
133
 
@@ -148,7 +147,7 @@ describe Amalgalite::Statement do
148
147
  db.execute( "create table t1(c1,c2,c3)" )
149
148
  db.execute("insert into t1(c1,c2,c3) values (1,2,'abc')")
150
149
  db.prepare( "select oid,* from t1" ) do |stmt|
151
- rows = stmt.execute
150
+ stmt.execute
152
151
  stmt.should be_using_rowid_column
153
152
  end
154
153
 
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
  require 'amalgalite/type_maps/storage_map'
3
3
 
4
4
  describe Amalgalite::TypeMaps::StorageMap do
data/spec/tap_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
 
3
3
  require 'amalgalite'
4
4
  require 'amalgalite/trace_tap'
@@ -34,11 +34,11 @@ describe Amalgalite::Taps::StringIO do
34
34
  end
35
35
 
36
36
  it "has a stdout tap" do
37
- s = ::Amalgalite::Taps::Stdout.new
37
+ ::Amalgalite::Taps::Stdout.new
38
38
  end
39
-
39
+
40
40
  it "has a stderr tap" do
41
- s = ::Amalgalite::Taps::Stderr.new
41
+ ::Amalgalite::Taps::Stderr.new
42
42
  end
43
43
  end
44
44
 
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
  require 'amalgalite/type_maps/text_map'
3
3
 
4
4
  describe Amalgalite::TypeMaps::TextMap do
@@ -1,4 +1,4 @@
1
- require File.expand_path( File.join( File.dirname( __FILE__ ), "spec_helper.rb" ) )
1
+ require 'spec_helper'
2
2
  require 'amalgalite/type_map'
3
3
 
4
4
  describe Amalgalite::TypeMap do
data/spec/version_spec.rb CHANGED
@@ -1,15 +1,8 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__),"spec_helper.rb"))
1
+ require 'spec_helper'
2
2
  require 'amalgalite/version'
3
3
 
4
- describe "Amalgalite::Version" do
4
+ describe "Amalgalite::VERSION" do
5
5
  it "should have a version string" do
6
- Amalgalite::Version.to_s.should =~ /\d+\.\d+\.\d+/
7
6
  Amalgalite::VERSION.should =~ /\d+\.\d+\.\d+/
8
7
  end
9
- it "should have a version hash" do
10
- h = Amalgalite::Version.to_hash
11
- [ :major, :minor, :build ].each do |k|
12
- h[k].should_not be_nil
13
- end
14
- end
15
8
  end
data/tasks/custom.rake ADDED
@@ -0,0 +1,99 @@
1
+ #-----------------------------------------------------------------------
2
+ # Custom tasks for this project
3
+ #-----------------------------------------------------------------------
4
+ require 'pathname'
5
+ namespace :util do
6
+ desc "List the sqlite api calls that are not implemented"
7
+ task :todo do
8
+
9
+ not_implementing = %w[
10
+ sqlite3_exec
11
+ sqlite3_open
12
+ sqlite3_os_end
13
+ sqlite3_os_init
14
+ sqlite3_malloc
15
+ sqlite3_realloc
16
+ sqlite3_free
17
+ sqlite3_get_table
18
+ sqlite3_free_table
19
+ sqlite3_key
20
+ sqlite3_rekey
21
+ sqlite3_next_stmt
22
+ sqlite3_release_memory
23
+ sqlite3_sleep
24
+ sqlite3_snprintf
25
+ sqlite3_vmprintf
26
+ sqlite3_strnicmp
27
+ sqlite3_test_control
28
+ sqlite3_unlock_notify
29
+ sqlite3_vfs_find
30
+ sqlite3_vfs_register
31
+ sqlite3_vfs_unregister
32
+ ]
33
+
34
+ sqlite_h = File.join( *%w[ ext amalgalite c sqlite3.h ] )
35
+ api_todo = {}
36
+ IO.readlines( sqlite_h ).each do |line|
37
+ if line =~ /\ASQLITE_API/ then
38
+ if line !~ /SQLITE_DEPRECATED/ and line !~ /SQLITE_EXPERIMENTAL/ then
39
+ if md = line.match( /(sqlite3_[^(\s]+)\(/ ) then
40
+ next if not_implementing.include?(md.captures[0])
41
+ api_todo[md.captures[0]] = true
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ Dir.glob("ext/amalgalite/c/amalgalite*.c").each do |am_file|
48
+ IO.readlines( am_file ).each do |am_line|
49
+ if md = am_line.match( /(sqlite3_[^(\s]+)\(/ ) then
50
+ api_todo.delete( md.captures[0] )
51
+ end
52
+ end
53
+ end
54
+
55
+ puts "#{api_todo.keys.size} functions to still implement"
56
+ puts api_todo.keys.sort.join("\n")
57
+ end
58
+
59
+ desc "Download and integrate the next version of sqlite (use VERSION=x.y.z)"
60
+ task :update_sqlite do
61
+ require 'uri'
62
+ require 'net/http'
63
+ require 'zip'
64
+
65
+ parts = ENV['VERSION'].split(".")
66
+ next_version = [ parts.shift.to_s ]
67
+ parts.each do |p|
68
+ next_version << "#{"%02d" % p }"
69
+ end
70
+ next_version << "00" if next_version.size == 3
71
+
72
+ next_version = next_version.join('')
73
+
74
+ raise "VERSION env variable must be set" unless next_version
75
+ url = ::URI.parse("http://sqlite.org/sqlite-amalgamation-#{next_version}.zip")
76
+ puts "downloading #{url.to_s} ..."
77
+ file = "tmp/#{File.basename( url.path ) }"
78
+ FileUtils.mkdir "tmp" unless File.directory?( "tmp" )
79
+ File.open( file, "wb+") do |f|
80
+ res = Net::HTTP.get_response( url )
81
+ f.write( res.body )
82
+ end
83
+
84
+ puts "extracting..."
85
+ upstream_files = %w[ sqlite3.h sqlite3.c sqlite3ext.h ]
86
+ Zip::ZipInputStream.open( file ) do |io|
87
+ loop do
88
+ entry = io.get_next_entry
89
+ break unless entry
90
+ bname = File.basename( entry.name )
91
+ if upstream_files.include?( bname ) then
92
+ dest_file = File.join( "ext", "amalgalite", "c", bname )
93
+ puts "updating #{dest_file}"
94
+ entry.extract( dest_file ) { true }
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,277 @@
1
+ # vim: syntax=ruby
2
+ require 'rake/clean'
3
+ #------------------------------------------------------------------------------
4
+ # If you want to Develop on this project just run 'rake develop' and you'll
5
+ # have all you need to get going. If you want to use bundler for development,
6
+ # then run 'rake develop:using_bundler'
7
+ #------------------------------------------------------------------------------
8
+ namespace :develop do
9
+
10
+ # Install all the development and runtime dependencies of this gem using the
11
+ # gemspec.
12
+ task :default do
13
+ require 'rubygems/dependency_installer'
14
+ installer = Gem::DependencyInstaller.new
15
+
16
+ This.set_coverage_gem
17
+
18
+ puts "Installing gem depedencies needed for development"
19
+ This.platform_gemspec.dependencies.each do |dep|
20
+ if dep.matching_specs.empty? then
21
+ puts "Installing : #{dep}"
22
+ installer.install dep
23
+ else
24
+ puts "Skipping : #{dep} -> already installed #{dep.matching_specs.first.full_name}"
25
+ end
26
+ end
27
+ puts "\n\nNow run 'rake test'"
28
+ end
29
+
30
+ # Create a Gemfile that just references the gemspec
31
+ file 'Gemfile' => :gemspec do
32
+ File.open( "Gemfile", "w+" ) do |f|
33
+ f.puts 'source :rubygems'
34
+ f.puts 'gemspec'
35
+ end
36
+ end
37
+
38
+ desc "Create a bundler Gemfile"
39
+ task :using_bundler => 'Gemfile' do
40
+ puts "Now you can 'bundle'"
41
+ end
42
+
43
+ # Gemfiles are build artifacts
44
+ CLOBBER << FileList['Gemfile*']
45
+ end
46
+ desc "Boostrap development"
47
+ task :develop => "develop:default"
48
+
49
+ #------------------------------------------------------------------------------
50
+ # Minitest - standard TestTask
51
+ #------------------------------------------------------------------------------
52
+ begin
53
+ require 'rspec/core/rake_task'
54
+ RSpec::Core::RakeTask.new( :test ) do |t|
55
+ t.ruby_opts = %w[ -w ]
56
+ t.rspec_opts = %w[ --color --format documentation ]
57
+ end
58
+
59
+ # require 'rake/testtask'
60
+ # Rake::TestTask.new( :test ) do |t|
61
+ # t.ruby_opts = %w[ -w -rubygems ]
62
+ # t.libs = %w[ lib spec ]
63
+ # t.pattern = "spec/**/*_spec.rb"
64
+ # end
65
+ #
66
+ task :test_requirements
67
+ task :test => :test_requirements
68
+ task :default => :test
69
+ rescue LoadError
70
+ This.task_warning( 'test' )
71
+ end
72
+
73
+ #------------------------------------------------------------------------------
74
+ # RDoc - standard rdoc rake task, although we must make sure to use a more
75
+ # recent version of rdoc since it is the one that has 'tomdoc' markup
76
+ #------------------------------------------------------------------------------
77
+ begin
78
+ gem 'rdoc' # otherwise we get the wrong task from stdlib
79
+ require 'rdoc/task'
80
+ RDoc::Task.new do |t|
81
+ t.markup = 'tomdoc'
82
+ t.rdoc_dir = 'doc'
83
+ t.main = 'README.md'
84
+ t.title = "#{This.name} #{This.version}"
85
+ t.rdoc_files.include( FileList['*.{rdoc,md,txt}'], FileList['ext/**/*.c'],
86
+ FileList['lib/**/*.rb'] )
87
+ end
88
+ rescue LoadError => le
89
+ This.task_warning( 'rdoc' )
90
+ end
91
+
92
+ #------------------------------------------------------------------------------
93
+ # Coverage - optional code coverage, rcov for 1.8 and simplecov for 1.9, so
94
+ # for the moment only rcov is listed.
95
+ #------------------------------------------------------------------------------
96
+ if RUBY_VERSION < "1.9.0"
97
+ begin
98
+ require 'rcov/rcovtask'
99
+ Rcov::RcovTask.new( 'coverage' ) do |t|
100
+ t.libs << 'spec'
101
+ t.pattern = 'spec/**/*_spec.rb'
102
+ t.verbose = true
103
+ t.rcov_opts << "-x ^/" # remove all the global files
104
+ t.rcov_opts << "--sort coverage" # so we see the worst files at the top
105
+ end
106
+ rescue LoadError
107
+ This.task_warning( 'rcov' )
108
+ end
109
+ else
110
+ begin
111
+ require 'simplecov'
112
+ desc 'Run tests with code coverage'
113
+ task :coverage do
114
+ ENV['COVERAGE'] = 'true'
115
+ Rake::Task[:test].execute
116
+ end
117
+ CLOBBER << FileList["coverage"]
118
+ rescue LoadError
119
+ This.task_warning( 'simplecov' )
120
+ end
121
+ end
122
+
123
+ #------------------------------------------------------------------------------
124
+ # Manifest - We want an explicit list of thos files that are to be packaged in
125
+ # the gem. Most of this is from Hoe.
126
+ #------------------------------------------------------------------------------
127
+ namespace 'manifest' do
128
+ desc "Check the manifest"
129
+ task :check => :clean do
130
+ files = FileList["**/*", ".*"].exclude( This.exclude_from_manifest ).to_a.sort
131
+ files = files.select{ |f| File.file?( f ) }
132
+
133
+ tmp = "Manifest.tmp"
134
+ File.open( tmp, 'w' ) do |f|
135
+ f.puts files.join("\n")
136
+ end
137
+
138
+ begin
139
+ sh "diff -du Manifest.txt #{tmp}"
140
+ ensure
141
+ rm tmp
142
+ end
143
+ puts "Manifest looks good"
144
+ end
145
+
146
+ desc "Generate the manifest"
147
+ task :generate => :clean do
148
+ files = %x[ git ls-files ].split("\n").sort
149
+ files.reject! { |f| f =~ This.exclude_from_manifest }
150
+ File.open( "Manifest.txt", "w" ) do |f|
151
+ f.puts files.join("\n")
152
+ end
153
+ end
154
+ end
155
+
156
+ #------------------------------------------------------------------------------
157
+ # Fixme - look for fixmes and report them
158
+ #------------------------------------------------------------------------------
159
+ namespace :fixme do
160
+ task :default => 'manifest:check' do
161
+ This.manifest.each do |file|
162
+ next if file == __FILE__
163
+ next unless file =~ %r/(txt|rb|md|rdoc|css|html|xml|css)\Z/
164
+ puts "FIXME: Rename #{file}" if file =~ /fixme/i
165
+ IO.readlines( file ).each_with_index do |line, idx|
166
+ prefix = "FIXME: #{file}:#{idx+1}".ljust(42)
167
+ puts "#{prefix} => #{line.strip}" if line =~ /fixme/i
168
+ end
169
+ end
170
+ end
171
+
172
+ def fixme_project_root
173
+ This.project_path( '../fixme' )
174
+ end
175
+
176
+ def fixme_project_path( subtree )
177
+ fixme_project_root.join( subtree )
178
+ end
179
+
180
+ def local_fixme_files
181
+ This.manifest.select { |p| p =~ %r|^tasks/| }
182
+ end
183
+
184
+ def outdated_fixme_files
185
+ local_fixme_files.reject do |local|
186
+ upstream = fixme_project_path( local )
187
+ Digest::SHA256.file( local ) == Digest::SHA256.file( upstream )
188
+ end
189
+ end
190
+
191
+ def fixme_up_to_date?
192
+ outdated_fixme_files.empty?
193
+ end
194
+
195
+ desc "See if the fixme tools are outdated"
196
+ task :outdated => :release_check do
197
+ if fixme_up_to_date? then
198
+ puts "Fixme files are up to date."
199
+ else
200
+ outdated_fixme_files.each do |f|
201
+ puts "#{f} is outdated"
202
+ end
203
+ end
204
+ end
205
+
206
+ desc "Update outdated fixme files"
207
+ task :update => :release_check do
208
+ if fixme_up_to_date? then
209
+ puts "Fixme files are already up to date."
210
+ else
211
+ puts "Updating fixme files:"
212
+ outdated_fixme_files.each do |local|
213
+ upstream = fixme_project_path( local )
214
+ puts " * #{local}"
215
+ FileUtils.cp( upstream, local )
216
+ end
217
+ puts "Use your git commands as appropriate."
218
+ end
219
+ end
220
+ end
221
+ desc "Look for fixmes and report them"
222
+ task :fixme => "fixme:default"
223
+
224
+ #------------------------------------------------------------------------------
225
+ # Gem Specification
226
+ #------------------------------------------------------------------------------
227
+ # Really this is only here to support those who use bundler
228
+ desc "Build the #{This.name}.gemspec file"
229
+ task :gemspec do
230
+ File.open( This.gemspec_file, "wb+" ) do |f|
231
+ f.write This.platform_gemspec.to_ruby
232
+ end
233
+ end
234
+
235
+ # the gemspec is also a dev artifact and should not be kept around.
236
+ CLOBBER << This.gemspec_file.to_s
237
+
238
+ # .rbc files from ruby 2.0
239
+ CLOBBER << FileList["**/*.rbc"]
240
+
241
+ # The standard gem packaging task, everyone has it.
242
+ require 'rubygems/package_task'
243
+ Gem::PackageTask.new( This.platform_gemspec ) do
244
+ # nothing
245
+ end
246
+
247
+ #------------------------------------------------------------------------------
248
+ # Release - the steps we go through to do a final release, this is pulled from
249
+ # a compbination of mojombo's rakegem, hoe and hoe-git
250
+ #
251
+ # 1) make sure we are on the master branch
252
+ # 2) make sure there are no uncommitted items
253
+ # 3) check the manifest and make sure all looks good
254
+ # 4) build the gem
255
+ # 5) do an empty commit to have the commit message of the version
256
+ # 6) tag that commit as the version
257
+ # 7) push master
258
+ # 8) push the tag
259
+ # 7) pus the gem
260
+ #------------------------------------------------------------------------------
261
+ task :release_check do
262
+ unless `git branch` =~ /^\* master$/
263
+ abort "You must be on the master branch to release!"
264
+ end
265
+ unless `git status` =~ /^nothing to commit/m
266
+ abort "Nope, sorry, you have unfinished business"
267
+ end
268
+ end
269
+
270
+ desc "Create tag v#{This.version}, build and push #{This.platform_gemspec.full_name} to rubygems.org"
271
+ task :release => [ :release_check, 'manifest:check', :gem ] do
272
+ sh "git commit --allow-empty -a -m 'Release #{This.version}'"
273
+ sh "git tag -a -m 'v#{This.version}' v#{This.version}"
274
+ sh "git push origin master"
275
+ sh "git push origin v#{This.version}"
276
+ sh "gem push pkg/#{This.platform_gemspec.full_name}.gem"
277
+ end