-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
major commit. first functional version
- Loading branch information
Dan Ryan
committed
Jul 22, 2011
1 parent
fe3c540
commit cbc51c5
Showing
20 changed files
with
389 additions
and
87 deletions.
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
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 |
---|---|---|
@@ -1,4 +1,14 @@ | ||
source "http://rubygems.org" | ||
source 'http://rubygems.org' | ||
|
||
gem 'mixlib-cli' | ||
gem 'yajl-ruby', :require => 'yajl' | ||
gemspec | ||
|
||
group :development, :test do | ||
gem 'rspec', '>= 2.6.0' | ||
gem 'spork', '>= 0.9.0.rc8' | ||
gem 'watchr', '>= 0.7' | ||
gem 'json_spec', '>= 0.5.0' | ||
end | ||
|
||
group :doc do | ||
gem 'yard' | ||
end |
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 |
---|---|---|
@@ -1,12 +1,47 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
overwatch-cli (0.0.1) | ||
clamp (>= 0.2.2) | ||
formatador (>= 0.2.0) | ||
hirb (= 0.4.5) | ||
rest-client (>= 1.6.3) | ||
yajl-ruby (>= 0.8.2) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
mixlib-cli (1.2.0) | ||
clamp (0.2.2) | ||
diff-lcs (1.1.2) | ||
formatador (0.2.0) | ||
hirb (0.4.5) | ||
json (1.5.3) | ||
json_spec (0.5.0) | ||
json (~> 1.0) | ||
rspec (~> 2.0) | ||
mime-types (1.16) | ||
rest-client (1.6.3) | ||
mime-types (>= 1.16) | ||
rspec (2.6.0) | ||
rspec-core (~> 2.6.0) | ||
rspec-expectations (~> 2.6.0) | ||
rspec-mocks (~> 2.6.0) | ||
rspec-core (2.6.4) | ||
rspec-expectations (2.6.0) | ||
diff-lcs (~> 1.1.2) | ||
rspec-mocks (2.6.0) | ||
spork (0.9.0.rc9) | ||
watchr (0.7) | ||
yajl-ruby (0.8.2) | ||
yard (0.7.2) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
mixlib-cli | ||
yajl-ruby | ||
json_spec (>= 0.5.0) | ||
overwatch-cli! | ||
rspec (>= 2.6.0) | ||
spork (>= 0.9.0.rc8) | ||
watchr (>= 0.7) | ||
yard |
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,6 @@ | ||
## TODO | ||
|
||
* dotfile for configuration of defaults | ||
* expand command set as other overwatch pieces are implemented | ||
* user authentication/authorization (done in the other apps, but we'll need support here) | ||
|
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 |
---|---|---|
@@ -1,41 +1,42 @@ | ||
# Add your own tasks in files placed in lib/tasks ending in .rake, | ||
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | ||
|
||
require File.expand_path('../config/application', __FILE__) | ||
require 'rake' | ||
|
||
Overwatch::Application.load_tasks | ||
# require 'resque/tasks' | ||
# require 'resque_scheduler/tasks' | ||
|
||
require 'resque/tasks' | ||
require 'resque_scheduler/tasks' | ||
require 'bundler/gem_tasks' | ||
|
||
require 'rspec/core/rake_task' | ||
|
||
desc "Run specs" | ||
RSpec::Core::RakeTask.new do |task| | ||
task.pattern = "spec/**/*_spec.rb" | ||
end | ||
|
||
desc "Run watchr" | ||
task :watchr do | ||
sh %{bundle exec watchr .watchr} | ||
end | ||
|
||
desc "Run spork" | ||
task :spork do | ||
sh %{bundle exec spork} | ||
end | ||
|
||
namespace :resque do | ||
task :setup do | ||
require 'resque' | ||
require 'resque_scheduler' | ||
require 'resque/scheduler' | ||
|
||
Resque.redis = 'localhost:6379' | ||
|
||
Resque.schedule = YAML.load_file( | ||
File.join(File.expand_path(File.dirname(__FILE__)), 'config/schedule.yml') | ||
) | ||
|
||
end | ||
end | ||
|
||
Bundler.require(:doc) | ||
desc "Generate documentation" | ||
YARD::Rake::YardocTask.new do |t| | ||
t.files = [ 'lib/**/*.rb' ] | ||
end | ||
|
||
namespace :overwatch do | ||
namespace :test do | ||
task :snapshot => :environment do | ||
a = Asset.first | ||
a.snapshots.create(:raw_data => {:one => rand(10), :two => { :three => rand(10) }}) | ||
a = Resource.first | ||
a.snapshots.create(:data => {:one => rand(10), :two => { :three => rand(10) }}) | ||
end | ||
end | ||
end |
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,8 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$: << File.expand_path(File.dirname(__FILE__) + "/../lib") | ||
|
||
require 'overwatch/cli' | ||
require 'clamp' | ||
|
||
Overwatch::CLI::Command.run |
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,56 +1,71 @@ | ||
require 'overwatch/cli/command' | ||
require 'rest-client' | ||
require 'clamp' | ||
require 'formatador' | ||
require 'yajl/json_gem' | ||
require 'overwatch/cli/helpers' | ||
require 'hirb' | ||
|
||
module Overwatch | ||
module CLI | ||
module Command | ||
class Command < Clamp::Command | ||
include Helpers | ||
|
||
def self.load | ||
Dir[File.join(File.dirname(__FILE__), "command", "*.rb")].each do |file| | ||
require file | ||
end | ||
# Overwatch::CLI::Plugin.load! | ||
end | ||
|
||
def self.commands | ||
@@commands ||= {} | ||
end | ||
|
||
def self.command_aliases | ||
@@command_aliases ||= {} | ||
end | ||
|
||
def self.namespaces | ||
@@namespaces ||= {} | ||
end | ||
|
||
def self.register_command(command) | ||
commands[command[:command]] = command | ||
end | ||
|
||
def self.register_namespace(namespace) | ||
namespaces[namespace[:name]] = namespace | ||
end | ||
|
||
def self.current_command | ||
@current_command | ||
end | ||
|
||
def self.current_args | ||
@current_args | ||
end | ||
|
||
def self.current_options | ||
@current_options | ||
end | ||
|
||
def self.global_options | ||
@global_options ||= [] | ||
option ["-v", "--verbose"], :flag, "be verbose" | ||
option "--version", :flag, "show version" do | ||
puts "Overwatch v#{Overwatch::CLI::VERSION} (Codename: Snickelfritz)" | ||
exit(0) | ||
end | ||
subcommand "resource", "Resources" do | ||
option ["-h", "--host"], "HOST", "overwatch-collection server", :default => "localhost" | ||
option ["-p", "--port"], "PORT", "overwatch-collection port", :default => "9001" | ||
option ["-f", "--format"], "[FORMAT]", "format (choices: pretty, json, text)", :default => "pretty" | ||
|
||
subcommand "list", "list all resources" do | ||
def execute | ||
options = { :fields => ['id','name', 'api_key'], :format => format } | ||
|
||
get("http://#{host}:#{port}/resources", options) | ||
end | ||
end | ||
|
||
subcommand "show", "show a specific resource" do | ||
parameter "NAME", "resource name" | ||
|
||
option ['-a', '--attributes'], :flag, "list all resource attributes" | ||
|
||
def execute | ||
options = { :fields => ['id','name', 'api_key'], :format => format } | ||
get("http://#{host}:#{port}/resources/#{name}", options) | ||
end | ||
end | ||
|
||
subcommand "create", "create a new resource" do | ||
parameter "NAME", "resource name" | ||
|
||
def execute | ||
options = { :fields => ['id','name', 'api_key'], :format => format } | ||
post("http://#{host}:#{port}/resources", JSON.generate({:name => name}), options) | ||
end | ||
|
||
def self.global_option(name, *args) | ||
global_options << { :name => name, :args => args } | ||
end | ||
subcommand "update", "update an existing resource" | ||
subcommand "delete", "delete an existing resource" do | ||
parameter "NAME", "resource name" | ||
|
||
def execute | ||
# resource = delete("http://#{host}:#{port}/resources/#{name}") | ||
display_line "[yellow]Resource deleted![/]" | ||
end | ||
end | ||
subcommand "regenerate", "regenerate a resource's API key" | ||
end | ||
|
||
subcommand "snapshot", "Snapshots" do | ||
subcommand "show", "show an existing snapshot" | ||
subcommand "create", "create a new snapshot" | ||
subcommand "delete", "delete an existing snapshot" | ||
end | ||
end | ||
|
||
end | ||
end |
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,12 @@ | ||
require 'clamp' | ||
|
||
module Overwatch | ||
module CLI | ||
module Command | ||
class Base | ||
|
||
end | ||
end | ||
end | ||
|
||
require File.expand_path(File.join(File.dirname(__FILE__), "main")) |
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,14 @@ | ||
|
||
module Overwatch | ||
module CLI | ||
module Command | ||
|
||
class Main < Base | ||
|
||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
# require 'overwatch/cli/command/resource' |
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,11 @@ | ||
module Overwatch | ||
module CLI | ||
module Command | ||
class Resource < Main | ||
|
||
end | ||
|
||
end | ||
end | ||
end | ||
|
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,14 @@ | ||
module Overwatch | ||
module CLI | ||
module Command | ||
class Create < Resource | ||
|
||
option ['-n', '--name'], "NAME", "name of resource" | ||
|
||
def execute | ||
puts "CREATE" | ||
end | ||
end | ||
end | ||
end | ||
end |
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,11 @@ | ||
module Overwatch | ||
module CLI | ||
module Command | ||
|
||
class Resource::Delete < Base | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
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,12 @@ | ||
module Overwatch | ||
module CLI | ||
module Command | ||
module Resource | ||
class List < Overwatch::CLI::Command::Base | ||
|
||
end | ||
|
||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.