Class: Hive::Toolbelt::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/hive/toolbelt/cli.rb

Constant Summary collapse

MANIFEST =
"manifest.json"
INDEX =
"index.html"
ICON =
"icon.png"
README =
"README.md"
LICENSE =
"MIT-LICENSE.txt"

Instance Method Summary collapse

Instance Method Details

#initObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/hive/toolbelt/cli.rb', line 20

def init
  config = {}
  config[:name] = ask("App Name: ")
  config[:description] = ask("Description: ")
  config[:author] = ask("Author Name: ")
  config[:contact] = ask("Author Contact: ")
  config[:repoURL] = ask("Git Repository URL: ")
  config[:accessedHosts] = ask("API hosts the app needs to talk to (separated by comma. e.g. api.github.com, www.bitstamp.net): ")

  create_manifest(config)
  copy_default_icon
  copy_api_mock # for in-browser development
  create_index_html config[:name]
  create_readme config
  create_license config[:author]
  create_empty_folders
end

#package(dir_name = '.') ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hive/toolbelt/cli.rb', line 39

def package dir_name='.'
  directory = sanitize_dir_name dir_name
  check_for_required_files directory

  bundle_name = bundle_name_from_manifest(File.join directory, MANIFEST)
  FileUtils.rm(bundle_name) if File.exists? bundle_name
  bundle_files bundle_name, directory

  say "#{bundle_name} packaged successfully", :green
rescue PackageError => e
  say e.message, :red
end