linguara 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  stats
23
+ doc
data/LICENSE CHANGED
@@ -1,3 +1,5 @@
1
+ The MIT License
2
+
1
3
  Copyright (c) 2009 Aleksander Dabrowski
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
data/README.rdoc CHANGED
@@ -1,6 +1,30 @@
1
1
  = linguara
2
2
 
3
- This gem allows integratation with Linguara WebAPI.
3
+ This gem allows integration with Linguara WebAPI.
4
+
5
+ == Installation
6
+
7
+ You need to somehow store your translation. We assume you use globalize2
8
+
9
+ gem install globalize2
10
+ gem install linguara
11
+
12
+ Create configuration file in config/initializers/linguara.rb:
13
+
14
+ Linguara.configure do |config|
15
+ config.api_key = 'api_key'
16
+ config.server_path = 'http://www.example.com/'
17
+ config.return_url = 'http://maverick.kumulator.com:82/linguara'
18
+ end
19
+
20
+ In your model add these two lines:
21
+
22
+ BlogPost < ActiveRecord::Base
23
+ translates :name, :description
24
+ translates_with_linguara :name, :description
25
+ end
26
+
27
+ And that's all, evrything else is magic. Now every time you create your model (by default), a request is being send to linguara. When translation will be accepted, request will be sent back to your application and model will be updated.
4
28
 
5
29
  == Note on Patches/Pull Requests
6
30
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ begin
9
9
  gem.description = %Q{Gem to integrate with linguara api}
10
10
  gem.email = "aleks@kumulator.pl"
11
11
  gem.homepage = "http://github.com/tjeden/linguara"
