Class: JiraCommand::Command::Config

Inherits:
Thor
  • Object
show all
Defined in:
lib/jira_command/command/config.rb

Instance Method Summary collapse

Instance Method Details

#clearObject



77
78
79
80
# File 'lib/jira_command/command/config.rb', line 77

def clear
  prompt = TTY::Prompt.new
  JiraCommand::Config.new.clear if prompt.yes?('Are you sure to clear?')
end

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/jira_command/command/config.rb', line 16

def create
  if JiraCommand::Config.check_exist
    puts 'config file has been already existed. if you want to renew it, please execute `jira_command config clear` first'
    exit 1
  end

  prompt = TTY::Prompt.new

  jira_url = prompt.ask('Please input your site url:')
  email = prompt.ask('Please input your registered email address:')
  token = prompt.mask('Please input your token:')

  jira_url += '/' unless jira_url.end_with?('/')
  config = { jira_url: jira_url, header_token: Base64.strict_encode64("#{email}:#{token}") }

  JiraCommand::Config.new.write(config)
end

#update_boardObject



67
68
69
70
71
72
73
74
# File 'lib/jira_command/command/config.rb', line 67

def update_board
  config = JiraCommand::Config.new.read
  agile_board = JiraCommand::Jira::Board.new(config)
  config.merge!({
                  boards: agile_board.list
                })
  JiraCommand::Config.new.write(config)
end

#update_itObject



57
58
59
60
61
62
63
64
# File 'lib/jira_command/command/config.rb', line 57

def update_it
  config = JiraCommand::Config.new.read
  jira_issue_type = JiraCommand::Jira::IssueType.new(config)
  config.merge!({
                  issue_types: jira_issue_type.list
                })
  JiraCommand::Config.new.write(config)
end

#update_projectsObject



35
36
37
38
39
40
41
42
43
# File 'lib/jira_command/command/config.rb', line 35

def update_projects
  config = JiraCommand::Config.new.read

  jira_project = JiraCommand::Jira::Project.new(config)
  config.merge!({
                  projects: jira_project.list
                })
  JiraCommand::Config.new.write(config)
end

#update_usersObject



47
48
49
50
51
52
53
54
# File 'lib/jira_command/command/config.rb', line 47

def update_users
  config = JiraCommand::Config.new.read
  user_api = JiraCommand::Jira::User.new(config)
  config.merge!({
                  users: user_api.all_list(project: options[:project])
                })
  JiraCommand::Config.new.write(config)
end