Class: Steep::Project

Inherits:
Object show all
Defined in:
lib/steep/project.rb,
lib/steep/project/dsl.rb,
lib/steep/project/group.rb,
lib/steep/project/target.rb,
lib/steep/project/options.rb,
lib/steep/project/pattern.rb

Defined Under Namespace

Classes: DSL, Group, Options, Pattern, Target

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(steepfile_path:, base_dir: nil) ⇒ Project

Returns a new instance of Project.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/steep/project.rb', line 8

def initialize(steepfile_path:, base_dir: nil)
  @targets = []
  @steepfile_path = steepfile_path
  @base_dir = if base_dir
    base_dir
  elsif steepfile_path
    steepfile_path.parent
  else
    raise ArgumentError, "Project#initialize(base_dir:): neither base_dir nor steepfile_path given"
  end

  if steepfile_path and !steepfile_path.absolute?
    raise ArgumentError, "Project#initialize(steepfile_path:): steepfile_path should be absolute path"
  end
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



5
6
7
# File 'lib/steep/project.rb', line 5

def base_dir
  @base_dir
end

#global_optionsObject

Returns the value of attribute global_options.



6
7
8
# File 'lib/steep/project.rb', line 6

def global_options
  @global_options
end

#steepfile_pathObject (readonly)

Returns the value of attribute steepfile_path.



4
5
6
# File 'lib/steep/project.rb', line 4

def steepfile_path
  @steepfile_path
end

#targetsObject (readonly)

Returns the value of attribute targets.



3
4
5
# File 'lib/steep/project.rb', line 3

def targets
  @targets
end

Instance Method Details

#absolute_path(path) ⇒ Object



30
31
32
# File 'lib/steep/project.rb', line 30

def absolute_path(path)
  (base_dir + path).cleanpath
end

#group_for_inline_source_path(path) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/steep/project.rb', line 56

def group_for_inline_source_path(path)
  relative = relative_path(path)
  targets.each do
    ret = _1.possible_inline_source_file?(relative)
    return ret if ret
  end

  nil
end

#group_for_path(path) ⇒ Object



43
44
45
# File 'lib/steep/project.rb', line 43

def group_for_path(path)
  group_for_source_path(path) || group_for_signature_path(path) || group_for_inline_source_path(path)
end

#group_for_signature_path(path) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/steep/project.rb', line 47

def group_for_signature_path(path)
  relative = relative_path(path)
  targets.each do
    ret = _1.possible_signature_file?(relative)
    return ret if ret
  end
  nil
end

#group_for_source_path(path) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/steep/project.rb', line 34

def group_for_source_path(path)
  path = relative_path(path)
  targets.each do |target|
    ret = target.possible_source_file?(path)
    return ret if ret
  end
  nil
end

#relative_path(path) ⇒ Object



24
25
26
27
28
# File 'lib/steep/project.rb', line 24

def relative_path(path)
  path.relative_path_from(base_dir)
rescue ArgumentError
  path
end

#target_for_inline_source_path(path) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/steep/project.rb', line 84

def target_for_inline_source_path(path)
  case group = group_for_inline_source_path(path)
  when Target
    group
  when Group
    group.target
  end
end

#target_for_path(path) ⇒ Object



93
94
95
# File 'lib/steep/project.rb', line 93

def target_for_path(path)
  target_for_source_path(path) || target_for_signature_path(path) || target_for_inline_source_path(path)
end

#target_for_signature_path(path) ⇒ Object



75
76
77
78
79
80
81
82
# File 'lib/steep/project.rb', line 75

def target_for_signature_path(path)
  case group = group_for_signature_path(path)
  when Target
    group
  when Group
    group.target
  end
end

#target_for_source_path(path) ⇒ Object



66
67
68
69
70
71
72
73
# File 'lib/steep/project.rb', line 66

def target_for_source_path(path)
  case group = group_for_source_path(path)
  when Target
    group
  when Group
    group.target
  end
end