Module: Hoe::Packaging
- Defined in:
- lib/hoe/packaging.rb
Overview
rubocop:disable Style/ClassAndModuleChildren
Constant Summary collapse
- VERSION =
Versionizing
'1.2.7'.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 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.
24 25 26 |
# File 'lib/hoe/packaging.rb', line 24 def create_packages @create_packages end |
#deploy_packages ⇒ Object
Returns the value of attribute deploy_packages.
25 26 27 |
# File 'lib/hoe/packaging.rb', line 25 def deploy_packages @deploy_packages end |
Instance Method Details
#bintray_config ⇒ Array
Method for getting the bintray config
110 111 112 113 114 115 |
# File 'lib/hoe/packaging.rb', line 110 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
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hoe/packaging.rb', line 52 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
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hoe/packaging.rb', line 36 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 rubocop:disable Metrics/AbcSize rubocop:disable Metrics/LineLength rubocop:disable Metrics/MethodLength This method smells of :reek:TooManyStatements
69 70 71 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 |
# File 'lib/hoe/packaging.rb', line 69 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
28 29 30 31 32 33 34 |
# File 'lib/hoe/packaging.rb', line 28 def initialize_packaging require 'fileutils' require 'parseconfig' require 'rainbow/ext/string' require 'fpm' require 'yaml' end |
#projectname ⇒ String
Method for getting the project name
102 103 104 105 106 |
# File 'lib/hoe/packaging.rb', line 102 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
119 120 121 122 |
# File 'lib/hoe/packaging.rb', line 119 def version version = File.open(*Dir.glob('VERSION'), &:readline) version.chomp.to_s end |