snackpack 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ class SnackLog
2
+ def initialize(stomach)
3
+ @stomach = stomach
4
+ @temp_menu = Tempfile.new('temp_menu')
5
+ @snack_log = @stomach+'snack_log.html'
6
+ end
7
+
8
+ def build
9
+ Dir[@stomach+'*'].each do |folder|
10
+ menu = fetch_menu(folder)
11
+ write_log(menu)
12
+ end
13
+ FileUtils.mv(@temp_menu.path, @snack_log)
14
+ end
15
+
16
+ private
17
+ def fetch_menu(folder)
18
+ Dir[folder+'/*.html']
19
+ end
20
+
21
+ def write_log(menu)
22
+ File.open(@temp_menu, 'a') do |f|
23
+ menu_title = get_title(menu.first) if menu.first
24
+ f.puts "<p><a href='#{menu.first}'>#{menu_title}</a></p>"
25
+ end
26
+ end
27
+
28
+ def get_title(menu)
29
+ title = menu.match(/[-]\d+.+[html]$/).to_s
30
+ title.gsub!(/\d/, '')
31
+ title.gsub!(/-/, ' ')
32
+ title.gsub!(/\//, '')
33
+ title.gsub!(/\./, '')
34
+ title.gsub!(/html/, '')
35
+ end
36
+ end
data/lib/snackpack.rb CHANGED
@@ -5,6 +5,7 @@ require 'fileutils'
5
5
 
6
6
  require_relative 'snackpack/gobble.rb'
7
7
  require_relative 'snackpack/condiments.rb'
8
+ require_relative 'snackpack/snack_log.rb'
8
9
 
9
10
  class Snackpack
10
11
 
@@ -20,7 +21,7 @@ class Snackpack
20
21
  def enter_avdis_kitchen
21
22
  open_fridge
22
23
  unwrap_snacks(get_snackpacks)
23
- #TODO build_the_menu (build index linking to all episodes)
24
+ SnackLog.new(@config[:stomach]).build
24
25
  end
25
26
 
26
27
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snackpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - lib/snackpack/gobble.rb
23
+ - lib/snackpack/snack_log.rb
23
24
  - lib/snackpack/condiments.rb
24
25
  - lib/snackpack.rb
25
26
  - bin/snackpack