Class: SRS::Workspace
- Inherits:
-
Object
- Object
- SRS::Workspace
- Defined in:
- lib/srs/workspace.rb
Defined Under Namespace
Classes: AlreadyInitialisedError, FolderNotEmptyError
Instance Attribute Summary collapse
-
#dotsrs ⇒ Object
readonly
Returns the value of attribute dotsrs.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dirname = ".") ⇒ Workspace
constructor
A new instance of Workspace.
Constructor Details
#initialize(dirname = ".") ⇒ Workspace
Returns a new instance of Workspace.
12 13 14 15 16 17 |
# File 'lib/srs/workspace.rb', line 12 def initialize(dirname=".") if not SRS::Workspace.initialised?(dirname) then return nil end @root = dirname @dotsrs = File.join(dirname,'.srs') self end |
Instance Attribute Details
#dotsrs ⇒ Object (readonly)
Returns the value of attribute dotsrs.
10 11 12 |
# File 'lib/srs/workspace.rb', line 10 def dotsrs @dotsrs end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
10 11 12 |
# File 'lib/srs/workspace.rb', line 10 def root @root end |
Class Method Details
.create(dirname, force = false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/srs/workspace.rb', line 19 def self.create(dirname, force=false) dotsrs_dir = File.join(dirname,'.srs/') if( SRS::Workspace.initialised?(dirname) ) then raise AlreadyInitialisedError return nil end FileUtils.mkdir_p(dirname) if( !force ) then if( Dir.entries(dirname).length > 2 ) then raise FolderNotEmptyError return nil end end Dir.mkdir(dotsrs_dir) Dir.mkdir(File.join(dirname, "data")) return SRS::Workspace.new(dirname) end |
.initialised?(dirname = ".") ⇒ Boolean
42 43 44 |
# File 'lib/srs/workspace.rb', line 42 def self.initialised?(dirname=".") Dir.exists?(File.join(dirname,'.srs/')) end |