Skip to content

Commit

Permalink
remove hpricot -> use nokogiri
Browse files Browse the repository at this point in the history
  • Loading branch information
nofxx committed May 9, 2015
1 parent 0574248 commit b3538d4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions lib/subtitle_it.rb
@@ -1,6 +1,7 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'rubygems'
require 'yaml'

require 'subtitle_it/version'
require 'subtitle_it/languages'
require 'subtitle_it/subtime'
Expand All @@ -17,7 +18,7 @@ module SubtitleIt

class Numeric
def reduce
self / ( 10 ** Math::log10(self).to_i)
self / 10 ** Math::log10(self).to_i
end
end

Expand All @@ -28,4 +29,3 @@ def to_a
end
end
end

7 changes: 4 additions & 3 deletions lib/subtitle_it/formats/xml.rb
Expand Up @@ -19,16 +19,17 @@
# </div>
# </body>
#</tt>
require 'hpricot'
require 'nokogiri'

module Formats
include PlatformEndLine

def parse_xml
final = []
doc = Hpricot.XML(@raw)
doc = Nokogiri::XML.parse(@raw)
(doc/'tt'/'p').each do |line|
time_on, time_off = ['begin', 'dur'].map { |str| line[str.to_sym] }
text = line.innerHTML
text = line.inner_html
final << Subline.new(time_on,time_off,text)
end
return final
Expand Down
10 changes: 5 additions & 5 deletions lib/subtitle_it/formats/yml.rb
@@ -1,18 +1,18 @@
# SubtitleIt
# YML Dump
#
require 'yaml'
module Formats

module Formats
def parse_yml
@yaml = YAML::load(@raw)
@yaml = YAML.load(@raw)
header = @yaml.delete('header')
@title = header['title']
@author = header['authors']
@version = header['version']
@yaml['lines'].map { |l| Subline.new(l[0], l[1], l[2]) }
end

def to_yml
YAML.dump(self)
end
end
end
4 changes: 2 additions & 2 deletions spec/fixtures/movie.xml
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<div xml:lang="en">
<p begin="00:00:00.00" dur="00:00:03.07">I had just joined <span tts:fontFamily="monospaceSansSerif,proportionalSerif,TheOther"tts:fontSize="+2">Macromedia</span> in 1996,</p>
<p begin="00:00:00.00" dur="00:00:03.07">I had just joined <span tts:fontFamily="monospaceSansSerif,proportionalSerif,TheOther" tts:fontSize="+2">Macromedia</span> in 1996,</p>
<p begin="00:00:03.07" dur="00:00:03.35">and we were trying to figure out what to do about the internet.</p>
<p begin="00:00:06.42" dur="00:00:03.15">And the company was in dire straights at the time.</p>
<p begin="00:00:09.57" dur="00:00:01.45">We were a CD-ROM authoring company,</p>
Expand All @@ -25,4 +25,4 @@
<p begin="00:00:29.02" dur="00:00:01.30" style="1">as <span tts:color="#ccc333">easy</span> as drawing on paper.</p>
</div>
</body>
</tt>
</tt>
1 change: 1 addition & 0 deletions subtitle_it.gemspec
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']

s.add_dependency 'colorize'
s.add_dependency 'nokogiri'
s.add_development_dependency 'rake', '~> 10.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'rspec-mocks', '~> 3.0'
Expand Down

0 comments on commit b3538d4

Please sign in to comment.