aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/Rakefile
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-01-28 11:46:54 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-01-28 11:46:54 +1100
commit9029efce410ea49de6eb65481fb2ad8143e69c35 (patch)
tree2ee9742df69c156b4b615e48e095e2c81edbbceb /activesupport/Rakefile
parent32ce2bb37fcc4f41322d69d74d686d08c0bb39c7 (diff)
downloadrails-9029efce410ea49de6eb65481fb2ad8143e69c35.tar.gz
rails-9029efce410ea49de6eb65481fb2ad8143e69c35.tar.bz2
rails-9029efce410ea49de6eb65481fb2ad8143e69c35.zip
Unbundling TZInfo
Diffstat (limited to 'activesupport/Rakefile')
-rw-r--r--activesupport/Rakefile99
1 files changed, 0 insertions, 99 deletions
diff --git a/activesupport/Rakefile b/activesupport/Rakefile
index 08af1d6fca..434c5e2ed4 100644
--- a/activesupport/Rakefile
+++ b/activesupport/Rakefile
@@ -74,102 +74,3 @@ task :release => [ :package ] do
rubyforge.login
rubyforge.add_release(PKG_NAME, PKG_NAME, "REL #{PKG_VERSION}", *packages)
end
-
-
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/lib"
-require 'active_support/values/time_zone'
-
-namespace :tzinfo do
- desc "Update bundled tzinfo gem. Only copies the subset of classes and definitions required to support Rails time zone features."
- task :update => ['tzinfo:copy_classes', 'tzinfo:copy_definitions'] do
- Rake::Task['tzinfo:cleanup_tmp'].invoke
- puts <<-EOV
- *** FINAL TZINFO BUNDLING STEPS ***
-
- 1. Update TZInfo version in lib/active_support/vendor.rb
- 2. gem uninstall tzinfo on local system before running tests, to ensure tests are running against bundled version
-
- If a test fails because a particular zone can't be found, it's likely because the TZInfo identifier in the
- ActiveSupport::TimeZone::MAPPING hash is referencing a linked timezone instead of referencing the timezone directly.
- In this case, just change the MAPPING value to the correct identifier, and unpack TZInfo again.
- EOV
- end
-
- task :unpack_gem do
- mkdir_p "tmp"
- cd "tmp"
- sh "gem unpack --version #{ENV['VERSION'] || "'> 0'"} tzinfo"
- cd ".."
- end
-
- task :copy_classes => :unpack_gem do
- mkdir_p "#{destination_path}/lib/tzinfo"
- cp "#{tmp_path}/lib/tzinfo.rb", "#{destination_path}/lib"
- comment_requires_for_excluded_classes!('lib/tzinfo.rb')
- files = FileList["#{tmp_path}/lib/tzinfo/*.rb"]
- files.each do |file|
- filename = File.basename(file)
- unless excluded_classes.include? filename.sub(/.rb$/, '')
- cp "#{tmp_path}/lib/tzinfo/#{filename}", "#{destination_path}/lib/tzinfo"
- comment_requires_for_excluded_classes!("lib/tzinfo/#{filename}")
- end
- end
- end
-
- task :copy_definitions => :unpack_gem do
- definitions_path = "#{destination_path}/lib/tzinfo/definitions/"
- mkdir_p definitions_path
- ActiveSupport::TimeZone::MAPPING.values.each do |zone|
- subdir = nil
- if /\// === zone
- subdir = zone.sub(/\w+$/, '')
- mkdir_p "#{definitions_path}/#{subdir}"
- end
- cp "#{tmp_path}/lib/tzinfo/definitions/#{zone}.rb", "#{definitions_path}/#{subdir}"
- end
- end
-
- task :cleanup_tmp do
- rm_rf "tmp"
- end
-
- def comment_requires_for_excluded_classes!(file)
- lines = open("#{destination_path}/#{file}") {|f| f.readlines}
- updated = false
-
- new_lines = []
- lines.each do |line|
- if Regexp.new("require 'tzinfo/(#{excluded_classes.join('|')})'") === line
- updated = true
- new_lines << "# #{line}"
- else
- new_lines << line
- end
- end
-
- if updated
- open("#{destination_path}/#{file}", "w") {|f| f.write(new_lines.join)}
- end
- end
-
- def version
- ENV['VERSION'] ||= get_unpacked_version
- end
-
- def get_unpacked_version
- m = (FileList["tmp/tzinfo-*"].to_s.match /\d+\.\d+\.\d+/)
- m ? m[0] : raise(LoadError, "TZInfo gem must be installed locally. `gem install tzinfo` and try again")
- end
-
- def tmp_path
- "tmp/tzinfo-#{version}"
- end
-
- def destination_path
- "lib/active_support/vendor/tzinfo-#{version}"
- end
-
- def excluded_classes
- %w(country country_index_definition country_info country_timezone timezone_index_definition timezone_proxy tzdataparser)
- end
-end