Class: Fanforce::CLI::App

Inherits:
Object
  • Object
show all
Defined in:
lib/fanforce/cli/app.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ App

Returns a new instance of App.



13
14
15
16
17
18
19
20
# File 'lib/fanforce/cli/app.rb', line 13

def initialize(dir)
  raise "This is an invalid directory name for a fanforce addon: #{dir}" if dir !~ /^(.*)\/(app-([a-z0-9-]+))\/?$/
  @_id         = $3
  @dir         = "#{$1}/#{$2}"
  @dir_root    = $1
  @dir_name    = $2
  @root_domain = Fanforce.apps_base_domain
end

Instance Attribute Details

#_idObject (readonly)

Returns the value of attribute _id.



2
3
4
# File 'lib/fanforce/cli/app.rb', line 2

def _id
  @_id
end

#dirObject (readonly)

Returns the value of attribute dir.



2
3
4
# File 'lib/fanforce/cli/app.rb', line 2

def dir
  @dir
end

#dir_nameObject (readonly)

Returns the value of attribute dir_name.



2
3
4
# File 'lib/fanforce/cli/app.rb', line 2

def dir_name
  @dir_name
end

#dir_rootObject (readonly)

Returns the value of attribute dir_root.



2
3
4
# File 'lib/fanforce/cli/app.rb', line 2

def dir_root
  @dir_root
end

#root_domainObject (readonly)

Returns the value of attribute root_domain.



2
3
4
# File 'lib/fanforce/cli/app.rb', line 2

def root_domain
  @root_domain
end

Class Method Details

.load(dir) ⇒ Object



9
10
11
# File 'lib/fanforce/cli/app.rb', line 9

def self.load(dir)
  self.new(dir)
end

.parse_dir_name(dir_name) ⇒ Object



4
5
6
7
# File 'lib/fanforce/cli/app.rb', line 4

def self.parse_dir_name(dir_name)
  return if dir_name !~ /^(app-([a-z0-9-]+))\/?$/
  {_id: $2, dir_name: $1}
end

Instance Method Details

#create_files(*filenames) ⇒ Object Also known as: create_file



22
23
24
25
26
# File 'lib/fanforce/cli/app.rb', line 22

def create_files(*filenames)
  filenames.each do |filename|
    Fanforce::CLI::Files.method(:"create_#{filename}").call(self)
  end
end

#end_printObject



53
54
55
# File 'lib/fanforce/cli/app.rb', line 53

def end_print
  puts 'DONE'
end

#start_printObject



49
50
51
# File 'lib/fanforce/cli/app.rb', line 49

def start_print
  print "- #{@dir_name}... "
end

#to_hashObject



36
37
38
39
40
41
42
43
# File 'lib/fanforce/cli/app.rb', line 36

def to_hash
  {
      _id: @_id,
      dir_name: @dir_name,
      dir_root: @dir_root,
      dir: @dir,
  }
end

#to_jsonObject



45
46
47
# File 'lib/fanforce/cli/app.rb', line 45

def to_json
  to_hash.to_json
end

#update_files(*filenames) ⇒ Object Also known as: update_file



29
30
31
32
33
# File 'lib/fanforce/cli/app.rb', line 29

def update_files(*filenames)
  filenames.each do |filename|
    Fanforce::CLI::Files.method(:"update_#{filename}").call(self)
  end
end