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_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 |
# 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_list ⇒ String
Backend method for bit scope list.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/takelage/bit/scope/module.rb', line 42 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['bit_scope_list'] % {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.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/takelage/bit/scope/module.rb', line 68 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['bit_scope_new'] % {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 |