Class: AndroidGenerator

Inherits:
RubiGen::Base
  • Object
show all
Defined in:
lib/generators/android/android_generator.rb

Constant Summary collapse

DEFAULT_SHEBANG =
File.join(Config::CONFIG['bindir'],
Config::CONFIG['ruby_install_name'])
DEFAULT_PACKAGE =
"org.zerosum.android"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runtime_args, runtime_options = {}) ⇒ AndroidGenerator

Returns a new instance of AndroidGenerator.



13
14
15
16
17
18
19
20
21
# File 'lib/generators/android/android_generator.rb', line 13

def initialize(runtime_args, runtime_options = {})
  super
  usage if args.empty?

  @destination_root = args.shift
  @app_name     = File.basename(File.expand_path(@destination_root)).underscore.camelize

  extract_options
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



8
9
10
# File 'lib/generators/android/android_generator.rb', line 8

def app_name
  @app_name
end

#authorObject

Returns the value of attribute author.



8
9
10
# File 'lib/generators/android/android_generator.rb', line 8

def author
  @author
end

#packageObject

Returns the value of attribute package.



8
9
10
# File 'lib/generators/android/android_generator.rb', line 8

def package
  @package
end

#sdk_pathObject

Returns the value of attribute sdk_path.



8
9
10
# File 'lib/generators/android/android_generator.rb', line 8

def sdk_path
  @sdk_path
end

#titleObject

Returns the value of attribute title.



8
9
10
# File 'lib/generators/android/android_generator.rb', line 8

def title
  @title
end

Instance Method Details

#manifestObject



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
49
50
51
52
53
54
# File 'lib/generators/android/android_generator.rb', line 23

def manifest
  record do |m|
    m.directory ""
    BASEDIRS.each { |dir| m.directory dir }

    m.directory "src/#{package.gsub('.', '/')}"
    m.template  "application.mirah",          "src/#{package.gsub('.', '/')}/#{app_name}.mirah"

    m.template  "AndroidManifest.xml",        "AndroidManifest.xml"
    m.template  "build.xml",                  "build.xml"

    m.template  "README.md",                  "README.md"

    m.template  "build.properties",           "build.properties"
    m.template  "default.properties",         "default.properties"
    m.template  "local.properties",           "local.properties"

    m.directory "res/layout"
    m.directory "res/values"
    m.template  "res/layout/main.xml",        "res/layout/main.xml"
    m.template  "res/values/strings.xml",     "res/values/strings.xml"

    m.directory "res/drawable-hdpi"
    m.template  "res/drawable-hdpi/icon.png", "res/drawable-hdpi/icon.png"
    m.directory "res/drawable-ldpi"
    m.template  "res/drawable-ldpi/icon.png", "res/drawable-ldpi/icon.png"
    m.directory "res/drawable-mdpi"
    m.template  "res/drawable-mdpi/icon.png", "res/drawable-mdpi/icon.png"
    
    # TODO: add tests, yo
  end
end