subtitle_it 0.7.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.autotest +19 -0
  2. data/History.txt +53 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +68 -0
  5. data/README.markdown +41 -0
  6. data/README.txt +102 -0
  7. data/Rakefile +4 -0
  8. data/bin/subtitle_it +66 -0
  9. data/config/hoe.rb +73 -0
  10. data/config/requirements.rb +15 -0
  11. data/lib/subtitle_it/bin.rb +132 -0
  12. data/lib/subtitle_it/fixes.rb +12 -0
  13. data/lib/subtitle_it/formats/ass.rb +13 -0
  14. data/lib/subtitle_it/formats/mpl.rb +29 -0
  15. data/lib/subtitle_it/formats/rsb.rb +37 -0
  16. data/lib/subtitle_it/formats/srt.rb +45 -0
  17. data/lib/subtitle_it/formats/sub.rb +49 -0
  18. data/lib/subtitle_it/formats/xml.rb +65 -0
  19. data/lib/subtitle_it/formats/yml.rb +18 -0
  20. data/lib/subtitle_it/generator.rb +15 -0
  21. data/lib/subtitle_it/languages.rb +60 -0
  22. data/lib/subtitle_it/movie.rb +24 -0
  23. data/lib/subtitle_it/movie_hasher.rb +30 -0
  24. data/lib/subtitle_it/platform_endl.rb +9 -0
  25. data/lib/subtitle_it/subdown.rb +107 -0
  26. data/lib/subtitle_it/subline.rb +25 -0
  27. data/lib/subtitle_it/substyle.rb +11 -0
  28. data/lib/subtitle_it/subtime.rb +41 -0
  29. data/lib/subtitle_it/subtitle.rb +76 -0
  30. data/lib/subtitle_it/version.rb +9 -0
  31. data/lib/subtitle_it.rb +22 -0
  32. data/script/console +10 -0
  33. data/script/destroy +14 -0
  34. data/script/generate +14 -0
  35. data/script/txt2html +82 -0
  36. data/setup.rb +1585 -0
  37. data/spec/fixtures/godfather.srt +2487 -0
  38. data/spec/fixtures/huge.ass +22 -0
  39. data/spec/fixtures/movie.xml +28 -0
  40. data/spec/fixtures/movie.yml +163 -0
  41. data/spec/fixtures/pseudo.rsb +6 -0
  42. data/spec/fixtures/pulpfiction.sub +2025 -0
  43. data/spec/fixtures/puplfiction.mpl +12 -0
  44. data/spec/fixtures/sincity.yml +12 -0
  45. data/spec/spec.opts +1 -0
  46. data/spec/spec_helper.rb +71 -0
  47. data/spec/subtitle_it/bin_spec.rb +142 -0
  48. data/spec/subtitle_it/fixes_spec.rb +0 -0
  49. data/spec/subtitle_it/formats/ass_spec.rb +5 -0
  50. data/spec/subtitle_it/formats/mpl_spec.rb +45 -0
  51. data/spec/subtitle_it/formats/rsb_spec.rb +42 -0
  52. data/spec/subtitle_it/formats/srt_spec.rb +57 -0
  53. data/spec/subtitle_it/formats/sub_spec.rb +49 -0
  54. data/spec/subtitle_it/formats/xml_spec.rb +60 -0
  55. data/spec/subtitle_it/formats/yml_spec.rb +20 -0
  56. data/spec/subtitle_it/generator_spec.rb +0 -0
  57. data/spec/subtitle_it/movie_hasher_spec.rb +13 -0
  58. data/spec/subtitle_it/movie_spec.rb +25 -0
  59. data/spec/subtitle_it/subdown_spec.rb +94 -0
  60. data/spec/subtitle_it/subline_spec.rb +30 -0
  61. data/spec/subtitle_it/substyle_spec.rb +1 -0
  62. data/spec/subtitle_it/subtime_spec.rb +73 -0
  63. data/spec/subtitle_it/subtitle_spec.rb +40 -0
  64. data/spec/subtitle_it_spec.rb +11 -0
  65. data/subtitle_it.gemspec +41 -0
  66. data/tasks/deployment.rake +34 -0
  67. data/tasks/environment.rake +7 -0
  68. data/tasks/rspec.rake +21 -0
  69. metadata +152 -0
data/script/txt2html ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ GEM_NAME = 'subtitle_it' # what ppl will type to install your gem
4
+ RUBYFORGE_PROJECT = 'subtitle_it'
5
+
6
+ require 'rubygems'
7
+ begin
8
+ require 'newgem'
9
+ require 'rubyforge'
10
+ rescue LoadError
11
+ puts "\n\nGenerating the website requires the newgem RubyGem"
12
+ puts "Install: gem install newgem\n\n"
13
+ exit(1)
14
+ end
15
+ require 'redcloth'
16
+ require 'syntax/convertors/html'
17
+ require 'erb'
18
+ require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
+
20
+ version = SubtitleIt::VERSION::STRING
21
+ download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
+
23
+ def rubyforge_project_id
24
+ RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
+ end
26
+
27
+ class Fixnum
28
+ def ordinal
29
+ # teens
30
+ return 'th' if (10..19).include?(self % 100)
31
+ # others
32
+ case self % 10
33
+ when 1: return 'st'
34
+ when 2: return 'nd'
35
+ when 3: return 'rd'
36
+ else return 'th'
37
+ end
38
+ end
39
+ end
40
+
41
+ class Time
42
+ def pretty
43
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
+ end
45
+ end
46
+
47
+ def convert_syntax(syntax, source)
48
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
+ end
50
+
51
+ if ARGV.length >= 1
52
+ src, template = ARGV
53
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
+ else
55
+ puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
+ exit!
57
+ end
58
+
59
+ template = ERB.new(File.open(template).read)
60
+
61
+ title = nil
62
+ body = nil
63
+ File.open(src) do |fsrc|
64
+ title_text = fsrc.readline
65
+ body_text_template = fsrc.read
66
+ body_text = ERB.new(body_text_template).result(binding)
67
+ syntax_items = []
68
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
+ ident = syntax_items.length
70
+ element, syntax, source = $1, $2, $3
71
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
+ "syntax-temp-#{ident}"
73
+ }
74
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
+ body = RedCloth.new(body_text).to_html
76
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
+ end
78
+ stat = File.stat(src)
79
+ created = stat.ctime
80
+ modified = stat.mtime
81
+
82
+ $stdout << template.result(binding)