Permalink
Browse files

initial commit

  • Loading branch information...
1 parent 32366bd commit 82e62bc040d3d5af6177b83e58fd43bc2b79f6b1 Joshua Sierles committed Jun 8, 2008
Showing with 182 additions and 0 deletions.
  1. +20 −0 LICENSE
  2. +4 −0 README
  3. +49 −0 Rakefile
  4. +4 −0 TODO
  5. +9 −0 bin/vgem
  6. 0 lib/vertebra-gem.rb
  7. +22 −0 lib/vertebra-gem/actor.rb
  8. +37 −0 lib/vertebra-gem/runner.rb
  9. +14 −0 script/destroy
  10. +14 −0 script/generate
  11. +2 −0 spec/spec_helper.rb
  12. +7 −0 spec/vertebra-gem_spec.rb
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 YOUR NAME
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
4 README
@@ -0,0 +1,4 @@
+vertebra-gem
+============
+
+Contains an actor and runner for managing gems on vertebra-enabled clusters.
View
@@ -0,0 +1,49 @@
+require 'rubygems'
+require 'rake/gempackagetask'
+require 'rubygems/specification'
+require 'date'
+
+GEM = "vertebra-gem"
+GEM_VERSION = "0.0.1"
+AUTHOR = "Your Name"
+EMAIL = "Your Email"
+HOMEPAGE = "http://example.com"
+SUMMARY = "A gem that provides..."
+
+spec = Gem::Specification.new do |s|
+ s.name = GEM
+ s.version = GEM_VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
+ s.summary = SUMMARY
+ s.description = s.summary
+ s.author = AUTHOR
+ s.email = EMAIL
+ s.homepage = HOMEPAGE
+
+ s.executables = %w(vgem)
+
+ s.add_dependency "vertebra"
+ s.add_dependency "thor"
+
+ s.require_path = 'lib'
+ s.autorequire = GEM
+ s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
+end
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
+
+desc "install the gem locally"
+task :install => [:package] do
+ sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
+end
+
+desc "create a gemspec file"
+task :make_spec do
+ File.open("#{GEM}.gemspec", "w") do |file|
+ file.puts spec.to_ruby
+ end
+end
View
4 TODO
@@ -0,0 +1,4 @@
+TODO:
+Fix LICENSE with your name
+Fix Rakefile with your name and contact info
+Add your code to lib/<%= name %>.rb
View
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../lib/vertebra-gem/runner'
+
+begin
+ Vertebra::VGem.start
+rescue DRb::DRbConnError
+ puts Vertebra::BaseRunner::NO_AGENT_ERROR
+end
View
No changes.
View
@@ -0,0 +1,22 @@
+require 'vertebra/actor'
+
+module Vertebra
+ module Actors
+ class Gem < ::Vertebra::Actor
+
+ provides '/gem'
+ register_with_agent
+
+ def list(args = {})
+ filter = args['filter'] || nil
+ ::Gem.source_index.refresh!.search(filter).flatten.collect {|gemspec| "#{gemspec.name} #{gemspec.version}" }
+ end
+
+ def install(args = {})
+ str = args['name']
+ str << "-#{args['version']}" if args['version']
+ `gem install #{str}`
+ end
+ end
+ end
+end
View
@@ -0,0 +1,37 @@
+require 'rubygems'
+
+begin
+ require 'thor'
+ require 'vertebra/base_runner'
+rescue LoadError
+ puts "Please install the thor and vertebra gems."
+ exit
+end
+
+module Vertebra
+ class VGem < BaseRunner
+
+ @@global_method_options = {:node => :optional, :cluster => :required, :only_nodes => :boolean, :slice => :optional}
+
+ def self.all_method_options(opts = {})
+ self.method_options(@@global_method_options.merge(opts))
+ end
+
+ desc "list", "Get a list of gems"
+ all_method_options :filter => :optional
+
+ def list(opts = {})
+ gems = broadcast('list', '/gem', opts)
+ gems.each { |host, gems| puts "\n#{host}";puts "---"; puts gems.is_a?(Array) ? gems.join("\n") : gems }
+ end
+
+ desc "install <gem_name>", "Install a gem"
+ all_method_options
+
+ def install(gem_name, opts = {})
+ result = broadcast('install', '/gem', opts.merge(:name => gem_name))
+ puts result.inspect
+ end
+
+ end
+end
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/destroy'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Destroy.new.run(ARGV)
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
+
+begin
+ require 'rubigen'
+rescue LoadError
+ require 'rubygems'
+ require 'rubigen'
+end
+require 'rubigen/scripts/generate'
+
+ARGV.shift if ['--help', '-h'].include?(ARGV[0])
+RubiGen::Base.use_component_sources! [:newgem_simple, :test_unit]
+RubiGen::Scripts::Generate.new.run(ARGV)
View
@@ -0,0 +1,2 @@
+$TESTING=true
+$:.push File.join(File.dirname(__FILE__), '..', 'lib')
@@ -0,0 +1,7 @@
+require File.dirname(__FILE__) + '/spec_helper'
+
+describe "vertebra-gem" do
+ it "should do nothing" do
+ true.should == true
+ end
+end

0 comments on commit 82e62bc

Please sign in to comment.