Module: Aina

Defined in:
lib/aina.rb,
lib/aina/globals.rb,
lib/aina/version.rb

Constant Summary collapse

TEMPLATES_DIR =
File.expand_path('../../..',__FILE__) + '/templates'
VERSION =
'0.4.0'

Class Method Summary collapse

Class Method Details

.aina_versionObject



10
11
12
# File 'lib/aina.rb', line 10

def self.aina_version
  Aina::VERSION
end

.install(output = false) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/aina.rb', line 14

def self.install(output = false)
  unless Dir.exists?(Dir.pwd + '/inc')
    Dir.mkdir(Dir.pwd + '/inc')
  end

  # Install Aina
  unless self.is_installed?
    text = File.read(Aina::TEMPLATES_DIR + '/aina_framework.php')

    ['{{aina_version}}'].each do |replace|
      attribute = replace.gsub(/[{}]/, '')
      @output = text.gsub!(/#{replace}/, self.send(attribute))
    end

    File.open(Dir.pwd + "/inc/aina.php", "w") {|file| file.puts @output}

    message = "Aina has been installed in your WordPress theme.\n"
    message += "\n\nIf you want your post type to be automatically included, put this is functions.php:\n"
    message += "function aina_post_types() {\n"
    message += " return array('your_post_type', 'another_post_type', 'etc');\n"
    message += "}\n"
  else
    message = "Aina was already installed in your WordPress theme ;-)\n"
  end

  # Include Aina
  unless functions_php_exists?
    create_empty_functions_php
  end
  File.open(functions_php, "a+") {|file| file.puts aina_inclusion}

  if output
    puts message
  end
end

.is_installed?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/aina.rb', line 50

def self.is_installed?
  File.exists?(Dir.pwd + "/inc/aina.php")
end