Sha256: df598681ebd2da02c78948387f2be881e6a055bf7ed872308a31a84a985ebf68

Contents?: true

Size: 1019 Bytes

Versions: 22

Compression:

Stored size: 1019 Bytes

Contents

module Bourdain
  module Generators

    class AttributeGenerator < Generator
      usage :generator, <<-END
        Generate a new attribute file in the current cookbook
        attribute [<options>] <name>
      END


      def initialize argv
        super

        name = argv.shift
        Trollop::die 'No <name> provided' if name.nil?
        Trollop::die 'Invalid <name> provided' unless valid? name
        name = normalized(name)

        return unless require_cookbook!

        FileUtils.mkdir_p 'attributes'
        path = File.join('attributes', name + '.rb')

        if File::exists? path
          log.warn "Attribute file already exists. Doing nothing."
          return
        end

        cookbook_name = File.basename Dir.pwd

        apply_template path, \
          template: %w[ cookbook attributes example.rb ],
          locals: {
            cookbook_name: cookbook_name,
            name: name
          }

        log.info "Generated attribute file at #{path}"
      end
    end

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
bourdain-1.6.3 lib/bourdain/resources/generators/attribute.rb
bourdain-1.6.2 lib/bourdain/resources/generators/attribute.rb
bourdain-1.6.1 lib/bourdain/resources/generators/attribute.rb
bourdain-1.6.0 lib/bourdain/resources/generators/attribute.rb
bourdain-1.5.1 lib/bourdain/resources/generators/attribute.rb
bourdain-1.5.0 lib/bourdain/resources/generators/attribute.rb
bourdain-1.4.1 lib/bourdain/resources/generators/attribute.rb
bourdain-1.4.0 lib/bourdain/resources/generators/attribute.rb
bourdain-1.3.3 lib/bourdain/resources/generators/attribute.rb
bourdain-1.3.2 lib/bourdain/resources/generators/attribute.rb
bourdain-1.3.1 lib/bourdain/resources/generators/attribute.rb
bourdain-1.3.0 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.22 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.21 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.20 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.19 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.18 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.17 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.16 lib/bourdain/resources/generators/attribute.rb
bourdain-1.2.15 lib/bourdain/resources/generators/attribute.rb