Module: Gembuild
- Defined in:
- lib/gembuild.rb,
lib/gembuild/project.rb,
lib/gembuild/version.rb,
lib/gembuild/pkgbuild.rb,
lib/gembuild/exceptions.rb,
lib/gembuild/aur_scraper.rb,
lib/gembuild/gem_scraper.rb
Overview
Gembuild: create Arch Linux PKGBUILDs for ruby gems. Copyright © 2015 Mario Finelli <[email protected]>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <www.gnu.org/licenses/>.
Defined Under Namespace
Classes: AurScraper, GemNotFoundError, GemScraper, InvalidPkgbuildError, Pkgbuild, Project, UndefinedGemNameError, UndefinedPkgnameError
Constant Summary collapse
- VERSION =
Current version of Gembuild.
'1.0.0'
Class Method Summary collapse
-
.conf_file ⇒ String
The path to the gembuild configuration file.
-
.configure ⇒ Hash
Read from the configuration file if it exists, otherwise prompt for the configuration and save it to file.
-
.fetch_git_global_email ⇒ String
Attempt to read the global git email, prompting the user for the email if unsuccessful.
-
.fetch_git_global_name ⇒ String
Attempt to read the global git name, prompting the user for the name if unsuccessful.
-
.fetch_pkgdir ⇒ String
Prompt the user for the location where they would like to store checked-out packages.
-
.prompt_for_confirmation(detected) ⇒ Boolean
Ask the user to confirm the detected value.
-
.prompt_for_git_email(msg = nil) ⇒ String
Prompt the user for the email to use.
-
.prompt_for_git_name(msg = nil) ⇒ String
Prompt the user for the name to use.
Class Method Details
.conf_file ⇒ String
The path to the gembuild configuration file.
34 35 36 |
# File 'lib/gembuild.rb', line 34 def conf_file File.(File.join('~', '.gembuild')) end |
.configure ⇒ Hash
Read from the configuration file if it exists, otherwise prompt for the configuration and save it to file.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gembuild.rb', line 43 def configure unless File.file?(conf_file) name = fetch_git_global_name email = fetch_git_global_email pkgdir = fetch_pkgdir File.write( conf_file, { name: name, email: email, pkgdir: pkgdir }.to_yaml ) end YAML.load_file(conf_file) end |
.fetch_git_global_email ⇒ String
Attempt to read the global git email, prompting the user for the email if unsuccessful.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/gembuild.rb', line 80 def fetch_git_global_email email = `git config --global user.email`.strip if $CHILD_STATUS.success? if prompt_for_confirmation(email) return email else prompt_for_git_email end else prompt_for_git_email('Could not detect email from git configuration.') end end |
.fetch_git_global_name ⇒ String
Attempt to read the global git name, prompting the user for the name if unsuccessful.
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/gembuild.rb', line 62 def fetch_git_global_name name = `git config --global user.name`.strip if $CHILD_STATUS.success? if prompt_for_confirmation(name) return name else prompt_for_git_name end else prompt_for_git_name('Could not detect name from git configuration.') end end |
.fetch_pkgdir ⇒ String
Prompt the user for the location where they would like to store checked-out packages.
137 138 139 140 |
# File 'lib/gembuild.rb', line 137 def fetch_pkgdir puts 'Where should projects be checked out?' File.(gets.chomp) end |
.prompt_for_confirmation(detected) ⇒ Boolean
Ask the user to confirm the detected value.
126 127 128 129 130 131 |
# File 'lib/gembuild.rb', line 126 def prompt_for_confirmation(detected) puts "Detected \"#{detected}\", is this correct? (y/n)" response = gets.chomp.downcase[0, 1] response == 'y' end |
.prompt_for_git_email(msg = nil) ⇒ String
Prompt the user for the email to use.
This method is only called if reading the global git configuration was unsuccessful or the user specified that it was incorrect.
116 117 118 119 120 |
# File 'lib/gembuild.rb', line 116 def prompt_for_git_email(msg = nil) puts msg unless msg.nil? || msg.empty? puts 'Please enter desired email: ' gets.chomp end |
.prompt_for_git_name(msg = nil) ⇒ String
Prompt the user for the name to use.
This method is only called if reading the global git configuration was unsuccessful or the user specified that it was incorrect.
102 103 104 105 106 |
# File 'lib/gembuild.rb', line 102 def prompt_for_git_name(msg = nil) puts msg unless msg.nil? || msg.empty? puts 'Please enter desired name: ' gets.chomp end |