Class: Archangel::Commands::ExtensionCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/archangel/commands/extension_command.rb

Overview

Generate Archangel extension

Instance Method Summary collapse

Instance Method Details

Banner

Say something nice



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/archangel/commands/extension_command.rb', line 96

def banner
  say %(

  ******************************************************************

    Your extension has been generated with a gemspec dependency on
    Archangel ~> v#{archangel_version}

I have a feeling you're about to build something amazing.

  ******************************************************************

  )
end

#copy_common_directoriesObject

Copy common directories that are shared with theme generator



52
53
54
55
56
57
58
59
60
# File 'lib/archangel/commands/extension_command.rb', line 52

def copy_common_directories
  %w[
    bin lib spec
  ].each do |dir|
    directory("../common/#{dir}", "#{extension_name}/#{dir}")
  end

  chmod("#{extension_name}/bin/rails", 0o755)
end

#copy_common_templatesObject

Copy common templates that are shared with theme generator



74
75
76
77
78
79
80
# File 'lib/archangel/commands/extension_command.rb', line 74

def copy_common_templates
  %w[
    .gitignore .rspec Gemfile MIT-LICENSE Rakefile
  ].each do |tpl|
    template("../common/#{tpl}", "#{extension_name}/#{tpl}")
  end
end

#copy_plugin_directoriesObject

Copy extension directories and chmod bin scripts



65
66
67
68
69
# File 'lib/archangel/commands/extension_command.rb', line 65

def copy_plugin_directories
  %w[
    config lib
  ].each { |dir| directory(dir, "#{extension_name}/#{dir}") }
end

#copy_plugin_templatesObject

Copy extension templates



85
86
87
88
89
# File 'lib/archangel/commands/extension_command.rb', line 85

def copy_plugin_templates
  %w[
    README.md
  ].each { |tpl| template(tpl, "#{extension_name}/#{tpl}") }
end

#create_plugin_directoryObject

Create extension directory



37
38
39
# File 'lib/archangel/commands/extension_command.rb', line 37

def create_plugin_directory
  empty_directory(extension_name)
end

#create_plugin_gemspecObject

Create extension .gemspec file



44
45
46
47
# File 'lib/archangel/commands/extension_command.rb', line 44

def create_plugin_gemspec
  template("extension.gemspec",
           "#{extension_name}/#{extension_name}.gemspec")
end

#generateObject

Generate extension

Usage

archangel extension [EXTENSION_NAME]
bundle exec bin/archangel extension [EXTENSION_NAME]


30
31
32
# File 'lib/archangel/commands/extension_command.rb', line 30

def generate
  name_plugin
end