Module: Squared::Workspace::Repo

Includes:
Format, Common, System, Task
Included in:
Application
Defined in:
lib/squared/workspace/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#warningObject

Returns the value of attribute warning.



11
12
13
# File 'lib/squared/workspace/repo.rb', line 11

def warning
  @warning
end

Instance Method Details

#repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil) ⇒ Object



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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/squared/workspace/repo.rb', line 13

def repo(url, manifest = 'latest', run: nil, dev: nil, prod: nil)
  @home = if (val = env('REPO_HOME'))
            home = Pathname.new(val)
            if @main == home.basename.to_s
              @root = home.parent
              if home.exist?
                @root = nil unless home.directory?
              elsif !@root.exist?
                @root.mkpath
              elsif !install?
                @root = nil unless confirm_install
              end
            end
            raise_error('REPO_HOME', val, hint: 'invalid') unless @root

            home.realdirpath
          elsif (val = env('REPO_ROOT'))
            @root = Pathname.new(val).realdirpath
            if !@root.exist?
              @root.mkpath
            elsif !install?
              raise_error('REPO_ROOT', val, hint: 'exist') unless confirm_install
            end
            @root.join(@main).realdirpath
          else
            install?(pwd = Pathname.pwd) ? pwd.join(@main) : pwd
          end
  @root = @home.parent
  @manifest_url = url
  @manifest = manifest
  if repo?
    @script[:build] = case (val = env('REPO_BUILD'))
                      when 'verbose'
                        @verbose = true
                        "#{run}:verbose" if run
                      when 'silent'
                        @verbose = false
                        @warning = false
                        run
                      else
                        val || run
                      end
    @script[:dev] = bool_match(env('REPO_DEV'), dev)
    @script[:prod] = bool_match(env('REPO_PROD'), prod)
    @warning = case env('REPO_WARN')
               when '0'
                 false
               when '1'
                 true
               else
                 !empty?(@root)
               end
    @extensions << :__repo__
  else
    @script[:build] = run
    @script[:dev] = dev
    @script[:prod] = prod
  end
  self
end