Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An octolicious wrapper around Github's gitignore template API.
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.coveralls.yml
.gitignore
.rspec
.travis.yml
CHANGELOG.md
Gemfile
Gemfile.lock
LICENSE
README.md
Rakefile
octonore.gemspec

README.md

Octonore Build Status Code Climate Coverage Status Dependency Status

An octolicious wrapper around the Gitignore Templates API.

$ gem install octonore

Usage

List the available templates by calling Template's list method.

>> Octonore::Template.list
=> ["Actionscript", "Android", "AppceleratorTitanium", "Autotools", "Bancha", "
C", "C++", "CFWheels", "CMake", "CSharp", "CakePHP", "Clojure", "CodeIgniter...

To get a gitignore template you first need to instantiate it.

>> c_template = Octonore::Template.new('C')
=> #<Octonore::Template:0x007fe65b8b2420 @name="C", @source="# Object files\n*.
o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.
so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n">

To get the template's source code, you can call its source accessor.

>> c_template.source
=> "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Wi
ndows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app
\n"

You can also get the template's name with the name accessor.

>> c_template.name
=> "C"

You can reload the template's source from Github with the update method.

>> c_template.update
=> "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Wi
ndows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app
\n"

Example Program

The following program asks the user for the name of a gitignore template. It then writes the gitignore to a file ending in .gitignore. If the user enters Java, then it will write the Java gitignore template to java.gitignore in the current directory.

require 'octonore'

begin
  print "Enter the name of a gitignore template (case sensitive): "
  template = Octonore::Template.new(gets.strip)

  File.open("#{template.name.downcase}.gitignore", 'w') { |file|
          file.write(template.source) }
rescue GitignoreTemplateNotFoundError => e
  puts e.message
end
Something went wrong with that request. Please try again.