gst-kitchen 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ notifications:
5
+ email:
6
+ - alle@geekstammtisch.de
data/Gemfile CHANGED
@@ -1,5 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby "1.9.3"
4
-
5
3
  gemspec
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/tisba/gst-kitchen.png)](https://travis-ci.org/tisba/gst-kitchen)
2
+
1
3
  # Geekstammtisch's Podcast Kitchen (gst-kitchen)
2
4
 
3
5
  Publishing podcats like a nerd!
@@ -11,6 +13,7 @@ The Geekstammtisch website and this gem is inspired by [fanboys-IGOR] [igor].
11
13
  drop me a note!
12
14
 
13
15
 
16
+
14
17
  ## Installation
15
18
 
16
19
  Add this line to your application's Gem file:
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/gst-kitchen.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
- gem.required_ruby_version = '~> 1.9.3'
20
+ gem.required_ruby_version = '>= 1.9.3'
21
21
 
22
22
  gem.add_dependency "yajl-ruby"
23
23
  gem.add_dependency "trollop"
@@ -25,4 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.add_dependency "redcarpet"
26
26
 
27
27
  gem.add_development_dependency "debugger"
28
+ gem.add_development_dependency "rspec"
28
29
  end
@@ -3,50 +3,62 @@ class Episode < Struct.new(:number, :name, :length, :media, :auphonic_uuid, :pub
3
3
 
4
4
  attr_accessor :podcast
5
5
 
6
- def self.from_auphonic(podcast, production)
7
- data = production.meta
8
- /#{podcast.handle}(?<number>\d{3})/ =~ data["data"]["metadata"]["title"]
9
-
10
- metadata = {
11
- auphonic_uuid: data["data"]["uuid"],
12
- number: number.to_i,
13
- length: data["data"]["length"],
14
- name: data["data"]["metadata"]["subtitle"].strip,
15
- summary: data["data"]["metadata"]["summary"].strip,
16
- }
17
-
18
- media = data["data"]["output_files"].each_with_object({}) do |item, obj|
19
- obj[item["format"]] = {
20
- "size" => item["size"],
21
- "file_ext" => item["ending"]
22
- }
6
+ class << self
7
+ def from_auphonic(podcast, production)
8
+ metadata = extract_episode_data_from_auphonic(podcast, production)
9
+
10
+ episode = self.new podcast
11
+ episode.number = metadata[:number]
12
+ episode.name = metadata[:name]
13
+ episode.length = metadata[:length].round
14
+ episode.auphonic_uuid = metadata[:auphonic_uuid]
15
+ episode.published_at = Time.now
16
+ episode.summary = metadata[:summary]
17
+ episode.media = metadata[:media]
18
+ episode.chapters = metadata[:chapters]
19
+
20
+ episode
23
21
  end
24
22
 
25
- episode = self.new podcast
26
-
27
- episode.number = metadata[:number]
28
- episode.name = metadata[:name]
29
- episode.length = metadata[:length].round
30
- episode.auphonic_uuid = metadata[:auphonic_uuid]
31
- episode.published_at = Time.now
32
- episode.summary = metadata[:summary]
33
- episode.media = media
23
+ def from_yaml(podcast, yaml_file)
24
+ episode = YAML.load_file(yaml_file)
25
+ episode.podcast = podcast
26
+ episode
27
+ end
34
28
 
35
- episode.chapters = data["data"]["chapters"].map do |chapter|
36
- Chapter.new(chapter["start"], chapter["title"])
29
+ def extract_episode_number(handle, title)
30
+ title.match(/#{handle}(\d{3})/) { |match| match[1].to_i }
37
31
  end
38
32
 
39
- episode.chapters.sort!
33
+ def extract_episode_data_from_auphonic(podcast, production)
34
+ data = production.meta
40
35
 
41
- episode
42
- end
36
+ metadata = {
37
+ auphonic_uuid: data["data"]["uuid"],
38
+ number: extract_episode_number(podcast.handle, data["data"]["metadata"]["title"]),
39
+ length: data["data"]["length"],
40
+ name: data["data"]["metadata"]["subtitle"].strip,
41
+ summary: data["data"]["metadata"]["summary"].strip,
42
+ }
43
43
 
44
- def self.from_yaml(podcast, yaml_file)
45
- episode = YAML.load_file(yaml_file)
46
- episode.podcast = podcast
47
- episode
44
+ metadata[:media] = data["data"]["output_files"].each_with_object({}) do |item, obj|
45
+ obj[item["format"]] = {
46
+ "size" => item["size"],
47
+ "file_ext" => item["ending"]
48
+ }
49
+ end
50
+
51
+ metadata[:chapters] = if data["data"]["chapters"]
52
+ metadata[:chapters] = data["data"]["chapters"].map do |chapter|
53
+ Chapter.new(chapter["start"], chapter["title"])
54
+ end.sort
55
+ end
56
+
57
+ metadata
58
+ end
48
59
  end
49
60
 
61
+
50
62
  def initialize(podcast=nil, *args)
51
63
  @podcast = podcast
52
64
  super(*args)
@@ -1,3 +1,3 @@
1
1
  module GstKitchen
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -0,0 +1,106 @@
1
+ require "spec_helper"
2
+ require "date"
3
+
4
+ describe Episode do
5
+ it "should extract the episode number from the full handle" do
6
+ Episode.extract_episode_number("GST", "GST000").should == 0
7
+ Episode.extract_episode_number("meh!", "meh!042").should == 42
8
+ end
9
+
10
+
11
+ describe "Auphonic" do
12
+ it "should be build on metadata provided by auphonic production" do
13
+ podcast = double("podcast")
14
+ podcast.stub(:handle).and_return("GST")
15
+
16
+ now = Time.now
17
+ Time.stub(:now).and_return(now)
18
+
19
+ production = double("auphonic production")
20
+ production.should_receive(:meta).and_return({
21
+ "data" => {
22
+ "uuid" => "id",
23
+ "length" => 1234,
24
+ "metadata" => {
25
+ "title" => "GST023 - Rikeripsum",
26
+ "subtitle" => "Rikeripsum",
27
+ "summary" => "summary"
28
+ },
29
+ "output_files" => [
30
+ {
31
+ "format" => "mp3",
32
+ "size" => 1234,
33
+ "ending" => "mp3"
34
+ }
35
+ ]
36
+ }
37
+ })
38
+
39
+ episode = Episode.from_auphonic podcast, production
40
+ episode.number.should == 23
41
+ episode.name.should == "Rikeripsum"
42
+ episode.length.should == 1234
43
+ episode.auphonic_uuid.should == "id"
44
+ episode.published_at.should == now
45
+ episode.summary.should == "summary"
46
+
47
+ # episode.media
48
+ # episode.chapters
49
+ end
50
+ end
51
+
52
+
53
+ it "should have a handle" do
54
+ podcast = double("podcast")
55
+ podcast.stub(:handle).and_return("GST")
56
+ subject.podcast = podcast
57
+
58
+ subject.number = 42
59
+
60
+ subject.handle.should == "GST042"
61
+ end
62
+
63
+ it "should have a title" do
64
+ podcast = double("podcast")
65
+ podcast.stub(:handle).and_return("GST")
66
+ subject.podcast = podcast
67
+
68
+ subject.number = 1
69
+ subject.name = "Episodename"
70
+
71
+ subject.title.should == "GST001 - Episodename"
72
+ end
73
+
74
+ it "should have a RFC2822 date" do
75
+ published_at = DateTime.strptime('2001-02-03T04:05:06+07:00', '%Y-%m-%dT%H:%M:%S%z').to_time
76
+
77
+ subject.published_at = published_at
78
+ subject.rfc_2822_date.should == published_at.rfc2822
79
+ end
80
+
81
+ it "should have a duration in HH:MM:SS" do
82
+ subject.length = 12301
83
+ subject.duration.should == "03:25:01"
84
+
85
+ subject.length = 1231
86
+ subject.duration.should == "00:20:31"
87
+
88
+ subject.length = 0
89
+ subject.duration.should == "00:00:00"
90
+ end
91
+
92
+ it "should be comparable" do
93
+ Episode.ancestors.should include Comparable
94
+ end
95
+
96
+ it "should be sortable (by episode number)" do
97
+ subject.number = 23
98
+
99
+ other = double("other episode")
100
+
101
+ [1, 23, 46].each do |other_number|
102
+ other.should_receive(:number).and_return(other_number)
103
+ (subject <=> other).should == (subject.number <=> other_number)
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,21 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
18
+
19
+ lib = File.expand_path('../lib', __FILE__)
20
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
+ require "gst-kitchen"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gst-kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
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: 2013-03-03 00:00:00.000000000 Z
12
+ date: 2013-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -91,6 +91,22 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
94
110
  description: gst-kitchen is a gem to publish podcasts like a nerd with auphonic!
95
111
  email:
96
112
  - sebastian.cohnen@gmx.net
@@ -100,6 +116,8 @@ extensions: []
100
116
  extra_rdoc_files: []
101
117
  files:
102
118
  - .gitignore
119
+ - .rspec
120
+ - .travis.yml
103
121
  - Gemfile
104
122
  - LICENSE.txt
105
123
  - README.md
@@ -116,6 +134,8 @@ files:
116
134
  - lib/gst-kitchen/media.rb
117
135
  - lib/gst-kitchen/podcast.rb
118
136
  - lib/gst-kitchen/version.rb
137
+ - spec/episode_spec.rb
138
+ - spec/spec_helper.rb
119
139
  - templates/episodes.rss.erb
120
140
  homepage: http://github.com/tisba/gst-kitchen
121
141
  licenses: []
@@ -126,7 +146,7 @@ require_paths:
126
146
  required_ruby_version: !ruby/object:Gem::Requirement
127
147
  none: false
128
148
  requirements:
129
- - - ~>
149
+ - - ! '>='
130
150
  - !ruby/object:Gem::Version
131
151
  version: 1.9.3
132
152
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -137,11 +157,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
157
  version: '0'
138
158
  segments:
139
159
  - 0
140
- hash: -1159944381496780028
160
+ hash: -649409298588626477
141
161
  requirements: []
142
162
  rubyforge_project:
143
163
  rubygems_version: 1.8.25
144
164
  signing_key:
145
165
  specification_version: 3
146
166
  summary: gst-kitchen is a gem to publish podcasts like a nerd with auphonic!
147
- test_files: []
167
+ test_files:
168
+ - spec/episode_spec.rb
169
+ - spec/spec_helper.rb