air18n 0.4.14 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- require "i18n"
1
+ require 'i18n'
2
2
 
3
3
  require 'active_record'
4
4
 
@@ -3,9 +3,10 @@ require 'air18n/phrase_revision'
3
3
  require 'air18n/phrase_screenshot'
4
4
  require 'air18n/phrase_translation'
5
5
  require 'air18n/screenshot'
6
+ require 'air18n/translator_info'
6
7
 
7
8
  module Air18n
8
9
  module Reflection
9
- MODELS = [Phrase, PhraseRevision, PhraseScreenshot, PhraseTranslation, Screenshot]
10
+ MODELS = [Phrase, PhraseRevision, PhraseScreenshot, PhraseTranslation, Screenshot, TranslatorInfo]
10
11
  end
11
12
  end
@@ -0,0 +1,7 @@
1
+ module Air18n
2
+ FactoryGirl.define do
3
+ factory :translator_info, :class => Air18n::TranslatorInfo do
4
+ user_id 3
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,17 @@
1
+ module Air18n
2
+ class TranslatorInfo < ActiveRecord::Base
3
+ belongs_to :user
4
+ validates :user_id, :presence => true
5
+
6
+ TRANSLATOR_ROLE_PROOFREAD = 2 ** 0
7
+ TRANSLATOR_ROLE_SIGNED_NDA = 2 ** 1
8
+
9
+ def has_role?(role)
10
+ if self.roles.nil?
11
+ false
12
+ else
13
+ (self.roles & role) > 0
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Air18n
2
- VERSION = "0.4.14"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -65,6 +65,19 @@ class Air18nMigration < ActiveRecord::Migration
65
65
  end
66
66
 
67
67
  add_index "screenshots", ["screenshot_url", "status"], :name => "index_screenshots_on_screenshot_url_and_status"
68
+
69
+ create_table "translator_infos", :force => true do |t|
70
+ t.integer "user_id"
71
+ t.string "currency"
72
+ t.float "translate_rate"
73
+ t.float "verify_rate"
74
+ t.integer "roles"
75
+ t.string "project"
76
+ t.datetime "created_at"
77
+ t.datetime "updated_at"
78
+ end
79
+
80
+ add_index "translator_infos", ["user_id"], :name => "index_translator_infos_on_user_id", :unique => true
68
81
  end
69
82
 
70
83
  def self.down
@@ -72,5 +85,6 @@ class Air18nMigration < ActiveRecord::Migration
72
85
  drop_table :phrase_translations
73
86
  drop_table :phrases
74
87
  drop_table :screenshots
88
+ drop_table :translator_infos
75
89
  end
76
90
  end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Air18n::TranslatorInfo do
6
+ context 'has_role?' do
7
+ it 'should work' do
8
+ ti = FactoryGirl.create(:translator_info)
9
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_PROOFREAD).should == false
10
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_SIGNED_NDA).should == false
11
+
12
+ ti.roles = Air18n::TranslatorInfo::TRANSLATOR_ROLE_PROOFREAD
13
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_PROOFREAD).should == true
14
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_SIGNED_NDA).should == false
15
+
16
+ ti.roles += Air18n::TranslatorInfo::TRANSLATOR_ROLE_SIGNED_NDA
17
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_PROOFREAD).should == true
18
+ ti.has_role?(Air18n::TranslatorInfo::TRANSLATOR_ROLE_SIGNED_NDA).should == true
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: air18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-06-24 00:00:00.000000000 Z
16
+ date: 2013-06-26 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: i18n
@@ -184,6 +184,8 @@ files:
184
184
  - lib/air18n/testing_support/factories/phrase.rb
185
185
  - lib/air18n/testing_support/factories/phrase_screenshot.rb
186
186
  - lib/air18n/testing_support/factories/phrase_translation.rb
187
+ - lib/air18n/testing_support/factories/translator_info.rb
188
+ - lib/air18n/translator_info.rb
187
189
  - lib/air18n/version.rb
188
190
  - lib/air18n/xss_detector.rb
189
191
  - lib/generators/air18n/migration/migration_generator.rb
@@ -199,6 +201,7 @@ files:
199
201
  - spec/lib/air18n/prim_and_proper_spec.rb
200
202
  - spec/lib/air18n/pseudo_locales_spec.rb
201
203
  - spec/lib/air18n/smart_count_spec.rb
204
+ - spec/lib/air18n/translator_info_spec.rb
202
205
  - spec/lib/air18n/xss_detector_spec.rb
203
206
  - spec/spec_helper.rb
204
207
  homepage: http://www.github.com/airbnb/air18n
@@ -221,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
224
  version: '0'
222
225
  requirements: []
223
226
  rubyforge_project:
224
- rubygems_version: 1.8.24
227
+ rubygems_version: 1.8.22
225
228
  signing_key:
226
229
  specification_version: 3
227
230
  summary: Dynamic I18n backend
@@ -237,5 +240,6 @@ test_files:
237
240
  - spec/lib/air18n/prim_and_proper_spec.rb
238
241
  - spec/lib/air18n/pseudo_locales_spec.rb
239
242
  - spec/lib/air18n/smart_count_spec.rb
243
+ - spec/lib/air18n/translator_info_spec.rb
240
244
  - spec/lib/air18n/xss_detector_spec.rb
241
245
  - spec/spec_helper.rb