Class: Ecogem::Workspace
- Inherits:
-
Object
- Object
- Ecogem::Workspace
- Defined in:
- lib/ecogem/workspace.rb
Instance Method Summary collapse
- #env ⇒ Object
- #gemfile ⇒ Object
- #gitsfile ⇒ Object
- #global_env ⇒ Object
-
#initialize(args, options = {}, &block) ⇒ Workspace
constructor
A new instance of Workspace.
- #new_tmpdir(&block) ⇒ Object
Constructor Details
#initialize(args, options = {}, &block) ⇒ Workspace
Returns a new instance of Workspace.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ecogem/workspace.rb', line 7 def initialize(args, = {}, &block) @args = args || ::Ecogem::Cli::Args.new([]) = {}.merge() new_tmpdir do |dir| begin @workdir = dir block.call self unless [:readonly] gitsfile.save end end end end |
Instance Method Details
#env ⇒ Object
25 26 27 |
# File 'lib/ecogem/workspace.rb', line 25 def env @env ||= ::Ecogem::Env.new(global_env, env_path) end |
#gemfile ⇒ Object
46 47 48 |
# File 'lib/ecogem/workspace.rb', line 46 def gemfile @gemfile ||= ::Ecogem::Gemfile.new(gemfile_path) end |
#gitsfile ⇒ Object
29 30 31 |
# File 'lib/ecogem/workspace.rb', line 29 def gitsfile @gitsfile ||= ::Ecogem::Gitsfile.new(nil, global_env.dir + '/gits/keys') end |
#global_env ⇒ Object
21 22 23 |
# File 'lib/ecogem/workspace.rb', line 21 def global_env @global_env ||= ::Ecogem::Env.new(nil, ::File.(::Dir.home + '/.ecogem')) end |
#new_tmpdir(&block) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/ecogem/workspace.rb', line 58 def new_tmpdir(&block) ::FileUtils.mkdir_p tmp_path unless ::File.exist?(tmp_path) ::Dir.mktmpdir(nil, tmp_path) do |dir| return block.call(dir) end end |