Module: Hoe::Packaging
- Defined in:
- lib/hoe/packaging.rb
Overview
Main module for hoe-packaging TODO: Try to fix this in future rubocop:disable Style/ClassAndModuleChildren
Constant Summary collapse
- VERSION =
Versionizing
'1.2.5'.freeze
Instance Attribute Summary collapse
-
#create_packages ⇒ Object
Returns the value of attribute create_packages.
-
#deploy_packages ⇒ Object
Returns the value of attribute deploy_packages.
Instance Method Summary collapse
-
#bintray_config ⇒ Array
Method for getting the bintray config.
-
#create_packages_method ⇒ String
Method for creating deb and rpm packages.
- #define_packaging_tasks ⇒ Object
-
#deploy_bintray_method ⇒ String
Method for deploying to bintray TODO: Try to pacify rubocop and reek in future rubocop:disable Metrics/AbcSize rubocop:disable Metrics/LineLength rubocop:disable Metrics/MethodLength This method smells of :reek:TooManyStatements.
-
#initialize_packaging ⇒ Object
Initialize plugin.
-
#projectname ⇒ String
Method for getting the project name.
-
#version ⇒ String
Method for getting version.
Instance Attribute Details
#create_packages ⇒ Object
Returns the value of attribute create_packages
26 27 28 |
# File 'lib/hoe/packaging.rb', line 26 def create_packages @create_packages end |
#deploy_packages ⇒ Object
Returns the value of attribute deploy_packages
27 28 29 |
# File 'lib/hoe/packaging.rb', line 27 def deploy_packages @deploy_packages end |
Instance Method Details
#bintray_config ⇒ Array
Method for getting the bintray config
113 114 115 116 117 118 |
# File 'lib/hoe/packaging.rb', line 113 def bintray_config config = YAML.safe_load(File.read("#{Dir.home}/.hoerc")) user = config['deploy']['username'].to_s apikey = config['deploy']['apikey'].to_s [user, apikey] end |
#create_packages_method ⇒ String
Method for creating deb and rpm packages
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hoe/packaging.rb', line 54 def create_packages_method FileUtils.cd('recipes') do puts 'Creating the deb package'.color(:yellow) system('fpm-cook -t deb') puts 'deb creating done'.color(:green) puts 'Creating the rpm package'.color(:yellow) system('fpm-cook -t rpm') puts 'rpm creating done'.color(:green) end end |
#define_packaging_tasks ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/hoe/packaging.rb', line 38 def define_packaging_tasks # Rake Task for building packages desc 'Creating deb and rpm files' task :create_packages do create_packages_method end # Rake task for deploying packages desc 'Deploying packages to bintray' task :deploy_packages do deploy_bintray_method end end |
#deploy_bintray_method ⇒ String
Method for deploying to bintray TODO: Try to pacify rubocop and reek in future rubocop:disable Metrics/AbcSize rubocop:disable Metrics/LineLength rubocop:disable Metrics/MethodLength This method smells of :reek:TooManyStatements
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/hoe/packaging.rb', line 72 def deploy_bintray_method project = projectname user, apikey = bintray_config version = version path = 'pool/main/r' debadd = ';deb_distribution=ubuntu;deb_component=main;deb_architecture=i386,amd64' publish = ';publish=1' puts 'Deploying packages to bintray'.color(:yellow) FileUtils.cd('recipes/pkg') do filerpm = Dir.glob('*.rpm') filedeb = Dir.glob('*.deb') rpm = filerpm.first.to_s deb = filedeb.first.to_s rpmup = system("curl -T #{rpm} -u#{user}:#{apikey} https://api.bintray.com/content/#{user}/rpm/#{project}/v#{version}/#{path}/#{publish}") begin rpmup['message'] == 'success' rescue NoMethodError false end debup = system("curl -T #{deb} -u#{user}:#{apikey} 'https://api.bintray.com/content/#{user}/deb/#{project}/v#{version}/#{path}/#{deb}#{debadd}#{publish}'") begin debup['message'] == 'success' rescue NoMethodError false end end puts 'Deploying succeeded'.color(:green) end |
#initialize_packaging ⇒ Object
Initialize plugin
30 31 32 33 34 35 36 |
# File 'lib/hoe/packaging.rb', line 30 def initialize_packaging require 'fileutils' require 'parseconfig' require 'rainbow/ext/string' require 'fpm' require 'yaml' end |
#projectname ⇒ String
Method for getting the project name
105 106 107 108 109 |
# File 'lib/hoe/packaging.rb', line 105 def projectname pnameraw = File.open(*Dir.glob('README.*'), &:readline) project = pnameraw.gsub(/[^0-9A-Za-z_-]/, '') return project end |
#version ⇒ String
Method for getting version
122 123 124 125 |
# File 'lib/hoe/packaging.rb', line 122 def version version = File.open(*Dir.glob('VERSION'), &:readline) version.chomp.to_s end |