Module: CovaIO

Included in:
Cova
Defined in:
lib/covaio.rb

Instance Method Summary collapse

Instance Method Details

#_io_app_exists(name) ⇒ Object



64
65
66
# File 'lib/covaio.rb', line 64

def _io_app_exists(name)
  return File.directory?(@dir_cova_apps_home + "/" + name)
end

#_io_clone_repo(repo, dir) ⇒ Object



72
73
74
75
76
77
78
# File 'lib/covaio.rb', line 72

def _io_clone_repo (repo, dir)
  pwd = Dir.pwd
  Dir.chdir(dir)
  _io_exec "git clone #{repo}"
  Dir.chdir(pwd)
  return _io_isdir(dir + "/" + File.basename(repo, ".*"))
end

#_io_cpdir(src, targ) ⇒ Object



102
103
104
105
106
107
108
# File 'lib/covaio.rb', line 102

def _io_cpdir(src, targ)
  if _io_isdir src and not _io_isdir targ, false
    `cp -r #{src} #{targ}`
    return _io_isdir targ
  end
  return false
end

#_io_exec(cmd) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/covaio.rb', line 17

def _io_exec(cmd)
  pipe = IO.popen(cmd)
  puts cmd.blue
  while (line = pipe.gets)
    print line.black   
  end
end

#_io_exec_xctool(cmd = "build", config = "Debug", sdk = "iphonesimulator") ⇒ Object



25
26
27
# File 'lib/covaio.rb', line 25

def _io_exec_xctool(cmd="build", config="Debug", sdk="iphonesimulator")
  _io_exec @dir_xctool_home + "/xctool.sh -workspace cova.xcworkspace -scheme cova -configuration #{config} -sdk #{sdk} #{cmd}"
end

#_io_initObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/covaio.rb', line 3

def _io_init
  @dir_user_home       = File.expand_path("~")
  @dir_cova_home       = File.expand_path("~/.cova")
  @dir_cova_mods_home  = File.expand_path("~/.cocoapods/cova")
  @dir_cocoapods_home  = File.expand_path("~/.cocoapods")
  @dir_xctool_home     = File.expand_path("~/.cova/xctool")
  @dir_xcode_build_home  = File.expand_path("~/Library/Developer/Xcode/DerivedData")
  @dir_cova_apps_home  = File.expand_path("~/.cova/apps")

  @repo_cova         = "git://github.com/dancali/cova.git"
  @repo_cova_mods      = "git://github.com/dancali/cova-mods.git"
  @repo_xctool     = "git://github.com/facebook/xctool.git"
end

#_io_isdir(dir, expected = true) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/covaio.rb', line 34

def _io_isdir(dir,expected=true)
  _log_line (expected ? "Expecting #{dir} to exist" : "Ensuring #{dir} does not exist")
  if File.directory?(dir)
    expected ? _log_line_ok : _log_line_error
      return true
    end        

    if expected
     _log_line_error
  else
    _log_line_ok
  end
    return false
end

#_io_isfile(file, expected = true) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/covaio.rb', line 49

def _io_isfile(file,expected=true)
  _log_line (expected ? "Expecting #{file} to exist" : "Ensuring #{file} does not exist")
  if File.exist?(file)
    expected ? _log_line_ok : _log_line_error
      return true
    end        

    if expected
     _log_line_error
  else
    _log_line_ok
  end
    return false
end

#_io_lndir(src, targ) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/covaio.rb', line 93

def _io_lndir(src, targ)
  if _io_isdir src and not _io_isdir targ, false
    `ln -s #{src} #{targ}`
    return _io_isdir targ
  end

  return false
end

#_io_ls(dir) ⇒ Object



68
69
70
# File 'lib/covaio.rb', line 68

def _io_ls(dir)
  Dir.foreach(dir) {|entry| puts "#{entry}" unless (entry =='.' || entry == '..') }
end

#_io_mkdir(dir) ⇒ Object



110
111
112
113
114
115
# File 'lib/covaio.rb', line 110

def _io_mkdir(dir)
  _log_line "Creating #{dir}"
  `mkdir #{dir}`
  File.directory?(dir) ? _log_line_ok : _log_line_error
  return File.directory?(dir)
end

#_io_pod_add_repo(name, repo) ⇒ Object



29
30
31
32
# File 'lib/covaio.rb', line 29

def _io_pod_add_repo(name, repo)
  _io_exec("pod repo add #{name} #{repo}")
  return _io_isdir(@dir_cocoapods_home + "/" + name)
end

#_io_rmdir(dir) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/covaio.rb', line 80

def _io_rmdir(dir)
  _log_line "Removing #{dir}"
  if File.directory?(dir)
    `rm -rf #{dir}`
     if File.directory?(dir)
       _log_line_error
       return false
    end
  end
  _log_line_ok
  return true
end