Module: Overapp

Defined in:
lib/overapp.rb,
lib/overapp/var.rb,
lib/overapp/files.rb,
lib/overapp/project.rb,
lib/overapp/util/cmd.rb,
lib/overapp/util/dir.rb,
lib/overapp/util/git.rb,
lib/overapp/load/base.rb,
lib/overapp/util/file.rb,
lib/overapp/util/write.rb,
lib/overapp/load/factory.rb,
lib/overapp/util/tmp_dir.rb,
lib/overapp/load/instance.rb,
lib/overapp/project/write.rb,
lib/overapp/template_file.rb,
lib/overapp/project/config.rb,
lib/overapp/load/types/repo.rb,
lib/overapp/load/types/command.rb,
lib/overapp/load/types/project.rb,
lib/overapp/load/types/raw_dir.rb,
lib/overapp/load/types/local_dir.rb,
lib/overapp/project/config_entry.rb,
lib/overapp/template_file/params.rb,
lib/overapp/template_file/var_obj.rb,
lib/overapp/template_file/body_mod.rb

Defined Under Namespace

Modules: Load Classes: BasicFile, ConfigEntry, Files, Git, MissingBaseFileError, Project, ProjectConfig, TemplateFile, TmpDir, Var

Class Method Summary collapse

Class Method Details

.dir_files(dir) ⇒ Object



3
4
5
6
7
# File 'lib/overapp/util/dir.rb', line 3

def dir_files(dir)
  res = Dir["#{dir}/**/*"] + Dir["#{dir}/**/.*"]
  res = res - [".","..",".git"]
  res = res.select { |x| FileTest.file?(x) }
end

.dir_files_full(dir) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/overapp/util/dir.rb', line 8

def dir_files_full(dir)
  raise "Dir not there #{dir}" unless FileTest.exist?(dir)
  dir_files(dir).map do |full_file|
    f = full_file.gsub("#{dir}/","")
    raise "bad #{f}" if f == full_file
    {:file => f, :body => read(full_file)}
  end
end

.ec(*args) ⇒ Object



3
4
5
# File 'lib/overapp/util/cmd.rb', line 3

def ec(*args)
  MharrisExt.ec(*args)
end

.file_create(*args) ⇒ Object



3
4
5
# File 'lib/overapp/util/file.rb', line 3

def file_create(*args)
  File.create(*args)
end

.load_files!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
# File 'lib/overapp.rb', line 13

def self.load_files!
  %w(files template_file project from_command var).each do |f|
    load File.dirname(__FILE__) + "/overapp/#{f}.rb"
  end

  %w(base instance factory).each do |f|
    load File.dirname(__FILE__) + "/overapp/load/#{f}.rb"
  end

  %w(command raw_dir local_dir repo empty project).each do |f|
    load File.dirname(__FILE__) + "/overapp/load/types/#{f}.rb"
  end

  %w(config write config_entry).each do |f|
    load File.dirname(__FILE__) + "/overapp/project/#{f}.rb"
  end

  %w(tmp_dir git dir cmd write file).each do |f|
    load File.dirname(__FILE__) + "/overapp/util/#{f}.rb"
  end

  %w(params body_mod var_obj).each do |f|
    load File.dirname(__FILE__) + "/overapp/template_file/#{f}.rb"
  end
end

.read(file) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/overapp/util/dir.rb', line 17

def read(file)
  if File.binary?(file)
    File.open(file,"rb") do |f|
      f.read
    end
  else
    File.read(file)
  end
end

.to_proper_dir(dir) ⇒ Object



38
39
40
41
# File 'lib/overapp/util/dir.rb', line 38

def to_proper_dir(dir)
  base = File.expand_path(File.dirname(__FILE__) + "/../../..")
  dir.gsub("OVERAPP_ROOT_DIR",base)
end

.with_local_path(overapp_path, &b) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/overapp/util/dir.rb', line 28

def with_local_path(overapp_path,&b)
  if Git.repo?(overapp_path)
    TmpDir.with_repo_path(overapp_path) do |dir|
      b[dir]
    end
  else
    yield overapp_path
  end
end

.write_project(overapp_path, output_path) ⇒ Object



3
4
5
6
7
# File 'lib/overapp/util/write.rb', line 3

def write_project(overapp_path,output_path)
  Overapp.with_local_path(overapp_path) do |dir|
    Overapp::Project.new(:path => dir).write_to!(output_path)
  end
end