Class: Jax::Generators::App::AppGenerator

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/jax/generators/app/app_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



12
13
14
# File 'lib/jax/generators/app/app_generator.rb', line 12

def self.source_root
  File.expand_path("templates", File.dirname(__FILE__))
end

Instance Method Details

#appObject



21
22
23
# File 'lib/jax/generators/app/app_generator.rb', line 21

def app
  directory 'app'
end

#configObject



25
26
27
# File 'lib/jax/generators/app/app_generator.rb', line 25

def config
  directory 'config'
end

#create_rootObject



16
17
18
19
# File 'lib/jax/generators/app/app_generator.rb', line 16

def create_root
  self.destination_root = File.expand_path(path_to_app, destination_root)
  empty_directory '.'
end

#doneObject



72
73
74
75
# File 'lib/jax/generators/app/app_generator.rb', line 72

def done
  # to clarify that everything is fine, just in case the user got warnings about git
  say_status :complete, "Done!", :green
end

#gemfileObject



49
50
51
52
53
54
55
# File 'lib/jax/generators/app/app_generator.rb', line 49

def gemfile
  if ENV['gemdev']
    create_file "Gemfile", "gem 'jax', :path => '../'"
  else
    template 'Gemfile.tt', 'Gemfile'
  end
end

#gitObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/jax/generators/app/app_generator.rb', line 57

def git
  void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
  if system "git --version >>#{void} 2>&1"
    if File.exist? '.git'
      say_status :exist, 'git', :blue
    else
      `git init`
      `git add *`
      say_status :init, 'git', :green
    end
  else
    say_status :warn, "Git does not seem to be installed. Skipping...", :yellow
  end
end

#publicObject



29
30
31
# File 'lib/jax/generators/app/app_generator.rb', line 29

def public
  directory 'public'
end

#rakefileObject



37
38
39
# File 'lib/jax/generators/app/app_generator.rb', line 37

def rakefile
  copy_file 'Rakefile'
end

#script_jaxObject



41
42
43
# File 'lib/jax/generators/app/app_generator.rb', line 41

def script_jax
  copy_file "script/jax", "script/jax"
end

#script_permissionsObject



45
46
47
# File 'lib/jax/generators/app/app_generator.rb', line 45

def script_permissions
  chmod("script/jax", 0755)
end

#specObject



33
34
35
# File 'lib/jax/generators/app/app_generator.rb', line 33

def spec
  directory 'spec'
end