summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-07-24 15:25:22 -0400
committerDaniel Beauchamp <daniel.beauchamp@shopify.com>2012-07-24 15:30:32 -0400
commitc63c8f1698e8c059e286fb49ba0264e4336a6e33 (patch)
tree372fa45a424f4de805112995be3e0074ce9e0125 /bin
parent9f625f927aadf6d9574bd968d2cfc29dde5551c0 (diff)
Initial version. 0.1.0 Release
Diffstat (limited to 'bin')
-rwxr-xr-xbin/att66
1 files changed, 66 insertions, 0 deletions
diff --git a/bin/att b/bin/att
new file mode 100755
index 0000000..fe8db05
--- /dev/null
+++ b/bin/att
@@ -0,0 +1,66 @@
+#!/usr/bin/env ruby
+
+require 'thor'
+require 'net/http'
+require 'json'
+
+class MockScheduler
+ def method_missing(*args)
+ yield
+ end
+end
+
+def send_event(id, data)
+ req = Net::HTTP::Post.new("/widgets/#{id}")
+ req["content-type"] = "application/json"
+ req.body = JSON.unparse(data.merge(:auth_token => AllTheThings::CLI.auth_token))
+ res = Net::HTTP.new('localhost', 3000).start { |http| http.request(req) }
+ puts "Data Sent to #{id}: #{data}"
+end
+
+SCHEDULER = MockScheduler.new
+
+module AllTheThings
+
+ class CLI < Thor
+ include Thor::Actions
+
+ class << self
+ attr_accessor :auth_token
+ end
+
+ attr_accessor :name
+
+ 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)
+ @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 = Thor::Util.snake_case(name)
+ directory :widget, File.join('widgets', @name)
+ end
+
+ desc "start", "Starts the server in style!"
+ def start(*args)
+ args = args.join(" ")
+ system("bundle exec thin -R config.ru start #{args}")
+ end
+
+ desc "job JOB_NAME AUTH_TOKEN(optional)", "Runs the specified job."
+ def job(name, auth_token = "")
+ self.class.auth_token = auth_token
+ f = File.join(Dir.pwd, "jobs", "#{name}.rb")
+ require f
+ end
+
+ end
+end
+
+AllTheThings::CLI.start \ No newline at end of file