Sha256: 52c3df8aa04f57ca9c6834435a28a54893db3e56974abd288caf0c65c40d8d50

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

class Fanforce::CLI::App
  attr_reader :_id, :dir, :dir_name, :dir_root, :root_domain

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

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

  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

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

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

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

  def to_json
    to_hash.to_json
  end

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

  def end_print
    puts 'DONE'
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fanforce-cli-1.7.1 lib/fanforce/cli/app.rb
fanforce-cli-1.7.0 lib/fanforce/cli/app.rb
fanforce-cli-1.6.0 lib/fanforce/cli/app.rb
fanforce-cli-1.5.0 lib/fanforce/cli/app.rb
fanforce-cli-1.4.0 lib/fanforce/cli/app.rb
fanforce-cli-1.3.0 lib/fanforce/cli/app.rb
fanforce-cli-1.2.0 lib/fanforce/cli/app.rb
fanforce-cli-1.1.0 lib/fanforce/cli/app.rb