Class: Submodule::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/submodule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Task

Returns a new instance of Task.

Yields:

  • (_self)

Yield Parameters:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/submodule.rb', line 11

def initialize 
  @cwd = Dir.pwd

  base = File.basename Dir["*.gemspec"][0], ".gemspec"
  if base[0]  
    base = File.basename Dir["*.gemspec"][0], ".gemspec"
    @version_file = "lib/#{base}/version.rb"
  end

  gitmodules = IniFile.new('./.gitmodules').to_h
  @path = gitmodules[gitmodules.keys.first]["path"]
  @path = File.expand_path(@path, @cwd)
  @submodule_name = gitmodules.keys.first.gsub('submodule ', '').gsub('"', '').gsub('vendor/', '')
  @github = gitmodules[gitmodules.keys.first]["url"].gsub('https://github.com/', '').gsub('.git', '')

  # TODO: detect default branch
  @branch = "master"

  yield self if block_given?
  define
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



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

def branch
  @branch
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end