Class: Buildr::IntellijIdea::IdeaFile

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/ide/idea.rb

Overview

Abstract base class for IdeaModule and IdeaProject

Direct Known Subclasses

IdeaModule, IdeaProject

Constant Summary collapse

DEFAULT_PREFIX =
''
DEFAULT_SUFFIX =
''
DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE =
'MAVEN_REPOSITORY'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIdeaFile

Returns a new instance of IdeaFile.



35
36
37
# File 'lib/buildr/ide/idea.rb', line 35

def initialize
  @local_repository_env_override = DEFAULT_LOCAL_REPOSITORY_ENV_OVERRIDE
end

Instance Attribute Details

#buildr_projectObject (readonly)

Returns the value of attribute buildr_project.



28
29
30
# File 'lib/buildr/ide/idea.rb', line 28

def buildr_project
  @buildr_project
end

#idObject



51
52
53
# File 'lib/buildr/ide/idea.rb', line 51

def id
  @id ||= buildr_project.name.split(':').last
end

#local_repository_env_overrideObject

Returns the value of attribute local_repository_env_override.



33
34
35
# File 'lib/buildr/ide/idea.rb', line 33

def local_repository_env_override
  @local_repository_env_override
end

#prefixObject



39
40
41
# File 'lib/buildr/ide/idea.rb', line 39

def prefix
  @prefix ||= DEFAULT_PREFIX
end

#suffixObject



43
44
45
# File 'lib/buildr/ide/idea.rb', line 43

def suffix
  @suffix ||= DEFAULT_SUFFIX
end

#templateObject

Returns the value of attribute template.



32
33
34
# File 'lib/buildr/ide/idea.rb', line 32

def template
  @template
end

Instance Method Details

#add_component(name, attrs = {}, &xml) ⇒ Object



55
56
57
# File 'lib/buildr/ide/idea.rb', line 55

def add_component(name, attrs = {}, &xml)
  self.components << create_component(name, attrs, &xml)
end

#add_component_from_artifact(artifact) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/buildr/ide/idea.rb', line 66

def add_component_from_artifact(artifact)
  self.components << lambda do
    a = Buildr.artifact(artifact)
    a.invoke
    Buildr::IntellijIdea.new_document(IO.read(a.to_s)).root
  end
end

#add_component_from_file(filename) ⇒ Object



59
60
61
62
63
64
# File 'lib/buildr/ide/idea.rb', line 59

def add_component_from_file(filename)
  self.components << lambda do
    raise "Unable to locate file #{filename} adding component to idea file" unless File.exist?(filename)
    Buildr::IntellijIdea.new_document(IO.read(filename)).root
  end
end

#filenameObject



47
48
49
# File 'lib/buildr/ide/idea.rb', line 47

def filename
  buildr_project.path_to("#{name}.#{extension}")
end

#nameObject



80
81
82
# File 'lib/buildr/ide/idea.rb', line 80

def name
  "#{prefix}#{self.id}#{suffix}"
end

#write(f) ⇒ Object

IDEA can not handle text content with indents so need to removing indenting Can not pass true as third argument as the ruby library seems broken



76
77
78
# File 'lib/buildr/ide/idea.rb', line 76

def write(f)
  document.write(f, -1, false, true)
end