Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in hoboku.gemspec | ||
gemspec |
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,7 @@ | ||
#!/usr/bin/env ruby | ||
#vim:ft=ruby | ||
|
||
require 'hoboku/cli' | ||
|
||
$PROGRAM_NAME = File.basename(__FILE__) | ||
Hoboku::CLI.start |
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,6 @@ | ||
require "hoboku/version" | ||
require "hoboku/cli" | ||
require "hoboku/app" | ||
|
||
module Hoboku | ||
# Your code goes 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 |
---|---|---|
@@ -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 |
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,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 |
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,9 @@ | ||
require 'ostruct' | ||
|
||
module Hoboku | ||
class Params < OpenStruct | ||
def app | ||
@table[:app] ||= ENV['APP_NAME'] | ||
end | ||
end | ||
end |