Class: SkadateGems::Dev::CLI::Skadate

Inherits:
Thor
  • Object
show all
Defined in:
lib/skadategems/dev/cli/skadate.rb

Instance Method Summary collapse

Instance Method Details

#export(filename = nil) ⇒ Object



151
152
153
154
155
156
157
158
159
# File 'lib/skadategems/dev/cli/skadate.rb', line 151

def export(filename = nil)
  version = current.source.version!

  filename ||= "./skadate-#{version}-#{Time.now.to_i}.tar.gz"

  bundle = Bundle.new(current)
  bundle.layout_theme = options[:layout_theme] if options[:layout_theme]
  bundle.gzip(filename)
end

#initObject



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/skadategems/dev/cli/skadate.rb', line 103

def init
  source = current.source

  dev_dir = source.filename('.dev')
  FileUtils.mkdir(dev_dir) unless File.exists?(dev_dir)

  htaccess_file_path = source.filename('.dev/.htaccess')
  unless File.exists?(htaccess_file_path)
    File.write(htaccess_file_path, <<-HTACCESS)
Order Deny,Allow
Deny from all
    HTACCESS
  end

  if options[:remote_url]
    execphp = ExecPHP::ServerSideAccessor.new

    rs_config = ExecPHP::RemoteServer.new(
      URI.join(options[:remote_url], 'exec.php').to_s,
      execphp.access_token
    )

    rs_config.save_as source.filename('.dev/remote-server.json')
    execphp.generate source.filename('exec.php')
  end
end

#version(section = 'about') ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/skadategems/dev/cli/skadate.rb', line 29

def version(section = 'about')
  section =
    case section[0]
      when 'l'
        :list
      when 'a'
        :about
      when 'n'
        :number
      when 'b'
        :build
      else
        say "Error: `skadate version` unrecognized info section `#{section}`", :red
        return help('version')
    end

  if section == :list
    current_version = current.source.version

    SoftwareVersion::LIST.each do |version|
      if version == current_version
        say('* ', version_status(current_version)[0], false)
      else
        say '  ', nil, false
      end

      say "skadate-#{version} [#{version.release_date.strftime('%Y-%m-%d')}]"
    end

    return
  end

  version = current.source.version!
  color, status = version_status(version)

  case section
    when :about
      say 'Skadate Software '
      say("#{version} ", :bold)

      if version.codename
        say('(', :white, false)
        say("#{version.codename}", :cyan, false)
        say ') '
      end

      say('[', :white, false)
      say(status, color, false)
      say ']'

      if version.release_date
        say "Release date: #{version.release_date.strftime('%B %e, %Y')}"
      end

      say 'Copyright (c) 2004-2014 Skalfa LLC'

    when :number
      say(version, color)

    when :build
      say(version.build, color)

    else
      raise "unexpected case :#{section}"
  end
end