Class: Gemmy::Tasks::MakeGem

Inherits:
Object
  • Object
show all
Defined in:
lib/gemmy/patches_loaded/tasks/make_gem.rb

Overview

A task to create skeleton structure for a ruby gem

Only one method is intended for public use, MakeGem.run.

It takes one argument - the name of the ruby gem.

It then prompts for a few more defails (summary, email, and name).

Here’s the structure it creates:

├── <name>.gemspec ├── Gemfile ├── reinstall ├── bin

└── <name>

└── lib

├── <name>.rb
└── version.rb

At which point you can run “gem build” then “gem install”

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def author
  @author
end

#class_nameObject (readonly)

Returns the value of attribute class_name.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def class_name
  @class_name
end

#emailObject (readonly)

Returns the value of attribute email.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def email
  @email
end

#gemfileObject (readonly)

Returns the value of attribute gemfile.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def gemfile
  @gemfile
end

#gemspec_fileObject (readonly)

Returns the value of attribute gemspec_file.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def gemspec_file
  @gemspec_file
end

#libObject (readonly)

Returns the value of attribute lib.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def lib
  @lib
end

#main_fileObject (readonly)

Returns the value of attribute main_file.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def main_file
  @main_file
end

#nameObject (readonly)

Returns the value of attribute name.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def name
  @name
end

#root_dirObject (readonly)

Returns the value of attribute root_dir.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def root_dir
  @root_dir
end

#rubygems_versionObject (readonly)

Returns the value of attribute rubygems_version.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def rubygems_version
  @rubygems_version
end

#summaryObject (readonly)

Returns the value of attribute summary.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def summary
  @summary
end

#urlObject (readonly)

Returns the value of attribute url.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def url
  @url
end

#version_fileObject (readonly)

Returns the value of attribute version_file.



52
53
54
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 52

def version_file
  @version_file
end

Class Method Details

.run(name) ⇒ Object

Builds a skeleton ruby gem. Prompts for some input using gets.chomp



29
30
31
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 29

def self.run(name)
  new.make_gem(name)
end

Instance Method Details

#make_gem(name) ⇒ Object

calls a sequence of commands to build out the gem directory



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gemmy/patches_loaded/tasks/make_gem.rb', line 35

def make_gem(name)
  @name = name
  @class_name = name.camelcase

  usage_io
  create_root_dir
  create_lib_dir
  create_version_file
  create_main_file
  gemspec_info_io
  create_gemspec_file
  create_gemfile
  create_reinstall_file
  create_executable
  puts "directory #{name} has been created".yellow
end