exogenesis 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in exogenesis.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Lucas Dohmen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # Exogenesis
2
+
3
+ A collection of classes that help you install, update and teardown package managers and other things useful for your dotfiles. It's something like a meta package manager (package manager is the wrong word... still searching for a better one). You can use it to install/update/teardown your dotfiles or to create a single `update` command to update everything on your computer.
4
+
5
+ **Please read the source code of this gem before you use it. I give no guarantee that this will not destroy your computer entirely.**
6
+
7
+ ## The Interface of the classes
8
+
9
+ Every class has the following methods (with the exception of `initialize` they all take no arguments):
10
+
11
+ * `initialize`: The arguments are arbitrary, please see the individual files for it
12
+ * `setup`: Installs the package manager itself
13
+ * `install`: Installs all packages (the list has to be provided in the initialize method)
14
+ * `update`: Updates the package manager itself and all packages
15
+ * `cleanup`: Starts a clean-up process
16
+ * `teardown`: Uninstalls all packages and the package manager itself
17
+
18
+ Not all package managers will need all of the methods. Just do not implement them.
19
+
20
+ ## Contributing
21
+
22
+ Additions of new classes are more than welcome, even if they are complimentary to the ones already provided. If you want to contribute a new class, please see the interface section and inherit from `AbstractPackageManager`.
23
+ Your code has to work on Ruby 1.8.7, because the dotfile installers should work on Mac OS without installing a new Ruby version (and Mac OS still ships with 1.8.7)
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'exogenesis/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "exogenesis"
8
+ spec.version = Exogenesis::VERSION
9
+ spec.authors = ["moonglum"]
10
+ spec.email = ["moonglum@moonbeamlabs.com"]
11
+ spec.description = %q{Build your dotfile installer, updater and teardown}
12
+ spec.summary = %q{A collection of classes that help you install, update and teardown package managers and other things useful for your dotfiles.}
13
+ spec.homepage = "https://github.com/moonglum/exogenesis"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,9 @@
1
+ require "exogenesis/version"
2
+ require "exogenesis/dotfile"
3
+ require "exogenesis/homebrew"
4
+ require "exogenesis/oh-my-zsh"
5
+ require "exogenesis/rvm"
6
+ require "exogenesis/vundle"
7
+
8
+ module Exogenesis
9
+ end
@@ -0,0 +1,25 @@
1
+ class AbstractPackageManager
2
+ # The arguments are arbitrary, please see the individual files for it
3
+ def initialize
4
+ end
5
+
6
+ # Installs the package manager itself
7
+ def setup
8
+ end
9
+
10
+ # Installs all packages (the list has to be provided in the initialize method)
11
+ def install
12
+ end
13
+
14
+ # Updates the package manager itself and all packages
15
+ def update
16
+ end
17
+
18
+ # Starts a clean-up process
19
+ def cleanup
20
+ end
21
+
22
+ # Uninstalls all packages and the package manager itself
23
+ def teardown
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ require 'exogenesis/abstract_package_manager'
2
+
3
+ # Links all files in the directory `tilde` to your home directory
4
+ class Dotfile < AbstractPackageManager
5
+ def install
6
+ file_names.each { |dotfile| link_file dotfile }
7
+ end
8
+
9
+ def teardown
10
+ file_names.each { |dotfile| unlink_file dotfile }
11
+ end
12
+
13
+ private
14
+
15
+ def link_file(file_name)
16
+ original = File.join Dir.pwd, "tilde", file_name.to_s
17
+ target = File.join Dir.home, ".#{file_name}"
18
+
19
+ if File.symlink? target
20
+ puts "#{file_name} already linked"
21
+ else
22
+ puts "Linking #{file_name}"
23
+ `ln -s #{original} #{target}`
24
+ end
25
+ end
26
+
27
+ def unlink_file(file_name)
28
+ target = File.join Dir.home, ".#{file_name}"
29
+
30
+ if File.symlink? target
31
+ `rm #{target}`
32
+ puts "Symlink for #{target} removed"
33
+ else
34
+ puts "No symlink for #{target} existed."
35
+ end
36
+ end
37
+
38
+ def file_names
39
+ file_names = Dir.entries(File.join(Dir.pwd, "tilde"))
40
+
41
+ file_names.delete_if do |filename|
42
+ filename[0] == "."
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,45 @@
1
+ require 'exogenesis/abstract_package_manager'
2
+
3
+ # Manages Homebrew - the premier package manager for Mac OS
4
+ class Homebrew < AbstractPackageManager
5
+ # Expects an array of packages to install, a package can either be:
6
+ # * A String: Then it will just install the package with this name
7
+ # * An Object with a single key value pair. The key is the name of the package, the value is an array of options passed to it
8
+ def initialize(brews)
9
+ @brews = brews
10
+ end
11
+
12
+ def update
13
+ puts "Updating Homebrew..."
14
+ `brew update`
15
+ puts "Upgrading the following apps: #{`brew outdated`}"
16
+ `brew upgrade`
17
+ end
18
+
19
+ def install
20
+ @brews.each do |brew|
21
+ if brew.class == String
22
+ install_package brew
23
+ else
24
+ name = brew.keys.first
25
+ options = brew[name]
26
+ install_package name, options
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def install_package(name, options = [])
34
+ print "Installing #{name}... "
35
+ status = `brew install #{name} #{options.join}`
36
+
37
+ raise "No formula for #{name}" if status.include? "No available formula"
38
+
39
+ if status.include? "already installed"
40
+ puts "Already Installed!"
41
+ else
42
+ puts "Installed!"
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,28 @@
1
+ require 'exogenesis/abstract_package_manager'
2
+
3
+ # Installs and removes OhMyZSH
4
+ class OhMyZSH < AbstractPackageManager
5
+ def install
6
+ print "Cloning Oh-my-zsh..."
7
+ target = File.join Dir.home, ".oh-my-zsh"
8
+
9
+ if File.exists? target
10
+ puts "Oh-my-zsh already exists"
11
+ else
12
+ `git clone git://github.com/moonglum/oh-my-zsh.git #{target}`
13
+ puts "Cloned!"
14
+ end
15
+ end
16
+
17
+ def teardown
18
+ print "Removing Oh-my-zsh..."
19
+ target = File.join Dir.home, ".oh-my-zsh"
20
+
21
+ if File.exists? target
22
+ `rm -r #{target}`
23
+ puts "Removed!"
24
+ else
25
+ puts "Did not exist"
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,32 @@
1
+ require 'exogenesis/abstract_package_manager'
2
+
3
+ # Installs the Ruby Version Manager RVM
4
+ class Rvm < AbstractPackageManager
5
+ # Expects an array of rubies as Strings you want to install
6
+ def initialize(rubies)
7
+ @rubies = rubies
8
+ end
9
+
10
+ def install
11
+ @rubies.each do |ruby|
12
+ print "Installing #{ruby}..."
13
+ status = `rvm install #{ruby} --with-gcc=gcc-4.2`
14
+
15
+ if status.include? "Already installed"
16
+ puts "Already Installed!"
17
+ else
18
+ puts "Installed!"
19
+ end
20
+ end
21
+ end
22
+
23
+ def update
24
+ puts "Updating RVM"
25
+ `rvm get head`
26
+ `rvm reload`
27
+ @rubies.each do |ruby|
28
+ print "Upgrading #{ruby}..."
29
+ system "rvm upgrade #{ruby}"
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Exogenesis
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,53 @@
1
+ require 'exogenesis/abstract_package_manager'
2
+
3
+ # Manages the Vim Package Manager Vundle
4
+ class Vundle < AbstractPackageManager
5
+ # The dependencies are read from you Vim files
6
+ # It creates a `~/.vim` folder and clones Vundle.
7
+ # Then it runs BundleInstall in Vim.
8
+ def install
9
+ create_vim_folder
10
+ clone
11
+ bundle_install
12
+ end
13
+
14
+ def teardown
15
+ print "Removing Vundle..."
16
+ target = File.join Dir.home, ".vim"
17
+
18
+ if File.exists? target
19
+ `rm -r #{target}`
20
+ puts "Removed!"
21
+ else
22
+ puts "Did not exist"
23
+ end
24
+ end
25
+
26
+ def update
27
+ puts "Updating Vim Bundles"
28
+ system "vim +BundleUpdate +qall"
29
+ end
30
+
31
+ private
32
+
33
+ def create_vim_folder
34
+ target = File.join Dir.home, ".vim"
35
+ Dir.mkdir target unless File.exists? target
36
+ end
37
+
38
+ def clone
39
+ target = File.join Dir.home, ".vim", "bundle", "vundle"
40
+
41
+ if File.exists? target
42
+ puts "Vundle already exists"
43
+ else
44
+ `git clone git://github.com/gmarik/vundle.git #{target}`
45
+ puts "Cloned!"
46
+ end
47
+ end
48
+
49
+ def bundle_install
50
+ system "vim +BundleInstall\! +qall"
51
+ system "vim +BundleClean\! +qall"
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exogenesis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - moonglum
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Build your dotfile installer, updater and teardown
47
+ email:
48
+ - moonglum@moonbeamlabs.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - exogenesis.gemspec
59
+ - lib/exogenesis.rb
60
+ - lib/exogenesis/abstract_package_manager.rb
61
+ - lib/exogenesis/dotfile.rb
62
+ - lib/exogenesis/homebrew.rb
63
+ - lib/exogenesis/oh-my-zsh.rb
64
+ - lib/exogenesis/rvm.rb
65
+ - lib/exogenesis/version.rb
66
+ - lib/exogenesis/vundle.rb
67
+ homepage: https://github.com/moonglum/exogenesis
68
+ licenses:
69
+ - MIT
70
+ post_install_message:
71
+ rdoc_options: []
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubyforge_project:
88
+ rubygems_version: 1.8.25
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: A collection of classes that help you install, update and teardown package
92
+ managers and other things useful for your dotfiles.
93
+ test_files: []
94
+ has_rdoc: