Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
add alpha installer :D
Browse files Browse the repository at this point in the history
  • Loading branch information
janlelis committed Aug 18, 2011
1 parent eb1a6d9 commit 995d74a
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
88 changes: 88 additions & 0 deletions bin/rubybuntu-gedit
@@ -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"
2 changes: 1 addition & 1 deletion data/language-specs
Submodule language-specs updated 1 files
+1 −1 ruby.lang
2 changes: 2 additions & 0 deletions rubybuntu-gedit.gemspec
Expand Up @@ -13,6 +13,8 @@ Gem::Specification.new do |s|
s.files = Dir.glob(%w|bin/* [A-Z]*.{txt,rdoc} data/**/*|) + %w|Rakefile rubybuntu-gedit.gemspec|
s.executables = Dir['bin/*'].map{|f| File.basename f }
s.license = "GPL"

s.add_dependency 'paint'

len = s.homepage.size
s.post_install_message = \
Expand Down

0 comments on commit 995d74a

Please sign in to comment.