Class: Rrm::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/rrm/repository.rb

Constant Summary collapse

CLONEDIR =
"/tmp/rrm/#{SecureRandom.uuid}/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, level, update_gems) ⇒ Repository

Returns a new instance of Repository.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rrm/repository.rb', line 13

def initialize(url, level, update_gems)
  @url = url
  @name = url.split('/').last.gsub('.git', '')
  @dockerfile   = Rrm::Dockerfile.new(git)
  @gemfile      = Rrm::Gemfile.new(git)
  @gemfile_lock = Rrm::GemfileLock.new(git, update_gems)
  @gitlab_ci    = Rrm::GitlabCi.new(git)
  @rubocop      = Rrm::Rubocop.new(git)
  @travis       = Rrm::Travis.new(git)
  @major, @minor, @patch = current_version.split('.')
  @level = level
end

Instance Attribute Details

#branch_nameObject

Returns the value of attribute branch_name.



11
12
13
# File 'lib/rrm/repository.rb', line 11

def branch_name
  @branch_name
end

#dockerfileObject

Returns the value of attribute dockerfile.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def dockerfile
  @dockerfile
end

#gemfileObject

Returns the value of attribute gemfile.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def gemfile
  @gemfile
end

#gemfile_lockObject

Returns the value of attribute gemfile_lock.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def gemfile_lock
  @gemfile_lock
end

#gitlab_ciObject

Returns the value of attribute gitlab_ci.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def gitlab_ci
  @gitlab_ci
end

#levelObject

Returns the value of attribute level.



8
9
10
# File 'lib/rrm/repository.rb', line 8

def level
  @level
end

#majorObject

Returns the value of attribute major.



9
10
11
# File 'lib/rrm/repository.rb', line 9

def major
  @major
end

#minorObject

Returns the value of attribute minor.



9
10
11
# File 'lib/rrm/repository.rb', line 9

def minor
  @minor
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/rrm/repository.rb', line 8

def name
  @name
end

#patchObject

Returns the value of attribute patch.



9
10
11
# File 'lib/rrm/repository.rb', line 9

def patch
  @patch
end

#rubocopObject

Returns the value of attribute rubocop.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def rubocop
  @rubocop
end

#travisObject

Returns the value of attribute travis.



10
11
12
# File 'lib/rrm/repository.rb', line 10

def travis
  @travis
end

#urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/rrm/repository.rb', line 8

def url
  @url
end

Instance Method Details

#current_versionObject



30
31
32
# File 'lib/rrm/repository.rb', line 30

def current_version
  @current_version ||= fetch_current_version
end

#gitObject



26
27
28
# File 'lib/rrm/repository.rb', line 26

def git
  @git ||= clone_or_update_git
end

#new_versionObject



34
35
36
# File 'lib/rrm/repository.rb', line 34

def new_version
  @new_version ||= decide_new_ruby_version
end

#push!Object



51
52
53
# File 'lib/rrm/repository.rb', line 51

def push!
  git.push('origin', @branch_name)
end

#update!Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rrm/repository.rb', line 38

def update!
  Rrm.logger.debug "Updating #{name} from #{current_version} to #{new_version}"
  create_branch
  dockerfile.update!(new_version)
  gemfile.update!(new_version)
  gemfile_lock.update!(new_version)
  gitlab_ci.update!(new_version)
  rubocop.update!(new_version.split('.')[0..1].join('.'))
  travis.update!(new_version)
rescue
  Rrm.logger.warn("Failed to update! #{$!.message} - #{$!.backtrace}")
end