12
- gem.authors = ["Aleksander Dabrowski"]
12
+ gem.authors = ["Aleksander Dabrowski", "Piotr Barczuk"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
14
  gem.files += FileList['lib/**/*.rb']
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
@@ -44,3 +44,15 @@ Rake::RDocTask.new do |rdoc|
44
44
  rdoc.rdoc_files.include('README*')
45
45
  rdoc.rdoc_files.include('lib/**/*.rb')
46
46
  end
47
+
48
+ task :metric do
49
+ FLAY_MAX = 100
50
+ correct = true
51
+ metric_output = %x[flay -s lib/*]
52
+ if metric_output.first.gsub("Total score (lower is better) = ","").to_i > FLAY_MAX
53
+ correct = false
54
+ puts "Too much flay. It should be less than: #{FLAY_MAX}"
55
+ puts metric_output
56
+ end
57
+ exit(1) unless correct
58
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'linguara'
@@ -7,12 +7,15 @@ module Linguara
7
7
  module LinguaraMethods
8
8
  def translates_with_linguara(*attr_names)
9
9
  include InstanceMethods
10
+
11
+ options = attr_names.extract_options!
10
12
 
11
13
  class_inheritable_accessor :linguara_translation_attribute_names
12
14
 
13
15
  self.linguara_translation_attribute_names = attr_names.map(&:to_sym)
14
16
 
15
- after_create :send_to_linguara
17
+ after_create :send_to_linguara if options[:send_on] == :create
18
+ after_save :send_to_linguara if options[:send_on] == :save
16
19
  end
17
20
  end
18
21
 
@@ -22,20 +25,40 @@ module Linguara
22
25
  prepared_fields = {}
23
26
  linguara_translation_attribute_names.each_with_index do |name, index|
24
27
  key_name = linguara_key_name(name, index)
25
- prepared_fields[key_name] = { :id => key_name, :content => self.send(name) }
28
+ prepared_fields[key_name] = self.send(name)
26
29
  end
27
30
  prepared_fields
28
31
  end
32
+
33
+ def send_to_linguara(options = {})
34
+ options = before_send_to_linguara(options)
35
+ res = Linguara.send_translation_request(self, options )
36
+ after_send_to_linguara(res)
37
+ res
38
+ end
39
+
40
+ def send_status_query(translation_request_id)
41
+ Linguara.send_status_query(translation_request_id)
42
+ end
29
43
 
30
44
  protected
31
45
 
32
46
  def linguara_key_name(field, index)
33
47
  "#{self.class.class_name}_#{self.id}_#{index}_#{field}"
34
- end
48
+ end
35
49
 
36
- def send_to_linguara
37
- Linguara.send_request(self)
38
- end
50
+ #override this if you want to have a customised method for determining which language to use.
51
+ def linguara_default_translation_language
52
+ 'en'
53
+ end
54
+
55
+ #override for some callbacks
56
+ def before_send_to_linguara(options)
57
+ options
58
+ end
59
+
60
+ def after_send_to_linguara(response)
61
+ end
39
62
 
40
63
  end
41
64
  end
@@ -1,8 +1,10 @@
1
1
  module Linguara
2
2
  class Configuration
3
- attr_accessor :api_key, :server_path, :return_url, :user, :password
3
+ attr_accessor :api_key, :server_path, :return_url, :user, :password, :request_valid_for, :site_url, :log, :return_request
4
4
 
5
5
  def initialize
6
+ self.log = true
7
+ self.request_valid_for = 30
6
8
  end
7
9
  end
8
10
  end
@@ -0,0 +1,22 @@
1
+ class Translation
2
+
3
+ attr_accessor :translation_hash
4
+
5
+ def initialize(element,options = {})
6
+ unless options[:translation] && options[:translation][:due_date]
7
+ options[:translation] = Hash.new
8
+ options[:translation][:due_date] ||= Date.today + Linguara.configuration.request_valid_for.to_i.days unless Linguara.configuration.request_valid_for.blank?
9
+ options[:translation][:due_date] ||= Date.today + 1.month
10
+ end
11
+ options[:return_url] ||= Linguara.configuration.return_url
12
+ options[:source_language] ||= I18n.locale.to_s
13
+ options[:content] = Hash.new
14
+ options[:content][:plain] = Hash.new
15
+ options[:content][:plain][:paragraphs] = element.fields_to_send
16
+ self.translation_hash = options
17
+ end
18
+
19
+ def to_hash
20
+ self.translation_hash
21
+ end
22
+ end
@@ -1,18 +1,21 @@
1
1
  module Linguara
2
2
  module Utils
3
- #TODO describe it, spec and move somewhere else
3
+ #TODO describe it, spec and move somewhere else
4
4
  # http://www.keyongtech.com/5211204-nested-http-params-on-ruby
5
5
  def serialize_form_data(data, path = "",serialized_params = [])
6
6
  if data.kind_of? Hash
7
- data.each_pair{|k,v| token = (path == "" ? url_encode(k) : "[#{url_encode(k)}]"); serialize_form_data(v, "#{path}#{token}",serialized_params)}
8
- elsif data.kind_of? Array
9
- data.each{|v| serialize_form_data(v, "#{path}[]", serialized_params) }
7
+ data.each_pair{|k,v| token = (path == "" ? CGI::escape(k.to_s) : "[#{CGI::escape(k.to_s)}]"); serialize_form_data(v, "#{path}#{token}",serialized_params)}
10
8
  else
11
9
  #end of recursion
12
- serialized_params << "#{path}=#{url_encode(data)}"
10
+ serialized_params << "#{path}=#{CGI::escape(data.to_s)}"
13
11
  end
14
12
 
15
13
  return serialized_params.join("&") if (path == "")
16
14
  end
15
+
16
+ def strip_blank_attributes(data)
17
+ data = data.each_pair { |k,v| v.is_a?(Hash) ? (strip_blank_attributes(v)) : (v) }
18
+ data.delete_if { |k,v| v.blank?}
19
+ end
17
20
  end
18
21
  end
data/lib/linguara.rb CHANGED
@@ -2,6 +2,7 @@ require 'net/http'
2
2
  require 'uri'
3
3
  require 'linguara/configuration'
4
4
  require 'linguara/utils'
5
+ require 'linguara/translation'
5
6
 
6
7
  module Linguara
7
8
  extend Linguara::Utils
@@ -15,47 +16,112 @@ module Linguara
15
16
  yield(configuration)
16
17
  end
17
18
 
19
+ # Use this method in your controller to accepr and save incoming translations
18
20
  def accept_translation(translation)
19
21
  target_language = translation[:target_language]
20
- translation[:paragraph].each do |key,value|
21
- class_name,id,order,field_name = value[:id].split('_')
22
- content = value[:content]
22
+ translation[:paragraphs].each do |key,value|
23
+ class_name,id,order,field_name = key.split('_')
23
24
  original_locale = I18n.locale
24
25
  element = class_name.constantize.find(id)
25
26
 
26
27
  I18n.locale = target_language
27
- element.send("#{field_name}=", content)
28
+ element.send("#{field_name}=", value.gsub(/<p>(.*?)<\/p>/, "\\1\n") )
28
29
  element.save(false)
29
30
  I18n.locale = original_locale
30
31
  end
31
32
  end
32
33
 
33
- def send_request(element)
34
- url= URI.parse(Linguara.configuration.server_path)
35
- req = Net::HTTP::Post.new(url.path)
36
- req.body = serialize_form_data({
37
- :translation => {
38
- :return_url => Linguara.configuration.return_url,
39
- :due_date => '27-06-2010',
40
- :source_language =>"pl",
41
- :target_language =>"en",
42
- :paragraph => element.fields_to_send,
43
- :account_token => Linguara.configuration.api_key}})
34
+ def send_translation_request(element, options = {})
35
+ translation = Translation.new(element, options)
36
+ url= URI.parse("#{Linguara.configuration.server_path}api/translations.xml")
37
+ req = prepare_request(url, translation.to_hash.merge( :authorization => true))
38
+ send_linguara_request(req, url)
39
+ end
40
+
41
+ def send_status_query(translation_request_id)
42
+ url= URI.parse("#{Linguara.configuration.server_path}api/translations/#{translation_request_id}/status.xml")
43
+ req = prepare_request(url, :authorization => true)
44
+ send_linguara_request(req, url)
45
+ end
46
+
47
+ def send_languages_request(options={})
48
+ url= URI.parse("#{Linguara.configuration.server_path}api/languages.xml")
49
+ req = prepare_request(url, options.merge(:method => :get))
50
+ send_linguara_request(req, url)
51
+ end
52
+
53
+ def send_specializations_request(options)
54
+ url= URI.parse("#{Linguara.configuration.server_path}api/specializations.xml")
55
+ req = prepare_request(url, options.merge(:method => :get))
56
+ send_linguara_request(req, url)
57
+ end
58
+
59
+ def send_translators_request(options)
60
+ url= URI.parse("#{Linguara.configuration.server_path}api/translators.xml")
61
+ req = prepare_request(url, options.merge(:method => :get))
62
+ send_linguara_request(req, url)
63
+ end
64
+
65
+ # Override this method if you want to perform some action when connection
66
+ # with linguara cannot be established e.g. log request or redo the send
67
+ def handle_request_error
68
+ log("ERROR WHILE SENDING REQUEST TO LINGUARA: #{$!}")
69
+ end
70
+
71
+ # Log a linguara-specific line. Uses Rails.logger
72
+ # by default. Set Lingurara.config.log = false to turn off.
73
+ def log message
74
+ logger.info("[linguara] #{message}") if logging?
75
+ end
76
+
77
+ def logger #:nodoc:
78
+ Rails.logger
79
+ end
80
+
81
+ def logging? #:nodoc:
82
+ Linguara.configuration.log
83
+ end
84
+
85
+ private
86
+
87
+ def prepare_request(url, data = {} )
88
+ data = strip_blank_attributes(data)
89
+ if data[:method] == :get
90
+ req = Net::HTTP::Get.new(url.path)
91
+ data.delete(:method)
92
+ else
93
+ req = Net::HTTP::Post.new(url.path)
94
+ end
95
+ if data[:authorization]
96
+ data.delete(:authorization)
97
+ req.body = serialize_form_data({
98
+ :site_url => Linguara.configuration.site_url,
99
+ :account_token => Linguara.configuration.api_key
100
+ }.merge(data))
101
+ else
102
+ req.body = serialize_form_data(data)
103
+ end
44
104
  req.content_type = 'application/x-www-form-urlencoded'
45
- req.basic_auth Linguara.configuration.user, Linguara.configuration.password
105
+ req.basic_auth(Linguara.configuration.user, Linguara.configuration.password)
106
+ req
107
+ end
108
+
109
+ def send_linguara_request(req, url)
46
110
  #TODO handle timeout
47
111
  begin
48
- res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
112
+ log("SENDING LINGUARA REQUEST TO #{url.path}: \n#{req.body}")
113
+ res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
114
+ log("LINGUARA RESPONSE: #{res.message} -- #{res.body}")
115
+ #TODO there should be object returned, whih contains request and respnse
116
+ if Linguara.configuration.return_request
117
+ return req
118
+ else
119
+ return res
120
+ end
49
121
  rescue Errno::ETIMEDOUT
50
122
  handle_request_error
51
123
  end
52
124
  end
53
-
54
- # ovverride this method if you want to perform some action when connection
55
- # with linguara cannot be established e.g. log request or redo the send
56
- def handle_request_error
57
- end
58
-
59
125
  end
60
126
  end
61
127
 
data/linguara.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{linguara}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Aleksander Dabrowski"]
12
- s.date = %q{2010-06-05}
11
+ s.authors = ["Aleksander Dabrowski", "Piotr Barczuk"]
12
+ s.date = %q{2010-07-23}
13
13
  s.description = %q{Gem to integrate with linguara api}
14
14
  s.email = %q{aleks@kumulator.pl}
15
15
  s.extra_rdoc_files = [
@@ -23,9 +23,11 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "init.rb",
26
27
  "lib/linguara.rb",
27
28
  "lib/linguara/active_record.rb",
28
29
  "lib/linguara/configuration.rb",
30
+ "lib/linguara/translation.rb",
29
31
  "lib/linguara/utils.rb",
30
32
  "linguara.gemspec",
31
33
  "spec/data/schema.rb",
@@ -33,7 +35,8 @@ Gem::Specification.new do |s|
33
35
  "spec/helper_model/database_mock.rb",
34
36
  "spec/linguara_spec.rb",
35
37
  "spec/spec.opts",
36
- "spec/spec_helper.rb"
38
+ "spec/spec_helper.rb",
39
+ "spec/translation_spec.rb"
37
40
  ]
38
41
  s.homepage = %q{http://github.com/tjeden/linguara}
39
42
  s.rdoc_options = ["--charset=UTF-8"]
@@ -45,7 +48,8 @@ Gem::Specification.new do |s|
45
48
  "spec/helper_model/blog_post.rb",
46
49
  "spec/helper_model/database_mock.rb",
47
50
  "spec/linguara_spec.rb",
48
- "spec/spec_helper.rb"
51
+ "spec/spec_helper.rb",
52
+ "spec/translation_spec.rb"
49
53
  ]
50
54
 
51
55
  if s.respond_to? :specification_version then
@@ -1,3 +1,3 @@
1
1
  class BlogPost < ActiveRecord::Base
2
- translates_with_linguara :title, :body
2
+ translates_with_linguara :title, :body, :send_on => :save
3
3
  end
@@ -2,24 +2,26 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Linguara" do
4
4
 
5
- it "should sent message to linguara for translatable classes" do
6
- FakeWeb.register_uri(:post, 'http://www.example.com/', :exception => Net::HTTPError)
5
+ it "sent message to linguara for translatable classes" do
6
+ FakeWeb.register_uri(:post, 'http://www.example.com/api/translations.xml', :exception => Net::HTTPError)
7
7
  blog_post = BlogPost.new( :title => "Title text", :body => "Body text")
8
8
  lambda {
9
9
  blog_post.save
10
10
  }.should raise_error(Net::HTTPError)
11
+ FakeWeb.clean_registry
11
12
  end
12
13
 
13
- it 'should accept correct translation' do
14
- FakeWeb.register_uri(:post, 'http://www.example.com/', :body => 'response_for_linguara', :status => 200)
14
+ it 'accepts correct translation' do
15
+ FakeWeb.register_uri(:post, 'http://www.example.com/', :body => 'response_for_linguara', :status => 200)
16
+ FakeWeb.register_uri(:post, 'http://www.example.com/api/translations.xml', :status => 200)
15
17
  blog_post = BlogPost.new( :title => "Old title", :body => "Old body")
16
18
  blog_post.save
17
19
  id = blog_post.id
18
20
  lambda {
19
21
  Linguara.accept_translation(
20
- :paragraph => {
21
- "BlogPost_#{id}_0_title"=> { :id =>"BlogPost_#{id}_0_title", :content =>"Hello World!"},
22
- "BlogPost_#{id}_1_body"=> { :id =>"BlogPost_#{id}_1_body", :content =>"Today is great weather, and I am going to EuRuKo."}
22
+ :paragraphs => {
23
+ "BlogPost_#{id}_0_title" => "Hello World!",
24
+ "BlogPost_#{id}_1_body" => "Today is great weather, and I am going to EuRuKo."
23
25
  },
24
26
  :source_language =>"pl",
25
27
  :target_language =>"en"
@@ -29,6 +31,83 @@ describe "Linguara" do
29
31
  translation.title.should eql("Hello World!")
30
32
  translation.body.should eql("Today is great weather, and I am going to EuRuKo.")
31
33
  end
34
+
35
+ describe '#send_translation_request' do
36
+ it 'sends request' do
37
+ blog_post = BlogPost.new( :title => "Old title", :body => "Old body")
38
+ FakeWeb.register_uri(:post, "http://www.example.com/api/translations.xml", :body => 'response_from_linguara', :status => 200)
39
+ response = Linguara.send_translation_request(blog_post)
40
+ response.body.should eql('response_from_linguara')
41
+ end
42
+ end
43
+
44
+ describe '#send_status_query' do
45
+ it 'sends request' do
46
+ FakeWeb.register_uri(:post, "http://www.example.com/api/translations/5/status.xml", :body => 'response_from_linguara', :status => 200)
47
+ response = Linguara.send_status_query(5)
48
+ response.body.should eql('response_from_linguara')
49
+ end
50
+ end
51
+
52
+ describe '#send_languages_request' do
53
+ it 'sends request' do
54
+ FakeWeb.register_uri(:get, "http://www.example.com/api/languages.xml", :body => 'response_from_linguara', :status => 200)
55
+ response = Linguara.send_languages_request("city"=>"321", "specialization"=>"technical", "country"=>"pl", "native_speaker"=>"1", "max_price"=>"12")
56
+ response.body.should eql('response_from_linguara')
57
+ end
58
+ end
59
+
60
+ describe '#send_specializations_request' do
61
+ it 'sends request' do
62
+ FakeWeb.register_uri(:get, "http://www.example.com/api/specializations.xml", :body => 'response_from_linguara', :status => 200)
63
+ response = Linguara.send_specializations_request("language"=>"suomi", "sworn" => "1", "native_speaker"=>"1", "max_price"=>"12")
64
+ response.body.should eql('response_from_linguara')
65
+ end
66
+ end
67
+
68
+ describe '#send_translators_request' do
69
+ it 'sends request' do
70
+ FakeWeb.register_uri(:get, "http://www.example.com/api/translators.xml", :body => 'response_from_linguara', :status => 200)
71
+ response = Linguara.send_translators_request("city"=>"warsaw", "country"=>"pl", "max_price"=>"12", "query"=>"wojcisz", "target_language"=>"en", "source_language" => "pl")
72
+ response.body.should eql('response_from_linguara')
73
+ end
74
+ end
75
+
76
+ describe '#prepare_request' do
77
+ before :each do
78
+ @url = URI.parse("http://www.example.com/api/translations")
79
+ @options = { :translation => { :translator => { :city => "Prague"}}}
80
+ end
81
+
82
+ it 'sets :POST by deafault' do
83
+ request = Linguara.send(:prepare_request, @url, @options)
84
+ request.is_a?(Net::HTTP::Post).should be_true
85
+ request.body.include?("post").should be_false
86
+ end
87
+
88
+ it 'sets :GET when option given' do
89
+ request = Linguara.send(:prepare_request, @url, @options.merge(:method => :get))
90
+ request.is_a?(Net::HTTP::Get).should be_true
91
+ request.body.include?("get").should be_false
92
+ end
93
+
94
+ it 'skips blank parameters' do
95
+ request = Linguara.send(:prepare_request, @url, @options.merge(:blank_attribute => ""))
96
+ request.body.include?("blank_attribute").should be_false
97
+ end
98
+
99
+ it 'skips blank parameters deep' do
100
+ request = Linguara.send(:prepare_request, @url, @options.merge(:blank_parent => { :blank_attribute => ""}))
101
+ request.body.include?("blank_attribute").should be_false
102
+ request.body.include?("blank_parent").should be_false
103
+ end
104
+
105
+ it 'sets content type to application/x-www-form-urlencoded' do
106
+ request = Linguara.send(:prepare_request, @url, @options)
107
+ request.content_type.should be_eql("application/x-www-form-urlencoded")
108
+ end
109
+
110
+ end
32
111
 
33
112
  end
34
113
 
@@ -37,9 +116,8 @@ describe 'Linguara::ActiveRecord' do
37
116
  blog_post = BlogPost.new( :title => "Title text", :body => "Body text")
38
117
  fields_to_send = blog_post.fields_to_send.to_a.sort { |a,b| a[0] <=> b[0] }
39
118
  fields_to_send.size.should eql(2)
40
- # It's complicated becouse linguara API is complicated. It will be much simplier in future
41
- fields_to_send.first[1][:content].should eql("Title text")
42
- fields_to_send.last[1][:content].should eql("Body text")
119
+ fields_to_send.first[1].should eql("Title text")
120
+ fields_to_send.last[1].should eql("Body text")
43
121
  end
44
122
  end
45
123
 
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,12 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
- require 'rubygems'
4
+ require 'cgi'
5
5
  require 'active_record'
6
6
  require 'active_support'
7
7
  require 'helper_model/database_mock'
8
8
  require 'linguara'
9
9
  require 'helper_model/blog_post'
10
- require "erb"
11
- include ERB::Util
12
10
  require 'spec'
13
11
  require 'spec/autorun'
14
12
  require 'fakeweb'
@@ -16,9 +14,10 @@ require 'fakeweb'
16
14
  prepare_database
17
15
 
18
16
  Linguara.configure do |config|
19
- config.api_key = 'api_keu'
17
+ config.api_key = 'api_key'
20
18
  config.server_path = 'http://www.example.com/'
21
19
  config.return_url = 'http://maverick.kumulator.com:82/linguara'
20
+ config.log = false
22
21
  end
23
22
 
24
23
  Spec::Runner.configure do |config|
@@ -0,0 +1,24 @@
1
+ require 'spec/spec_helper'
2
+
3
+ describe Translation do
4
+ subject do
5
+ @blog_post = BlogPost.new( :title => "Title text", :body => "Body text")
6
+ Translation.new(@blog_post)
7
+ end
8
+
9
+ it 'creates default due_date on default' do
10
+ subject.to_hash[:translation][:due_date].should eql(Date.today + Linguara.configuration.request_valid_for.to_i.days)
11
+ end
12
+
13
+ it 'creates return_url on default' do
14
+ subject.to_hash[:return_url].should eql(Linguara.configuration.return_url)
15
+ end
16
+
17
+ it 'sets source language on default' do
18
+ subject.to_hash[:source_language].should eql(I18n.locale.to_s)
19
+ end
20
+
21
+ it 'creates paragraphs for model' do
22
+ subject.to_hash[:content][:plain][:paragraphs].should eql(@blog_post.fields_to_send)
23
+ end
24
+ end
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linguara
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aleksander Dabrowski
14
+ - Piotr Barczuk
14
15
  autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-06-05 00:00:00 +02:00
19
+ date: 2010-07-23 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -50,9 +51,11 @@ files:
50
51
  - README.rdoc
51
52
  - Rakefile
52
53
  - VERSION
54
+ - init.rb
53
55
  - lib/linguara.rb
54
56
  - lib/linguara/active_record.rb
55
57
  - lib/linguara/configuration.rb
58
+ - lib/linguara/translation.rb
56
59
  - lib/linguara/utils.rb
57
60
  - linguara.gemspec
58
61
  - spec/data/schema.rb
@@ -61,6 +64,7 @@ files:
61
64
  - spec/linguara_spec.rb
62
65
  - spec/spec.opts
63
66
  - spec/spec_helper.rb
67
+ - spec/translation_spec.rb
64
68
  has_rdoc: true
65
69
  homepage: http://github.com/tjeden/linguara
66
70
  licenses: []
@@ -101,3 +105,4 @@ test_files:
101
105
  - spec/helper_model/database_mock.rb
102
106
  - spec/linguara_spec.rb
103
107
  - spec/spec_helper.rb
108
+ - spec/translation_spec.rb