woody 0.0.17 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/woody CHANGED
@@ -12,9 +12,10 @@ default_command :compile
12
12
 
13
13
  command :compile do |c|
14
14
  c.description = "Compiles the site"
15
+ c.option "--no-add", "Don't ask to add new metadata"
15
16
  c.action do |args, options|
16
17
  Woody.init
17
- Woody::Compiler.compile
18
+ Woody::Compiler.compile(options)
18
19
  end
19
20
  end
20
21
  alias_command :c, :compile
@@ -30,9 +31,10 @@ alias_command :d, :deploy
30
31
 
31
32
  command :cd do |c|
32
33
  c.description = "Compiles then deploys the site"
34
+ c.option "--no-add", "Don't ask to add new metadata"
33
35
  c.action do |args, options|
34
36
  Woody.init
35
- Woody::Compiler.compile
37
+ Woody::Compiler.compile(options)
36
38
  Woody::Deployer.deploy
37
39
  end
38
40
  end
@@ -3,7 +3,7 @@ module Woody
3
3
  module Compiler
4
4
 
5
5
  # Compiles the Woody site
6
- def self.compile()
6
+ def self.compile(options = [])
7
7
  puts "Compiling..."
8
8
  meta = YAML.load_file("content/metadata.yml")
9
9
 
@@ -18,8 +18,11 @@ module Woody
18
18
  filesfound << filename
19
19
  else
20
20
  # No episode metadata stored for this yet
21
-
22
- puts "Warning: no metadata found for file #{filename}"
21
+ unless options.no_add == false # Seemingly backwards, I know...
22
+ prompt_metadata(meta, episodes, filesfound, filename)
23
+ else
24
+ puts "Warning: found media file #{filename} but no metadata. Will not be published."
25
+ end
23
26
  end
24
27
  end
25
28
 
@@ -99,6 +102,33 @@ module Woody
99
102
 
100
103
  private
101
104
 
105
+ def self.prompt_metadata(meta, episodes, filesfound, filename)
106
+ puts "Found new media file: #{filename}"
107
+ if agree("Add metadata for this file? ")
108
+ m = Hash.new
109
+ m['date'] = Time.now
110
+ m['title'] = ask "Title: "
111
+ m['subtitle'] = ask "Subtitle: "
112
+ m['synopsis'] = ask "Synopsis:"
113
+ m['tags'] = ask "Tags: ", Array
114
+
115
+ meta[filename] = m
116
+ episodes << Episode.new(filename, m['title'], Date.parse(m['date'].to_s), m['synopsis'], m['subtitle'], m['tags'])
117
+ filesfound << filename
118
+
119
+ write_meta meta
120
+ puts "Saved."
121
+ end
122
+ puts # Leave a blank line
123
+ end
124
+
125
+ # Writes the metadata file
126
+ def self.write_meta(meta)
127
+ File.open( 'content/metadata.yml', 'w' ) do |out|
128
+ YAML.dump meta, out
129
+ end
130
+ end
131
+
102
132
  # Copies custom assets to output recursively
103
133
  def self.copy_assets_r(touchedfiles, subdir="")
104
134
  Dir.foreach("templates/assets/#{subdir}") do |item|
data/lib/woody/episode.rb CHANGED
@@ -6,7 +6,7 @@ module Woody
6
6
  # @param [Hash] meta is the relevant part of metadata.yml
7
7
  # @return [Episode] the new Episode object
8
8
  def self.new_from_meta(filename, meta)
9
- return Episode.new(filename, meta['title'], Date.parse(meta['date']), meta['synopsis'], meta['subtitle'], meta['tags'])
9
+ return Episode.new(filename, meta['title'], Date.parse(meta['date'].to_s), meta['synopsis'], meta['subtitle'], meta['tags'])
10
10
  end
11
11
 
12
12
  # Creates a new Episode object
data/lib/woody/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Woody
2
2
  # Specifies Woody gem version
3
- VERSION = "0.0.17"
3
+ VERSION = "0.1.0"
4
4
  end
data/lib/woody.rb CHANGED
@@ -10,6 +10,9 @@ require 'aws/s3'
10
10
  require 'digest'
11
11
  require 'fileutils'
12
12
  require 'uri'
13
+ require 'date'
14
+ require 'time'
15
+ require 'highline/import'
13
16
 
14
17
  oldverbosity = $VERBOSE; $VERBOSE = nil # Silence depreciation notice
15
18
  require 'mp3info'
data/woody.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_runtime_dependency 'mp3info'
22
22
  gem.add_runtime_dependency 'aws-s3'
23
23
  gem.add_runtime_dependency 'commander'
24
-
25
- # gem.post_install_message = "This update modifies default templates. Please run `woody update_templates` in your site directory to update them. Warning: this will destroy any modifications to your templates."
24
+ gem.add_runtime_dependency 'highline'
25
+
26
+ # gem.post_install_message = "This update modifies default templates. Please run `woody update templates` in your site directory to update them. Warning: this will destroy any modifications to your templates."
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woody
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
12
+ date: 2012-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: highline
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  description: Woody
79
95
  email:
80
96
  - david@davidr.me