Module: Snip

Included in:
Command::Add, Command::Edit
Defined in:
lib/snip.rb,
lib/snip_version.rb,
lib/snip/commands.rb,
lib/snip/command/add.rb,
lib/snip/command/run.rb,
lib/snip/util/editor.rb,
lib/snip/command/edit.rb,
lib/snip/command/list.rb,
lib/snip/command/show.rb,
lib/snip/command/remove.rb

Defined Under Namespace

Modules: Command, Commands, Util Classes: DuplicateSnippetNameError, ExecuteSnippetError, NotInitializedError, SnippetNotFoundError

Constant Summary collapse

DEFAULT_DIR =
'~/.snip'
INSTALL_DIR =
File.expand_path(Snip::DEFAULT_DIR)
VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.initObject



17
18
19
20
21
# File 'lib/snip.rb', line 17

def self.init
  unless Snip::initialized?
    FileUtils.mkdir(Snip::INSTALL_DIR)
  end
end

.initialized?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/snip.rb', line 13

def self.initialized?
  File.directory?(Snip::INSTALL_DIR)
end

.snippet_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/snip.rb', line 23

def self.snippet_exists?(name)
  File.exists?(File.join(Snip::INSTALL_DIR, name))
end