Class: Fgi::Configuration

Inherits:
Object
  • Object
show all
Extended by:
HttpRequests
Defined in:
lib/fgi/configuration.rb

Class Method Summary collapse

Methods included from HttpRequests

get, post

Class Method Details

.new_configObject

Launch the process to create the fresh project fgi config file



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fgi/configuration.rb', line 9

def new_config
  puts '####################################################################'
  puts '##          Welcome to Fast Gitlab Issues configuration           ##'
  puts "####################################################################\n\n"

  # -------------------------- #
  #          CHECKERS          #
  # -------------------------- #

  git_directory?
  already_configured?

  # -------------------------- #
  #        INITIALIZERS        #
  # -------------------------- #

  # The hash that will contain the project's fgi configuration to save as yml
  # It will contain :
  #    :url
  #    :routes
  #    :project_id
  #    :project_slug
  #    :default_branch
  config                     = {}

  config[:git_service_class] = define_git_service
  config[:url]               = save_git_url

  # Instanciation of the Git service class
  # TODO - HARD REFECTO NEEDED HERE...
  git_service                = config[:git_service_class].new(config: config)
  config[:git_service]       = git_service.to_sym
  user_token                 = save_user_token(config: config, git_service: git_service)
  project_name_and_id        = define_project_name_and_id(git_service, user_token)
  config                     = config.merge(project_name_and_id)
  git_service                = config[:git_service_class].new(config: config)
  config[:default_branch]    = define_default_branch(git_service, user_token)

  # -------------------------- #
  #          CREATORS          #
  # -------------------------- #

  Fgi::Tokens.create_user_tokens_file(config: config, git_service: git_service, token: user_token)
  create_fgi_config_file(config)
end