Permalink
Please sign in to comment.
Showing
with
92 additions
and 2 deletions.
- +0 −2 Gemfile
- +7 −0 bin/hoboku
- +2 −0 hoboku.gemspec
- +2 −0 lib/hoboku.rb
- +42 −0 lib/hoboku/app.rb
- +30 −0 lib/hoboku/cli.rb
- +9 −0 lib/hoboku/params.rb
@@ -1,4 +1,2 @@ | ||
source 'https://rubygems.org' | ||
- | ||
-# Specify your gem's dependencies in hoboku.gemspec | ||
gemspec |
@@ -0,0 +1,7 @@ | ||
+#!/usr/bin/env ruby | ||
+#vim:ft=ruby | ||
+ | ||
+require 'hoboku/cli' | ||
+ | ||
+$PROGRAM_NAME = File.basename(__FILE__) | ||
+Hoboku::CLI.start |
@@ -0,0 +1,42 @@ | ||
+module Hoboku | ||
+ class App | ||
+ attr_accessor :dir, :name | ||
+ | ||
+ def initialize(app_name=nil) | ||
+ @name = app_name || File.basename(dir) | ||
+ end | ||
+ | ||
+ def create | ||
+ print "Creating #{name}... " | ||
+ # create the app here | ||
+ puts "done" | ||
+ puts http_uri + ' | ' + git_uri | ||
+ add_remote | ||
+ end | ||
+ | ||
+ def hostname | ||
+ name + '.localhost' | ||
+ end | ||
+ | ||
+ def http_uri | ||
+ "http://#{hostname}/" | ||
+ end | ||
+ | ||
+ def git_uri | ||
+ ".hoboku/#{name}.git" | ||
+ end | ||
+ | ||
+ def browse | ||
+ system "open", http_uri | ||
+ end | ||
+ | ||
+ def add_remote | ||
+ # add git remote | ||
+ puts "Git remote hoboku added" | ||
+ end | ||
+ | ||
+ def dir | ||
+ @dir ||= `git rev-parse --show-toplevel 2>/dev/null || pwd`.chomp | ||
+ end | ||
+ end | ||
+end |
@@ -0,0 +1,30 @@ | ||
+require 'thor' | ||
+require 'hoboku/params' | ||
+require 'hoboku/app' | ||
+ | ||
+module Hoboku | ||
+ class CLI < Thor | ||
+ class_option :app, desc: "Name of the hoboku application", aliases: '-a' | ||
+ | ||
+ desc "create [APP_NAME]", "Create the hoboku app" | ||
+ def create(app_name=nil) | ||
+ params.app ||= app_name | ||
+ app.create | ||
+ end | ||
+ | ||
+ desc "browse", "Open the app in the browser" | ||
+ def browse | ||
+ app.browse | ||
+ end | ||
+ | ||
+ protected | ||
+ | ||
+ def params | ||
+ @params ||= Params.new(options) | ||
+ end | ||
+ | ||
+ def app | ||
+ @app ||= App.new(params.app) | ||
+ end | ||
+ end | ||
+end |
@@ -0,0 +1,9 @@ | ||
+require 'ostruct' | ||
+ | ||
+module Hoboku | ||
+ class Params < OpenStruct | ||
+ def app | ||
+ @table[:app] ||= ENV['APP_NAME'] | ||
+ end | ||
+ end | ||
+end |
0 comments on commit
5c3c7f5