This repository has been archived by the owner on Apr 1, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env ruby | ||
# The installer was done as fast as possible, so | ||
# TODO use dry and maintainable ruby code :D | ||
|
||
# enable colors if possible | ||
require 'paint' rescue nil | ||
unless defined? Paint | ||
module Paint | ||
def self.[](*args) | ||
args[0] | ||
end | ||
end | ||
end | ||
|
||
if ARGV.shift != 'install' | ||
warn 'Currently, only "rubybuntu-gedit install" is supported. Quitting...' | ||
exit | ||
end | ||
|
||
def action(what) | ||
if what && !what.empty? | ||
puts Paint["x] #{what}", :yellow] | ||
system what | ||
end | ||
end | ||
|
||
def check_existence(what, sudo = true) | ||
if File.exists?(what) | ||
print ">> The installer found an outdated file at \"#{what}\"\n" \ | ||
"Q] It's recommended to remove it. Do you want to remove it? [Yn]" | ||
action gets.chop =~ /^y?$/i ? | ||
"sudo rm -f #{what}" | ||
: nil | ||
end | ||
end | ||
|
||
@data = File.dirname(__FILE__) + "/../data" | ||
|
||
puts 'Welcome to the rubybuntu-gedit installer :D' | ||
puts 'Before each action I\'ll tell you what I am going to do' | ||
puts Paint['Please note: ', :bold] + 'I am pretty untested and might destroy your computer' | ||
|
||
# # # | ||
# language specs | ||
puts '>> Let\'s start with copying the language specs' | ||
print 'Q] Do you want to install the languages specs as sudo [/usr/share/gtksourceview-2.0/language-specs] or in your home directory [~/.local/share/gtksourceview-2.0/language-specs]? [Sh]' | ||
action gets.chop =~ /^s?$/i ? | ||
"sudo cp #@data/language-specs/*.lang /usr/share/gtksourceview-2.0/language-specs" | ||
: "mkdir -p ~/.local/share/gtksourceview-2.0/language-specs\n" \ | ||
" cp #@data/language-specs/*.lang ~/.local/share/gtksourceview-2.0/language-specs" | ||
|
||
check_existence '/usr/share/gtksourceview-2.0/language-specs/rhtml.lang', true | ||
check_existence '/usr/share/gtksourceview-2.0/language-specs/ruby_on_rails.lang', true | ||
check_existence '~/.local/share/gtksourceview-2.0/language-specs/rhtml.lang', false | ||
check_existence '~/.local/share/gtksourceview-2.0/language-specs/ruby_on_rails.lang', false | ||
|
||
# # # | ||
# mime | ||
puts '>> Now the mime types should be updated' | ||
print 'Q] Do you want to install the mime types as sudo [/usr/share/mime/packages] or in your home directory [~/.local/share/gtksourceview-2.0/language-specs]? [Sh]' | ||
action gets.chop =~ /^s?$/i ? | ||
"sudo cp #@data/mime/*.xml /usr/share/mime/packages\n" \ | ||
" sudo update-mime-database /usr/share/mime" | ||
: "mkdir -p ~/.local/share/mime/packages\n" \ | ||
" cp #@data/mime/*.xml ~/.local/share/mime/packages" \ | ||
" update-mime-database ~/.local/share/mime" | ||
|
||
check_existence '/usr/share/mime/rails.xml', true | ||
check_existence '~/.local/share/mime/rails.xml', false | ||
|
||
# # # | ||
# styles | ||
puts '>> Now, some styles get copied that use the new language specs :)' | ||
print 'Q] Do you want to install the styles as sudo [/usr/share/gtksourceview-2.0/styles] or in your home directory [~/.local/share/gtksourceview-2.0/styles]? [Sh]' | ||
action gets.chop =~ /^s?$/i ? | ||
"sudo cp #@data/styles/*.xml /usr/share/gtksourceview-2.0/styles" | ||
: "mkdir -p ~/.local/share/gtksourceview-2.0/styles\n" \ | ||
" cp #@data/language-specs/*.lang ~/.local/share/gtksourceview-2.0/styles" | ||
|
||
# # # | ||
# snippets | ||
puts '>> Sorry, currently, the snippets cannot installed via this installer' | ||
|
||
puts Paint["Congratulations! You've updated your gedit stuff! (if everything worked correctly °_°)", :green] | ||
puts "If not, please install manually and open an issue on github" | ||
puts 'Don\'t forget to change your gedit style to "RubyBuntu One" ;)' | ||
puts | ||
puts " J-_-L" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters