Module: Sake::Store
- Extended by:
- Store
- Included in:
- Store
- Defined in:
- lib/sake.rb
Overview
The store is, as of writing, a single Rakefile: ~/.sake When we add new tasks, we just re-build this file. Over and over.
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
Everything we can’t catch gets sent to our tasks_file. Common examples are #tasks or #add_task.
454
455
456
|
# File 'lib/sake.rb', line 454
def method_missing(*args, &block)
tasks_file.send(*args, &block)
end
|
Instance Method Details
#path ⇒ Object
462
463
464
465
466
467
468
469
470
|
# File 'lib/sake.rb', line 462
def path
path = if PLATFORM =~ /win32/
win32_path
else
File.join(File.expand_path('~'), '.sake')
end
FileUtils.touch(path) unless path.is_file?
path
end
|
#save! ⇒ Object
481
482
483
484
485
|
# File 'lib/sake.rb', line 481
def save!
File.open(path, 'w') do |file|
file.puts tasks_file.to_ruby
end
end
|
#tasks_file ⇒ Object
458
459
460
|
# File 'lib/sake.rb', line 458
def tasks_file
@tasks_file ||= TasksFile.parse(path)
end
|
#win32_path ⇒ Object
472
473
474
475
476
477
478
479
|
# File 'lib/sake.rb', line 472
def win32_path
unless File.exists?(win32home = ENV['HOMEDRIVE'] + ENV['HOMEPATH'])
puts "# No HOMEDRIVE or HOMEPATH environment variable.",
"# Sake needs to know where it should save Rake tasks!"
else
File.join(win32home, 'Sakefile')
end
end
|