Class: Embryo::Filesystem
- Inherits:
-
Object
- Object
- Embryo::Filesystem
- Defined in:
- lib/embryo/filesystem.rb
Instance Method Summary collapse
- #application_human_name ⇒ Object
- #application_name ⇒ Object
- #commit_changes ⇒ Object
- #delete(path) ⇒ Object
- #gemfile ⇒ Object
-
#initialize(generator, *write_options) ⇒ Filesystem
constructor
A new instance of Filesystem.
- #require_gem(*args) ⇒ Object
- #sorted_cache ⇒ Object
- #write(path, data) ⇒ Object
Constructor Details
#initialize(generator, *write_options) ⇒ Filesystem
Returns a new instance of Filesystem.
7 8 9 10 11 12 |
# File 'lib/embryo/filesystem.rb', line 7 def initialize(generator, *) @generator = generator = @write_cache = {} @gemfile = nil end |
Instance Method Details
#application_human_name ⇒ Object
49 50 51 |
# File 'lib/embryo/filesystem.rb', line 49 def application_human_name application_name.titleize end |
#application_name ⇒ Object
45 46 47 |
# File 'lib/embryo/filesystem.rb', line 45 def application_name File.basename Dir.getwd end |
#commit_changes ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/embryo/filesystem.rb', line 14 def commit_changes @gemfile.write(*) if @gemfile sorted_cache.each do |path, data| if data @generator.create_file path, data, * else @generator.remove_file path, * if File.exist? path end end end |
#delete(path) ⇒ Object
41 42 43 |
# File 'lib/embryo/filesystem.rb', line 41 def delete(path) @write_cache[path] = nil end |
#gemfile ⇒ Object
33 34 35 |
# File 'lib/embryo/filesystem.rb', line 33 def gemfile @gemfile ||= Gemfile.current generator: @generator end |
#require_gem(*args) ⇒ Object
29 30 31 |
# File 'lib/embryo/filesystem.rb', line 29 def require_gem(*args) gemfile.require_gem(*args) end |
#sorted_cache ⇒ Object
25 26 27 |
# File 'lib/embryo/filesystem.rb', line 25 def sorted_cache @write_cache.sort.to_h end |
#write(path, data) ⇒ Object
37 38 39 |
# File 'lib/embryo/filesystem.rb', line 37 def write(path, data) @write_cache[path] = data end |