Class: Gemsmith::CLI

Inherits:
Thor
  • Object
show all
Includes:
CLIHelpers, CLIOptions, Thor::Actions, ThorPlus::Actions
Defined in:
lib/gemsmith/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CLIHelpers

#editor, enforce_symbol_keys, #gem_class, #gem_name, open_gem, pick_gem, print_gems, process_gem, read_gem, #template_options

Methods included from CLIOptions

author_email, author_name, author_url, company_name, company_url, default_boolean, gem_platform, gem_private_key, gem_public_key, gem_url, github_user, initialize_template_options, rails_version, ruby_version, year

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ CLI

Initialize.



30
31
32
33
34
35
# File 'lib/gemsmith/cli.rb', line 30

def initialize args = [], options = {}, config = {}
  super args, options, config
  @settings_file = File.join ENV["HOME"], ".gemsmith", "settings.yml"
  @settings = load_yaml @settings_file
  @template_options = {}
end

Class Method Details

.source_rootObject

Overwrites the Thor template source root.



25
26
27
# File 'lib/gemsmith/cli.rb', line 25

def self.source_root
  File.expand_path File.join(File.dirname(__FILE__), "templates")
end

Instance Method Details

#create(name) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gemsmith/cli.rb', line 47

def create name
  say
  info "Creating gem..."

  initialize_template_options name, options
  Skeletons::DefaultSkeleton.run self
  Skeletons::DocumentationSkeleton.run self
  Skeletons::CLISkeleton.run(self) if template_options[:bin]
  Skeletons::RailsSkeleton.run(self) if template_options[:rails]
  Skeletons::RspecSkeleton.run(self) if template_options[:rspec]
  Skeletons::GuardSkeleton.run(self) if template_options[:guard]
  Skeletons::TravisSkeleton.run(self) if template_options[:travis]
  Skeletons::GitSkeleton.run self

  info "Gem created."
  say
end

#editObject



79
80
81
# File 'lib/gemsmith/cli.rb', line 79

def edit
  `#{editor} #{@settings_file}`
end

#help(task = nil) ⇒ Object



91
92
93
# File 'lib/gemsmith/cli.rb', line 91

def help task = nil
  say and super
end

#open(name) ⇒ Object



67
68
69
# File 'lib/gemsmith/cli.rb', line 67

def open name
  process_gem name, "open"
end

#read(name) ⇒ Object



73
74
75
# File 'lib/gemsmith/cli.rb', line 73

def read name
  process_gem name, "read"
end

#versionObject



85
86
87
# File 'lib/gemsmith/cli.rb', line 85

def version
  say "Gemsmith " + VERSION
end