Permalink
Browse files

Version bump to 0.0.0

  • Loading branch information...
Reto Schüttel authored and retoo committed Dec 1, 1977
1 parent 98e1969 commit f947e72a5ff184a474a457c899f88ca987fb6036
View
@@ -1,4 +1,4 @@
-= ruby-gettext-extractor
+= ruby_gettext_extractor
Description goes here.
View
@@ -4,7 +4,7 @@ require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
- gem.name = "ruby-gettext-extractor"
+ gem.name = "ruby_gettext_extractor"
gem.summary = %Q{Alternative gettext parser for ruby files}
gem.description = %Q{Alternative and more powerful gettext parser for ruby files. It covers some special cases which the normal parser can't handle}
gem.email = "reto (ät) schuettel (dot) ch"
@@ -50,7 +50,7 @@ Rake::RDocTask.new do |rdoc|
end
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "ruby-gettext-extractor #{version}"
+ rdoc.title = "ruby_gettext_extractor #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
View
@@ -0,0 +1 @@
+0.0.0
@@ -12,12 +12,19 @@
require 'gettext/rgettext'
end
-module RubyGetTextExtracter
+module RubyGettextExtracter
extend self
def parse(file, targets = []) # :nodoc:
+ content = File.read(file)
+
+ parse_string(content, file, targets)
+ end
+
+ def parse_string(content, file, targets=[])
+ # file is just for information in error messages
parser = Extractor.new(file, targets)
- results = parser.run()
+ results = parser.run(content)
end
def target?(file) # :nodoc:
@@ -41,9 +48,7 @@ def initialize(filename, targets)
super()
end
- def run()
- content = File.read(@filename)
-
+ def run(content)
self.parse(content)
return @results
end
@@ -138,4 +143,4 @@ def new_call recv, meth, args = nil
end
end
-GetText::RGetText.add_parser(RubyGetTextExtracter)
+GetText::RGetText.add_parser(RubyGettextExtracter)
@@ -5,7 +5,7 @@
class TestGetTextParser < Test::Unit::TestCase
def test_ruby
- ary = RubyGetTextExtracter.parse('test/cases/gettext.rb')
+ ary = RubyGettextExtracter.parse('test/cases/gettext.rb')
assert_equal(['aaa', 'test/cases/gettext.rb:8'], ary[0])
assert_equal(['aaa\n', 'test/cases/gettext.rb:12'], ary[1])
@@ -30,7 +30,7 @@ def test_ruby
end
def test_ruby_N
- ary = RubyGetTextExtracter.parse('test/cases/N_.rb')
+ ary = RubyGettextExtracter.parse('test/cases/N_.rb')
assert_equal(['aaa', 'test/cases/N_.rb:8'], ary[0])
assert_equal(['aaa\n', 'test/cases/N_.rb:12'], ary[1])
@@ -50,7 +50,7 @@ def test_ruby_N
end
def test_ruby_n
- ary = RubyGetTextExtracter.parse('test/cases/ngettext.rb')
+ ary = RubyGettextExtracter.parse('test/cases/ngettext.rb')
assert_equal(["aaa\000aaa2", 'test/cases/ngettext.rb:8'], ary[0])
assert_equal(["bbb\\n\000ccc2\\nccc2", 'test/cases/ngettext.rb:12'], ary[1])
# position difference caused by multiline statement, 18 instead of 16
@@ -68,15 +68,15 @@ def test_ruby_n
end
def test_ruby_p
- ary = RubyGetTextExtracter.parse('test/cases/pgettext.rb')
+ ary = RubyGettextExtracter.parse('test/cases/pgettext.rb')
assert_equal(["AAA\004BBB", "test/cases/pgettext.rb:8", "test/cases/pgettext.rb:12"], ary[0])
assert_equal(["AAA|BBB\004CCC", "test/cases/pgettext.rb:16"], ary[1])
assert_equal(["AAA\004CCC", "test/cases/pgettext.rb:20"], ary[2])
assert_equal(["CCC\004BBB", "test/cases/pgettext.rb:24"], ary[3])
end
def test_new_cases
- ary = RubyGetTextExtracter.parse('test/cases/new.rb')
+ ary = RubyGettextExtracter.parse('test/cases/new.rb')
assert_equal(["baz", "test/cases/new.rb:5"], ary[0])
assert_equal(["foobarbaz", "test/cases/new.rb:5"], ary[1])
assert_equal(["world", "test/cases/new.rb:6"], ary[2])
View
@@ -3,7 +3,7 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
-require 'ruby-gettext-extractor'
+require 'ruby_gettext_extractor'
class Test::Unit::TestCase
end

0 comments on commit f947e72

Please sign in to comment.