Module: CassetteRack::Cli

Defined in:
lib/cassette-rack/cli.rb

Class Method Summary collapse

Class Method Details

.draw(dest_path) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cassette-rack/cli.rb', line 4

def draw(dest_path)
  tree = CassetteRack::Tree.create(CassetteRack::Configure.source_path)
  tree.each do |entry|
    if entry.leaf?
      drawer = CassetteRack::Drawer.new(entry.id)
      if drawer.exist?
        path = File.join(dest_path, entry.id)
        File.open(path + '.md', 'w') do |file|
          file.puts drawer.pull
        end
      end
    else
      path = File.join(dest_path, entry.id)
      FileUtils.mkdir_p(path)
    end
  end
end