summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-08-02 13:38:19 -0400
committerDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-08-02 13:38:19 -0400
commitcdd8ff258582f5eba7e3941a5a18007e7aabbbfa (patch)
tree259644bbbda24070efc5685445e6b26187a70b20 /bin
parent1dcf732b801f9fa513901fda27388a36eddb44ab (diff)
Better generators, sample widgets, and more!
Diffstat (limited to 'bin')
-rwxr-xr-xbin/things (renamed from bin/att)29
1 files changed, 22 insertions, 7 deletions
diff --git a/bin/att b/bin/things
index c90fc48..0ad9eb3 100755
--- a/bin/att
+++ b/bin/things
@@ -31,30 +31,45 @@ module AllTheThings
attr_accessor :name
+ no_tasks do
+ ['widget', 'dashboard', 'job'].each do |type|
+ define_method "generate_#{type}" do |name|
+ @name = Thor::Util.snake_case(name)
+ directory type.to_sym, File.join("#{type}s")
+ end
+ end
+ end
+
def self.source_root
File.expand_path('../../templates', __FILE__)
end
- desc "install PROJECT_NAME", "Sets up ALL THE THINGS needed for your dashboard project structure."
- def install(name)
+ desc "new PROJECT_NAME", "Sets up ALL THE THINGS needed for your dashboard project structure."
+ def new(name)
@name = Thor::Util.snake_case(name)
directory :project, @name
end
- desc "new_widget WIDGET_NAME", "Creates a new widget with all the fixins'"
- def new_widget(name)
- @name = "widget_#{Thor::Util.snake_case(name)}"
- directory :widget, File.join('widgets', @name)
+ desc "generate GENERATOR NAME", "Creates a new widget with all the fixins'"
+ def generate(type, name)
+ send("generate_#{type}".to_sym, name)
+ rescue NoMethodError => e
+ puts "Invalid generator. Either use widget, dashboard, or job"
end
+ map "g" => :generate
desc "start", "Starts the server in style!"
+ method_option :job_path, :desc => "Specify the directory where jobs are stored"
def start(*args)
args = args.join(" ")
- system("bundle exec thin -R config.ru start #{args}")
+ command = "bundle exec thin -R config.ru start #{args}"
+ command.prepend "export JOB_PATH=#{options[:job_path]}; " if options[:job_path]
+ system(command)
end
desc "job JOB_NAME AUTH_TOKEN(optional)", "Runs the specified job."
def job(name, auth_token = "")
+ Dir[File.join(Dir.pwd, 'lib/**/*.rb')].each {|file| require file }
self.class.auth_token = auth_token
f = File.join(Dir.pwd, "jobs", "#{name}.rb")
require f