Module: BitScopeModule
- Included in:
- Takelage::BitScope
- Defined in:
- lib/takelage/bit/scope/module.rb
Overview
takelage bit scope module
Instance Method Summary collapse
-
#bit_scope_add(scope) ⇒ Object
Backend method for bit scope add.
-
#bit_scope_inbit ⇒ Object
Backend method for bit scope inbit.
-
#bit_scope_list ⇒ String
Backend method for bit scope list.
-
#bit_scope_new(scope) ⇒ Int
Backend method for bit scope new.
Instance Method Details
#bit_scope_add(scope) ⇒ Object
Backend method for bit scope add.
5 6 7 8 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 |
# File 'lib/takelage/bit/scope/module.rb', line 5 def bit_scope_add(scope) log.debug "Adding bit remote scope \"#{scope}\" to local workspace" return false unless configured? %w(bit_ssh bit_remote) unless bit_check_workspace log.error 'No bit workspace' return false end if git_check_workspace unless git_check_master log.error 'Not on git master branch' return false end end # check if bit remote scope exists scope_list = bit_scope_list log.debug scope_list unless scope_list.include? scope log.error "The bit remote bit scope \"#{scope}\" doesn't exist" return false end # get bit remote from active config bit_remote = config.active['bit_remote'] # prepare scope add command cmd_bit_scope_add = "bit remote add #{bit_remote}/#{scope}" run cmd_bit_scope_add log.info "Added bit remote scope \"#{scope}\" to local bit workspace" end |
#bit_scope_inbit ⇒ Object
Backend method for bit scope inbit.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/takelage/bit/scope/module.rb', line 42 def bit_scope_inbit log.debug "Logging in to bit remote server" return false unless configured? %w(bit_ssh) cmd_bit_scope_login = config.active['bit_ssh'] run_and_exit cmd_bit_scope_login end |
#bit_scope_list ⇒ String
Backend method for bit scope list.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/takelage/bit/scope/module.rb', line 55 def bit_scope_list log.debug "Listing bit remote scopes" return false unless configured? %w(bit_ssh bit_remote) # get ssh command from active config cmd_bit_ssh = config.active['bit_ssh'] # prepare scope list command root = config.active['bit_scope_root'] cmd_bit_scope_list = config.active['cmd_bit_scope_list_find_scopes'] % { root: root } # run ssh command with scope list command scope_list = run "#{cmd_bit_ssh} '#{cmd_bit_scope_list}'" # remove bit remote root directory from results scope_list.gsub!(/#{root}\/*/, '') # remove /scope.json from results scope_list.gsub!(/\/scope.json/, '') scope_list end |
#bit_scope_new(scope) ⇒ Int
Backend method for bit scope new.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/takelage/bit/scope/module.rb', line 87 def bit_scope_new(scope) log.debug "Creating new bit remote scope \"#{scope}\"" return false unless configured? %w(bit_ssh bit_remote) # check if bit remote scope already exists scope_list = bit_scope_list if scope_list.include? scope log.error "The remote bit scope \"#{scope}\" already exists" return false end # get ssh command from active config cmd_bit_ssh = config.active['bit_ssh'] # prepare scope list command root = config.active['bit_scope_root'] cmd_bit_scope_new = config.active['cmd_bit_scope_new_bit_init'] % { scope: scope, root: root } # run ssh command with scope new command run "#{cmd_bit_ssh} '#{cmd_bit_scope_new}'" log.info "Created new bit remote scope \"#{scope}\"" end |