Sha256: 5000f0435abfa108dcf1d3af6210751f07c1162114050dbb935958625708dda2

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require 'optparse'
require File.expand_path('../command/template.rb', File.readlink(__FILE__))

module Motion
  module Project
    class GemCommand < Command
      self.name = 'gem'
      self.help = 'Create a new RubyMotion gem'

      @@description = <<-DESCRIPTION
    Creates a skeleton RubyMotion Gem.
      DESCRIPTION

      @@example     = <<-EXAMPLE
    `motion gem GEM`

    This creates the following directory structure:
        GEM/
        ├── .gitignore
        ├── Gemfile
        ├── LICENSE.md
        ├── README.md
        ├── Rakefile
        ├── lib/
        │   ├── GEM/
        │   │   ├── version.rb
        │   └── GEM.rb
        └── GEM.gemspec
      EXAMPLE

      def run(args)
        option_parser = OptionParser.new do |opt|
          opt.banner = 'Usage:'
          opt.separator '    motion gem <gem-name>'
          opt.separator ''
          opt.separator 'Options:'
          opt.on('-h', '--help', 'Shows this screen')
          opt.separator ''
          opt.separator 'Description:'
          opt.separator @@description
          opt.separator ''
          opt.separator 'Example:'
          opt.separator @@example
        end

        option_parser.parse!
        if args.count > 1
          puts option_parser
          exit 1
        elsif args.count == 0
          puts option_parser
          exit
        end

        gem_name = args.first
        Motion::Gem::Command::Template.scaffold_gem(gem_name)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
motion-gem-0.1.0 lib/motion/gem/gem_command.rb