Kouhei Sutou
null+****@clear*****
Sun Sep 14 17:38:22 JST 2014
Kouhei Sutou 2014-06-05 13:07:53 +0900 (Thu, 05 Jun 2014) New Revision: 80d2f01e67e565086a763c59fa1483f774b6ca82 https://github.com/groonga/heroku-groonga-builder/commit/80d2f01e67e565086a763c59fa1483f774b6ca82 Message: Classify Modified files: Rakefile Modified: Rakefile (+77 -79) =================================================================== --- Rakefile 2014-06-05 13:04:06 +0900 (8632bda) +++ Rakefile 2014-06-05 13:07:53 +0900 (91f1199) @@ -2,104 +2,102 @@ require "octokit" task :default => :build - �� top_dir = Dir.pwd - -def top_dir - @top_dir -end - -def relative_install_prefix - File.join("vendor", "groonga") -end +class GroongaBuilder + def initialize + @top_dir = Dir.pwd + @github_token = ENV["GITHUB_TOKEN"] + if @github_token.nil? + raise "must set GITHUB_TOKEN environment variable" + end + end -def absolete_install_prefix - File.join(top_dir, relative_install_prefix) -end + def run + ensure_release + build_groonga + archive_name = archive + release_archive(archive_name) + end -def github_token - ENV["GITHUB_TOKEN"] -end + private + def relative_install_prefix + File.join("vendor", "groonga") + end -def groonga_version - ENV["GROONGA_VERSION"] || "4.0.2" -end + def absolete_install_prefix + File.join(@top_dir, relative_install_prefix) + end -def groonga_base_name - "groonga-#{groonga_version}" -end + def groonga_version + ENV["GROONGA_VERSION"] || "4.0.2" + end -def groonga_tag_name - "v#{groonga_version}" -end + def groonga_base_name + "groonga-#{groonga_version}" + end -def github_groonga_repository - "groonga/groonga" -end + def groonga_tag_name + "v#{groonga_version}" + end -def create_client - Octokit::Client.new(:access_token => github_token) -end + def github_groonga_repository + "groonga/groonga" + end -def find_release - client = create_client - releases = client.releases(github_groonga_repository) - releases.find do |release| - release.tag_name == groonga_tag_name + def client + @client ||= Octokit::Client.new(:access_token => @github_token) end -end -def release_exist? - not find_release.nil? -end + def find_release + releases = client.releases(github_groonga_repository) + releases.find do |release| + release.tag_name == groonga_tag_name + end + end -def ensure_create_release - return if release_exist? + def release_exist? + not find_release.nil? + end - client = create_client - client.create_release(github_groonga_repository, groonga_tag_name) -end + def ensure_release + return if release_exist? -def build_groonga - archive_name = "#{groonga_base_name}.tar.gz" - sh("curl", "-O", "http://packages.groonga.org/source/groonga/#{archive_name}") - sh("tar", "xf", archive_name) + client.create_release(github_groonga_repository, groonga_tag_name) + end - Dir.chdir(base_name) do - configure_args = [] - if ENV["DEBUG"] == "yes" - configure_args << "--enable-debug" + def build_groonga + archive_name = "#{groonga_base_name}.tar.gz" + sh("curl", "-O", + "http://packages.groonga.org/source/groonga/#{archive_name}") + sh("tar", "xf", archive_name) + + Dir.chdir(base_name) do + configure_args = [] + if ENV["DEBUG"] == "yes" + configure_args << "--enable-debug" + end + sh("./configure", + "--prefix=#{absolete_install_prefix}", + "--disable-static", + "--disable-document", + *configure_args) + sh("make", "-j4") + sh("make", "install") end - sh("./configure", - "--prefix=#{absolete_install_prefix}", - "--disable-static", - "--disable-document", - *configure_args) - sh("make", "-j4") - sh("make", "install") end -end - -def archive - built_archive_name = "heroku-#{groonga_base_name}.tar.xz" - sh("tar", "cJf", built_archive_name, relative_install_prefix) - - build_archive_name -end -def upload_archive(archive_name) - release = find_release + def archive + archive_name = "heroku-#{groonga_base_name}.tar.xz" + sh("tar", "cJf", archive_name, relative_install_prefix) + archive_name + end - client = create_client - client.upload_asset(release.url, archive_name) + def upload_archive(archive_name) + release = find_release + client.upload_asset(release.url, archive_name) + end end task :build do - if github_token.nil? - raise "must set GITHUB_TOKEN environment variable" - end - - ensure_create_release - build_groonga - archive_name = archive - release_archive(archive_name) + builder = GroongaBuilder.new + builder.run end -------------- next part -------------- HTML����������������������������...下載