Class: Linguist::Command::Project

Inherits:
Base
  • Object
show all
Defined in:
lib/linguist_ruby/commands/project.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from Base

#app_urls, #escape, #extract_app_from_git_config, #extract_option, #extract_project_title_from_args, #extract_project_title_from_dir_name, #extract_project_title_from_git, #git_remotes, #git_url, #initialize, #linguist, #project, #project_title

Methods included from Helpers

#ask, #confirm, #confirm_command, #deprecate, #display, #error, #format_date, #git, #has_git?, #home_directory, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #shell

Constructor Details

This class inherits a constructor from Linguist::Command::Base

Instance Method Details

#createObject



26
27
28
29
30
31
# File 'lib/linguist_ruby/commands/project.rb', line 26

def create
  title = args.shift.downcase.strip rescue nil
  title ||= extract_from_dir_name
  linguist.projects.create title
  display("Created #{title}")
end

#destroyObject



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/linguist_ruby/commands/project.rb', line 55

def destroy
  display "=== #{project.title}"
  display "Web URL:        #{project.weburl}"
  display "Owner:          #{project.owner}"

  if confirm_command(project_title)
    redisplay "Destroying #{project_title} ... "
    project.destroy
    display "done"
  end
end

#infoObject



44
45
46
47
48
49
# File 'lib/linguist_ruby/commands/project.rb', line 44

def info
  display "=== #{project.title}"
  display "Web URL:        #{project.weburl}"
  display "Owner:          #{project.owner}"
  display "Number of translation:      #{project.translations_count}"
end

#listObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/linguist_ruby/commands/project.rb', line 15

def list
  list = linguist.projects.all
  if list.size > 0
    display "Projects:\n" + list.keys.map { |name|
      "- #{name}"
    }.join("\n")
  else
    display "You have no projects."
  end
end

#loginObject



6
7
8
# File 'lib/linguist_ruby/commands/project.rb', line 6

def 
  Linguist::Command.run_internal "auth:reauthorize", args.dup
end

#logoutObject



10
11
12
13
# File 'lib/linguist_ruby/commands/project.rb', line 10

def logout
  Linguist::Command.run_internal "auth:delete_credentials", args.dup
  display "Local credentials cleared."
end

#openObject



51
52
53
# File 'lib/linguist_ruby/commands/project.rb', line 51

def open
  Launchy.open project.weburl
end

#renameObject



33
34
35
36
37
38
39
40
41
42
# File 'lib/linguist_ruby/commands/project.rb', line 33

def rename
  oldtitle = project.title

  newtitle = args[1].downcase.strip rescue raise(CommandFailed, "Invalid new project name")

  project.update(:title => newtitle)
  display("Renaming project from #{oldtitle} to #{newtitle}")

  display app_urls(newtitle)
end