Class: Vendor::CLI::App::Library

Inherits:
Thor
  • Object
show all
Defined in:
lib/vendor/cli/app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.printable_tasks(all = true, subcommand = false) ⇒ Object

This is a hack so Thor doesn’t output 2 help commands…



52
53
54
# File 'lib/vendor/cli/app.rb', line 52

def self.printable_tasks(all = true, subcommand = false)
  super.delete_if { |x| x[0].match(/vendor help/) }
end

Instance Method Details

#build(file) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/vendor/cli/app.rb', line 28

def build(file)
  builder = Vendor::VendorSpec::Builder.new(File.expand_path(file))
  if builder.build
    Vendor.ui.success "Successfully built library"
    Vendor.ui.info "Name: #{builder.name}"
    Vendor.ui.info "Version: #{builder.version}"
    Vendor.ui.info "File: #{builder.filename}"
  end
end

#initObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vendor/cli/app.rb', line 10

def init
  # Use the current folder name as the name of the vendorspec
  name = File.basename(Dir.pwd)

  # Figure out who should be the author
  username = `git config --get github.user` ||
             `git config --get github.user` ||
             `whoami`
  email    = `git config --get user.email` ||
             "#{username}@example.com"

  Vendor::Template.copy "vendorspec", :name => "#{name}.vendorspec",
                                      :locals => { :name => name,
                                                   :username => username.chomp,
                                                   :email => email.chomp }
end

#push(file) ⇒ Object



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

def push(file)
  begin
    Vendor::CLI::Auth.with_api_key do |api_key|
      url = Vendor::API.push :file => File.expand_path(file), :api_key => api_key
      Vendor.ui.success "Successfully pushed to #{Vendor::API.api_uri}#{url}"
    end
  rescue Vendor::API::Error => e
    Vendor.ui.error "Error: #{e.message}"
    exit 1
  end
end