class Object
Public Instance Methods
set_cap_consts()
click to toggle source
# File lib/deplo/set_cap_consts.rb, line 1 def set_cap_consts set :gem , fetch( :application ).to_s.gsub( /\Agem_/ , "" ) set :latest_version_file , ::File.expand_path( "#{ fetch( :pj_dir ) }/.latest_version" ) # Version of Gem dirname = [ fetch( :pj_dir ) , :lib , fetch( :gem ).gsub( /::/ , "_" ) ].map( &:to_s ).join( "/" ) require "#{ dirname }/version.rb" namespace = fetch( :gem ).to_s.split( "::" ).map( &:camelize ).join( "::" ) set :new_version , eval( "#{ namespace }::VERSION" ) require "#{ ::File.dirname( __FILE__ ) }/version.rb" end
set_cap_namespace_gem()
click to toggle source
# File lib/deplo/gem.rb, line 1 def set_cap_namespace_gem namespace :gem do desc "Gem - Test" task :test do ::Deplo.process "gem:test" do system( "rake spec" ) end end desc "Gem - Rake install" task :rake_install_locally do ::Deplo.process "gem:rake_install_locally" do system( "rake install" ) end end desc "Gem - Update name of latest version" task :update do ::Deplo.process "gem:update" do latest_version_file = fetch( :latest_version_file ) ::File.open( latest_version_file , "w:utf-8" ) do |f| f.print fetch( :new_version ) end end end desc "Install Gem #{ fetch( :new_version ) }" task install_locally: :test do ::Deplo.process "gem:install_locally" do ::Deplo.yes_no( yes: ::Proc.new { ::Rake::Task[ "git:commit_for_gem" ].invoke ::Rake::Task[ "github:push" ].invoke ::Rake::Task[ "gem:rake_install_locally" ].invoke } ) end end desc "Release Gem #{ fetch( :new_version ) }" task release_to_public: :install_locally do if ::File.exist?( fetch( :latest_version_file ) ) old_version = open( fetch( :latest_version_file ) , "r:utf-8" ).read else old_version = nil end ::Deplo.process "gem:release_to_public" do ::Deplo.yes_no( message: "Release Gem #{ fetch( :new_version ) }" , yes: ::Proc.new { ::Rake::Task[ "gem:update" ].invoke system( "rake release" ) }) end unless old_version.nil? ::Deplo.process "gem:yank_old_version" do ::Deplo.yes_no( message: "Yank Old Gem #{ old_version }" , yes: ::Proc.new { system( "gem yank #{ fetch( :gem ) } -v #{ old_version }" ) }) end end end desc "Files to check" task :files_to_check do #-------- xxxx.gemspec ::Deplo.display_file_content_to_check( "#{ fetch( :gem ) }.gemspec" , "spec.add_development_dependency \"capistrano\"" , "spec.add_development_dependency \"deplo\", \">= #{ ::Deplo::VERSION }\"" ) #-------- lib/xxxx/version.rb ::Deplo.display_file_content_to_check( "lib/#{ fetch( :gem ) }/version.rb" , "module #{ fetch( :gem ).capitalize }" , " VERSION = ::File.open( \"\#\{ ::File.dirname( __FILE__ ) \}/../../.current_version\" , \"r:utf-8\" ).read.chomp" , "end" ) #-------- spec/xxxx_spec.rb ::Deplo.display_file_content_to_check( "spec/#{ fetch( :gem ) }_spec.rb" , "require \'spec_helper\'" , "require \'deplo\'" , "" , "spec_filename = ::File.expand_path( ::File.dirname( __FILE__ ) )" , "version = ::File.open( \"\#\{ ::File.dirname( __FILE__ ) \}/..\/.current_version\" , \"r:utf-8\" ).read.chomp" , "" , "describe #{ fetch( :gem ).camelize } do" , " it \"has a version number \\\'\#\{ version \}\\\'\" do" , " expect( ::Deplo.version_check( ::#{ fetch( :gem ).camelize }::VERSION , spec_filename ) ).to eq( true )" , " end" ) #-------- Capfile (1) ::Deplo.display_file_content_to_check( "Capfile" , # "\# Load DSL and set up stages" , "require \'capistrano/setup\'" , "" , "\# Include default deployment tasks" , "require \'capistrano/deploy\'" , "" , "require \'deplo\'" ) #-------- Capfile (2) ::Deplo.display_file_content_to_check( "Capfile" , # "Rake::Task[:production].invoke" , "invoke :production" , "set_cap_tasks_from_deplo" ) #-------- .gitignore gitignore_filename = ::File.expand_path( "#{ fetch( :pj_dir ) }/.gitignore" ) latest_version_setting_in_gitignore = "/.latest_version" ::Deplo.display_file_content_to_check( ".gitignore" , latest_version_setting_in_gitignore ) ::Deplo.file_inclusion_check( gitignore_filename , latest_version_setting_in_gitignore , addition: true ) #-------- version.rb ::Deplo.display_file_content_to_check( "lib/#{ fetch( :gem ) }/version.rb" ) #-------- config/deploy.rb ::Deplo.display_file_content_to_check( "config/deploy.rb" ) in_file = ::File.open( "#{ fetch( :pj_dir ) }/config/deploy.rb" ).read.split( /\n/ ) regexps = [ /\Aset \:application/ , /\Aset \:repo_url/ , /\Aset \:pj_dir/ , /\Aset \:github_remote_name/ , /\Aset \:deploy_to ?, \'\/\'/ ] condition = regexps.all? { | regexp | included_in_file = in_file.any? { | row | regexp === row } unless included_in_file puts "No row matched with #{ regexp.to_s }" end included_in_file } puts "" if condition puts "*** All Capistrano constants are set. (maybe each constant itself is not valid)" else puts "[!] Some Capistrano constants are not set." end end end end
set_cap_namespace_git()
click to toggle source
# File lib/deplo/git.rb, line 27 def set_cap_namespace_git namespace :git do desc 'add to git all files under this directory' task :add do ::Deplo.process "git:add" do system "git add -A ." end end desc 'commit to git' task commit: :add do ::Deplo.process "git:commit" do system "git commit -m \"#{ ::Deplo::TitleForGitCommit.set }\"" end end desc 'commit to git (amend)' task :commit_amend do ::Deplo.process "git:commit_amend" do system "git commit --amend -m \"#{ ::Deplo::TitleForGitCommit.set }\"" end end desc 'commit to git (for Gem install or release)' task commit_for_gem: :add do ::Deplo.process "git:commit_for_gem" do gem_v = fetch( :new_version ) t = ::Deplo::TitleForGitCommit.set( gem_version: gem_v ) system "git commit -m \"#{t}\"" end end end end
set_cap_namespace_github()
click to toggle source
# File lib/deplo/github.rb, line 19 def set_cap_namespace_github namespace :github do desc 'push to github' task :push do ::Deplo.process "github:push" do github_remote_name = fetch( :github_remote_name ) branch_name = ::Deplo::BranchNameForGithub.set system "git push #{ github_remote_name } #{ branch_name }" end end desc 'pull from github' task :pull do ::Deplo.process "github:pull" do github_remote_name = fetch( :github_remote_name ) branch_name = ::Deplo::BranchNameForGithub.set system "git push #{ github_remote_name } #{ branch_name }" end end end end
set_cap_tasks_from_deplo( cap_consts: true )
click to toggle source
# File lib/deplo.rb, line 57 def set_cap_tasks_from_deplo( cap_consts: true ) if cap_consts set_cap_consts end set_cap_namespace_git set_cap_namespace_github set_cap_namespace_gem end