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


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

def banner
  puts %(

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

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

#{random_compliment}

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

  )
end

#copy_common_directoriesObject

Copy common directories that are shared with theme generator


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

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

#copy_common_templatesObject

Copy common templates that are shared with theme generator


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

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

#copy_plugin_directoriesObject

Copy extension directories and chmod bin scripts


61
62
63
64
65
66
67
# File 'lib/archangel/commands/extension_command.rb', line 61

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

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

#copy_plugin_templatesObject

Copy extension templates


83
84
85
86
87
# File 'lib/archangel/commands/extension_command.rb', line 83

def copy_plugin_templates
  %w[
    Gemfile Rakefile 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