Sha256: 357d0c1bbc5513e6e8c7a6a9c20f524026f6747af060e1006543e5f0daceea84

Contents?: true

Size: 894 Bytes

Versions: 2

Compression:

Stored size: 894 Bytes

Contents

require_relative 'frenchpress/blog'

# The FrenchPress class houses some conveience methods for accessing a Blog
# object, as well as misc properties (such as self.version) and settings
# manipulation (such as self.default=)
class FrenchPress
 
  @working = nil

  def self.open(dir)
    default_file = File.join Dir.home, '.frenchpress_dir'
    dir ||= File.open(default_file).read.to_s if File.exist?(default_file)
    dir ||= Dir.getwd
    dir = File.expand_path(dir)
    FrenchPress.working = FrenchPress::Blog.new dir # sets a class inst var
    FrenchPress.working
  end

  def self.version
    '0.1.0'
  end

  def self.default=(default_dir)
    Dir.chdir(Dir.home) do
      File.open('.frenchpress_dir', 'w+') do |f|
        f.truncate 0
        f.write default_dir
      end
    end
  end

  def self.working
    @working
  end

  def self.working=(blag)
    @working = blag
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
frenchpress-0.2.1 lib/frenchpress.rb
frenchpress-0.2 lib/frenchpress.rb