tr8n 3.1.8 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.rspec +1 -0
- data/.rvmrc +1 -1
- data/.watchr +18 -0
- data/Gemfile.lock +16 -10
- data/app/assets/images/tr8n/minus_node.png +0 -0
- data/app/assets/images/tr8n/pixel.gif +0 -0
- data/app/assets/images/tr8n/plus_node.png +0 -0
- data/app/assets/javascripts/tr8n/tr8n.js +1 -0
- data/app/assets/javascripts/tr8n/tr8n_client_sdk.js +581 -425
- data/app/assets/stylesheets/tr8n/layout.css.scss +1 -1
- data/app/assets/stylesheets/tr8n/tr8n.css.scss +20 -0
- data/app/controllers/tr8n/admin/base_controller.rb +4 -1
- data/app/controllers/tr8n/admin/clientsdk_controller.rb +1 -1
- data/app/controllers/tr8n/admin/metrics_controller.rb +30 -0
- data/app/controllers/tr8n/api/v1/base_controller.rb +12 -0
- data/app/controllers/tr8n/api/v1/language_controller.rb +7 -5
- data/app/controllers/tr8n/awards_controller.rb +1 -1
- data/app/controllers/tr8n/base_controller.rb +12 -6
- data/app/controllers/tr8n/dashboard_controller.rb +1 -1
- data/app/controllers/tr8n/forum_controller.rb +1 -1
- data/app/controllers/tr8n/glossary_controller.rb +1 -1
- data/app/controllers/tr8n/help_controller.rb +1 -1
- data/app/controllers/tr8n/phrases_controller.rb +1 -1
- data/app/controllers/tr8n/translator_controller.rb +8 -0
- data/app/helpers/tr8n/admin/base_helper.rb +1 -1
- data/app/helpers/tr8n/base_helper.rb +1 -1
- data/app/helpers/tr8n/dashboard_helper.rb +1 -1
- data/app/models/tr8n/base_filter.rb +1 -1
- data/app/models/tr8n/daily_language_metric.rb +1 -1
- data/app/models/tr8n/date_rule.rb +1 -1
- data/app/models/tr8n/gender_list_rule.rb +1 -1
- data/app/models/tr8n/gender_rule.rb +1 -1
- data/app/models/tr8n/glossary.rb +1 -1
- data/app/models/tr8n/glossary_filter.rb +1 -1
- data/app/models/tr8n/integration/ru/russian_gender_list_rule.rb +1 -1
- data/app/models/tr8n/integration/ru/russian_numeric_rule.rb +1 -1
- data/app/models/tr8n/ip_location.rb +1 -1
- data/app/models/tr8n/ip_location_filter.rb +1 -1
- data/app/models/tr8n/language.rb +19 -7
- data/app/models/tr8n/language_case.rb +1 -1
- data/app/models/tr8n/language_case_filter.rb +1 -1
- data/app/models/tr8n/language_case_rule.rb +1 -1
- data/app/models/tr8n/language_case_rule_filter.rb +1 -1
- data/app/models/tr8n/language_case_value_map.rb +1 -1
- data/app/models/tr8n/language_case_value_map_filter.rb +1 -1
- data/app/models/tr8n/language_filter.rb +1 -1
- data/app/models/tr8n/language_forum_abuse_report.rb +1 -1
- data/app/models/tr8n/language_forum_abuse_report_filter.rb +1 -1
- data/app/models/tr8n/language_forum_message.rb +1 -1
- data/app/models/tr8n/language_forum_message_filter.rb +1 -1
- data/app/models/tr8n/language_forum_topic.rb +1 -1
- data/app/models/tr8n/language_forum_topic_filter.rb +1 -1
- data/app/models/tr8n/language_metric.rb +1 -1
- data/app/models/tr8n/language_metric_filter.rb +1 -1
- data/app/models/tr8n/language_rule.rb +1 -1
- data/app/models/tr8n/language_rule_filter.rb +1 -1
- data/app/models/tr8n/language_user.rb +1 -1
- data/app/models/tr8n/language_user_filter.rb +1 -1
- data/app/models/tr8n/list_rule.rb +1 -1
- data/app/models/tr8n/monthly_language_metric.rb +1 -1
- data/app/models/tr8n/numeric_rule.rb +35 -28
- data/app/models/tr8n/sync_log.rb +1 -1
- data/app/models/tr8n/sync_log_filter.rb +1 -1
- data/app/models/tr8n/total_language_metric.rb +1 -1
- data/app/models/tr8n/translation.rb +4 -3
- data/app/models/tr8n/translation_domain.rb +11 -3
- data/app/models/tr8n/translation_domain_filter.rb +1 -1
- data/app/models/tr8n/translation_filter.rb +1 -1
- data/app/models/tr8n/translation_key.rb +73 -36
- data/app/models/tr8n/translation_key_comment.rb +1 -1
- data/app/models/tr8n/translation_key_comment_filter.rb +1 -1
- data/app/models/tr8n/translation_key_filter.rb +1 -1
- data/app/models/tr8n/translation_key_lock.rb +1 -1
- data/app/models/tr8n/translation_key_lock_filter.rb +1 -1
- data/app/models/tr8n/translation_key_source.rb +16 -5
- data/app/models/tr8n/translation_key_source_filter.rb +1 -1
- data/app/models/tr8n/translation_source.rb +12 -4
- data/app/models/tr8n/translation_source_filter.rb +1 -1
- data/app/models/tr8n/translation_source_language.rb +1 -1
- data/app/models/tr8n/translation_vote.rb +1 -1
- data/app/models/tr8n/translation_vote_filter.rb +1 -1
- data/app/models/tr8n/translator.rb +21 -5
- data/app/models/tr8n/translator_filter.rb +1 -1
- data/app/models/tr8n/translator_following.rb +1 -1
- data/app/models/tr8n/translator_following_filter.rb +1 -1
- data/app/models/tr8n/translator_log.rb +3 -3
- data/app/models/tr8n/translator_log_filter.rb +1 -1
- data/app/models/tr8n/translator_metric.rb +1 -1
- data/app/models/tr8n/translator_metric_filter.rb +1 -1
- data/app/models/tr8n/translator_report.rb +1 -1
- data/app/models/tr8n/translator_report_filter.rb +1 -1
- data/app/models/tr8n/value_rule.rb +1 -1
- data/app/views/tr8n/admin/clientsdk/index.html.erb +29 -29
- data/app/views/tr8n/admin/clientsdk/lb_samples.html.erb +1 -1
- data/app/views/tr8n/admin/metrics/_tabs.html.erb +22 -0
- data/app/views/tr8n/admin/metrics/index.html.erb +60 -0
- data/app/views/tr8n/common/_header.html.erb +3 -1
- data/app/views/tr8n/common/_language_selector.html.erb +4 -2
- data/app/views/tr8n/common/_scripts.html.erb +5 -0
- data/app/views/tr8n/common/_terms_of_service.html.erb +53 -0
- data/app/views/tr8n/help/credits.html.erb +4 -0
- data/app/views/tr8n/language/_select.html.erb +5 -1
- data/app/views/tr8n/translator/registration.html.erb +21 -0
- data/config/routes.rb +3 -1
- data/doc/classes.graffle +356 -7194
- data/lib/generators/tr8n/templates/config/tr8n/config.yml +9 -1
- data/lib/generators/tr8n/templates/config/tr8n/site/shortcuts.yml +1 -1
- data/lib/generators/tr8n/templates/config/tr8n/tokens/decorations.yml +4 -1
- data/lib/generators/tr8n/tr8n_generator.rb +1 -1
- data/lib/tasks/tr8n.rake +1 -1
- data/lib/tr8n.rb +23 -0
- data/lib/tr8n/active_dumper.rb +1 -1
- data/lib/tr8n/cache.rb +1 -8
- data/lib/tr8n/cache_adapters/memcached.rb +1 -1
- data/lib/tr8n/config.rb +37 -1
- data/lib/tr8n/dictionary.rb +1 -1
- data/lib/tr8n/engine.rb +4 -1
- data/lib/tr8n/exception.rb +1 -1
- data/lib/tr8n/extender.rb +1 -1
- data/lib/tr8n/extensions/action_controller_extension.rb +5 -4
- data/lib/tr8n/extensions/action_view_extension.rb +71 -20
- data/lib/tr8n/extensions/array_extension.rb +14 -1
- data/lib/tr8n/extensions/date_extension.rb +1 -1
- data/lib/tr8n/extensions/fixnum_extension.rb +1 -1
- data/lib/tr8n/extensions/hash_extension.rb +1 -1
- data/lib/tr8n/extensions/string_extension.rb +1 -1
- data/lib/tr8n/extensions/time_extension.rb +1 -1
- data/lib/tr8n/ip_address.rb +1 -1
- data/lib/tr8n/key_registration_exception.rb +1 -1
- data/lib/tr8n/keyboard_mapping.rb +1 -1
- data/lib/tr8n/logger.rb +1 -1
- data/lib/tr8n/railtie.rb +1 -1
- data/lib/tr8n/site_map.rb +1 -1
- data/lib/tr8n/site_map_section.rb +1 -1
- data/lib/tr8n/token.rb +1 -1
- data/lib/tr8n/token_exception.rb +1 -1
- data/lib/tr8n/tokenized_label.rb +2 -12
- data/lib/tr8n/tokens/data_token.rb +1 -1
- data/lib/tr8n/tokens/decoration_token.rb +1 -1
- data/lib/tr8n/tokens/hidden_token.rb +1 -1
- data/lib/tr8n/tokens/method_token.rb +1 -1
- data/lib/tr8n/tokens/transform_token.rb +1 -1
- data/lib/tr8n/version.rb +25 -1
- data/local/tr8n_server/app/models/user.rb +1 -0
- data/local/tr8n_server/config/environments/test.rb +1 -1
- data/local/tr8n_server/config/tr8n/config.yml +45 -39
- data/local/tr8n_server/config/tr8n/site/shortcuts.yml +1 -1
- data/local/tr8n_server/db/schema.rb +2 -0
- data/spec/controllers/awards_controller_spec.rb +22 -0
- data/spec/controllers/base_controller_spec.rb +6 -0
- data/spec/controllers/dashboard_controller_spec.rb +23 -0
- data/spec/controllers/forum_controller_spec.rb +23 -0
- data/spec/controllers/glossary_controller_spec.rb +22 -0
- data/spec/controllers/help_controller_spec.rb +22 -0
- data/spec/controllers/language_cases_controller_spec.rb +13 -0
- data/spec/controllers/language_controller_spec.rb +10 -0
- data/spec/controllers/phrases_controller_spec.rb +22 -0
- data/spec/controllers/translations_controller_spec.rb +23 -0
- data/spec/controllers/translator_controller_spec.rb +22 -0
- data/spec/lib/tokenized_label_spec.rb +42 -0
- data/spec/lib/tokens/data_token_spec.rb +49 -0
- data/spec/lib/tokens/decoration_token_spec.rb +49 -0
- data/spec/lib/tokens/hidden_token_spec.rb +53 -0
- data/spec/lib/tokens/method_token_spec.rb +61 -0
- data/spec/lib/tokens/transform_token_spec.rb +51 -0
- data/spec/models/tr8n/daily_language_metric_spec.rb +5 -0
- data/spec/models/tr8n/date_rule_spec.rb +5 -0
- data/spec/models/tr8n/gender_list_rule_spec.rb +5 -0
- data/spec/models/tr8n/gender_rule_spec.rb +141 -0
- data/spec/models/tr8n/glossary_spec.rb +5 -0
- data/spec/models/tr8n/ip_location_spec.rb +5 -0
- data/spec/models/tr8n/language_case_rule_spec.rb +5 -0
- data/spec/models/tr8n/language_case_spec.rb +5 -0
- data/spec/models/tr8n/language_case_value_map_spec.rb +5 -0
- data/spec/models/tr8n/language_forum_abuse_report_spec.rb +5 -0
- data/spec/models/tr8n/language_forum_message_spec.rb +5 -0
- data/spec/models/tr8n/language_forum_topic_spec.rb +5 -0
- data/spec/models/tr8n/language_metric_spec.rb +5 -0
- data/spec/models/tr8n/language_rule_spec.rb +5 -0
- data/spec/models/tr8n/language_spec.rb +79 -0
- data/spec/models/tr8n/language_user_spec.rb +5 -0
- data/spec/models/tr8n/list_rule_spec.rb +5 -0
- data/spec/models/tr8n/monthly_language_metric_spec.rb +5 -0
- data/spec/models/tr8n/numeric_rule_spec.rb +162 -0
- data/spec/models/tr8n/sync_log_spec.rb +5 -0
- data/spec/models/tr8n/total_language_metric_spec.rb +5 -0
- data/spec/models/tr8n/translation_domain_spec.rb +5 -0
- data/spec/models/tr8n/translation_key_comment_spec.rb +5 -0
- data/spec/models/tr8n/translation_key_lock_spec.rb +5 -0
- data/spec/models/tr8n/translation_key_source_spec.rb +5 -0
- data/spec/models/tr8n/translation_key_spec.rb +118 -0
- data/spec/models/tr8n/translation_source_language_spec.rb +5 -0
- data/spec/models/tr8n/translation_source_spec.rb +5 -0
- data/spec/models/tr8n/translation_spec.rb +5 -0
- data/spec/models/tr8n/translation_vote_spec.rb +5 -0
- data/spec/models/tr8n/translator_following_spec.rb +5 -0
- data/spec/models/tr8n/translator_log_spec.rb +5 -0
- data/spec/models/tr8n/translator_metric_spec.rb +5 -0
- data/spec/models/tr8n/translator_report_spec.rb +5 -0
- data/spec/models/tr8n/translator_spec.rb +140 -0
- data/spec/spec_helper.rb +26 -27
- data/tr8n.gemspec +3 -1
- metadata +173 -50
- data/local/tr8n_server/db/migrate/20110930041150_create_tr8n_tables.rb +0 -372
- data/spec/fake_app.rb +0 -50
- data/spec/lib/data_token_spec.rb +0 -26
- data/spec/lib/transform_token_spec.rb +0 -22
- data/spec/models/translation_key_spec.rb +0 -63
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::ForumController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "logged in user" do
|
13
|
+
it "should redirect the guest user to homepage" do
|
14
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
15
|
+
request.session[:user_id] = @user.id
|
16
|
+
|
17
|
+
get :index
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::GlossaryController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "logged in user" do
|
13
|
+
it "should redirect the guest user to homepage" do
|
14
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
15
|
+
request.session[:user_id] = @user.id
|
16
|
+
|
17
|
+
get :index
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::HelpController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "logged in user" do
|
13
|
+
it "should redirect the guest user to homepage" do
|
14
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
15
|
+
request.session[:user_id] = @user.id
|
16
|
+
|
17
|
+
get :index
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::LanguageCasesController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::PhrasesController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "logged in user" do
|
13
|
+
it "should redirect the guest user to homepage" do
|
14
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
15
|
+
request.session[:user_id] = @user.id
|
16
|
+
|
17
|
+
get :index
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::TranslationsController do
|
4
|
+
|
5
|
+
|
6
|
+
describe "guest user" do
|
7
|
+
it "should be redirect to homepage" do
|
8
|
+
get :index
|
9
|
+
response.should redirect_to('/')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "logged in user" do
|
14
|
+
it "should redirect the guest user to homepage" do
|
15
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
16
|
+
request.session[:user_id] = @user.id
|
17
|
+
|
18
|
+
get :index
|
19
|
+
response.should be_success
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::TranslatorController do
|
4
|
+
|
5
|
+
describe "guest user" do
|
6
|
+
it "should be redirect to homepage" do
|
7
|
+
get :index
|
8
|
+
response.should redirect_to('/')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "logged in user" do
|
13
|
+
it "should redirect the guest user to homepage" do
|
14
|
+
@user = User.create(:first_name => "Mike", :gender => "male")
|
15
|
+
request.session[:user_id] = @user.id
|
16
|
+
|
17
|
+
get :index
|
18
|
+
response.should be_success
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::TokenizedLabel do
|
4
|
+
describe 'registering tokens' do
|
5
|
+
|
6
|
+
context "registering correct tokens" do
|
7
|
+
it "should register all tokens" do
|
8
|
+
str = 'Dear {user:gender}, you have [bold: {count:number|| new message}] in your mailbox!'
|
9
|
+
|
10
|
+
label = Tr8n::TokenizedLabel.new(str)
|
11
|
+
label.label.should eq(str)
|
12
|
+
|
13
|
+
label.tokens?.should be_true
|
14
|
+
label.data_tokens?.should be_true
|
15
|
+
label.decoration_tokens?.should be_true
|
16
|
+
|
17
|
+
label.data_tokens.count.should eq(2)
|
18
|
+
label.decoration_tokens.count.should eq(1)
|
19
|
+
|
20
|
+
label.tokens.count.should eq(3)
|
21
|
+
|
22
|
+
label.sanitized_tokens_hash.keys.should eq(["{user}", "{count}", "[bold: ]"])
|
23
|
+
|
24
|
+
label.translation_tokens?.should be_true
|
25
|
+
label.translation_tokens.count.should eq(3)
|
26
|
+
|
27
|
+
san_str = "Dear {user}, you have [bold: {count} new messages] in your mailbox!"
|
28
|
+
label.sanitized_label.should eq(san_str)
|
29
|
+
|
30
|
+
label.suggestion_tokens.should eq(["{user}", "{count}", "bold"])
|
31
|
+
|
32
|
+
label.words.should eq(["Dear", "User", "Have", "Bold", "Count", "Messages", "Your", "Mailbox"])
|
33
|
+
|
34
|
+
label.tokens.each do |token|
|
35
|
+
label.allowed_token?(token).should be_true
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::Tokens::DataToken do
|
4
|
+
describe 'registering tokens' do
|
5
|
+
|
6
|
+
context "incorrect tokens" do
|
7
|
+
it "should not be registered" do
|
8
|
+
[
|
9
|
+
'Hello {user:}',
|
10
|
+
'Hello {} and welcome',
|
11
|
+
'Hello {user::}'
|
12
|
+
].each do |label|
|
13
|
+
Tr8n::Tokens::DataToken.parse(label).count.should eq(0)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "correct tokens" do
|
19
|
+
it "should be registered" do
|
20
|
+
[
|
21
|
+
'Hello {user}',
|
22
|
+
'You have {count} messages',
|
23
|
+
'You have {count:number}',
|
24
|
+
'Hello {user:gender}',
|
25
|
+
'Today is {today:date}',
|
26
|
+
'Hello {user_list:list}',
|
27
|
+
'{long_token_name} like this message',
|
28
|
+
'Hello {user1}',
|
29
|
+
'Hello {user1:user}',
|
30
|
+
'Hello {user1:user::pos} and welcome',
|
31
|
+
].each do |label|
|
32
|
+
tokens = Tr8n::Tokens::DataToken.parse(label)
|
33
|
+
tokens.count.should eq(1)
|
34
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::DataToken")
|
35
|
+
end
|
36
|
+
|
37
|
+
[
|
38
|
+
'{user} has {count} messages',
|
39
|
+
'{user1:user} has {count:number} messages'
|
40
|
+
].each do |label|
|
41
|
+
tokens = Tr8n::Tokens::DataToken.parse(label)
|
42
|
+
tokens.count.should eq(2)
|
43
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::DataToken")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::Tokens::DecorationToken do
|
4
|
+
describe 'identifying tokens' do
|
5
|
+
|
6
|
+
context 'incorrect tokens' do
|
7
|
+
it 'should not be registered' do
|
8
|
+
[
|
9
|
+
'Hello {bold}',
|
10
|
+
'Hello [bold}',
|
11
|
+
'Hello [bold]',
|
12
|
+
'Hello [[bold]',
|
13
|
+
'Hello [[bold]]',
|
14
|
+
'Hello [[bold]]',
|
15
|
+
'Hello [bold:]',
|
16
|
+
'You have [bold {count}] messages',
|
17
|
+
].each do |label|
|
18
|
+
Tr8n::Tokens::DecorationToken.parse(label).should be_empty
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'correct tokens' do
|
24
|
+
it 'should be registered' do
|
25
|
+
[
|
26
|
+
'Hello [bold: Mike]',
|
27
|
+
'Hello [link: test]',
|
28
|
+
'Hello [a: test]',
|
29
|
+
'Hello [1: test]',
|
30
|
+
'You have [bold: {count}] messages',
|
31
|
+
'You have [bold: {count|| message}]',
|
32
|
+
'[link: {count} {_messages}]',
|
33
|
+
'[link: {count||message}]',
|
34
|
+
'[link: {count||person, people}]',
|
35
|
+
'[link: {user.name}]'
|
36
|
+
].each do |label|
|
37
|
+
Tr8n::Tokens::DecorationToken.parse(label).count.should eq(1)
|
38
|
+
end
|
39
|
+
|
40
|
+
[
|
41
|
+
'You have [link1: {msg_count|| message}] and [link2: {alert_count|| alert}]',
|
42
|
+
].each do |label|
|
43
|
+
Tr8n::Tokens::DecorationToken.parse(label).count.should eq(2)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::Tokens::HiddenToken do
|
4
|
+
describe 'registering tokens' do
|
5
|
+
|
6
|
+
context "incorrect tokens" do
|
7
|
+
it "should not be registered" do
|
8
|
+
[
|
9
|
+
'Hello {user:}',
|
10
|
+
'Hello {} and welcome',
|
11
|
+
'Hello {user::}',
|
12
|
+
'You have {count} messages',
|
13
|
+
'You have {count:number}',
|
14
|
+
'Hello {user:gender}',
|
15
|
+
'Today is {today:date}',
|
16
|
+
'Hello {user_list:list}',
|
17
|
+
'{long_token_name} like this message',
|
18
|
+
'Hello {user1}',
|
19
|
+
'Hello {user1:user}',
|
20
|
+
'Hello {user1:user::pos} and welcome',
|
21
|
+
'{user:gender|his,her}',
|
22
|
+
'{count:number|message}',
|
23
|
+
'{count:number||message}',
|
24
|
+
'Dear {user:gender}, you have {count:number||message}',
|
25
|
+
'{count | message}',
|
26
|
+
'{count | message, messages}',
|
27
|
+
'{count:number | message, messages}',
|
28
|
+
'{user:gender | he, she, he/she}',
|
29
|
+
'{now:date | did, does, will do}',
|
30
|
+
'{users:list | all male, all female, mixed genders}',
|
31
|
+
'{count || message, messages}'
|
32
|
+
].each do |label|
|
33
|
+
Tr8n::Tokens::HiddenToken.parse(label).count.should eq(0)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "correct tokens" do
|
39
|
+
it "should be registered" do
|
40
|
+
[
|
41
|
+
'{_he_she}',
|
42
|
+
'{_posted__items}',
|
43
|
+
'Hello {user.name} you have {count} {_posted__items}'
|
44
|
+
].each do |label|
|
45
|
+
tokens = Tr8n::Tokens::HiddenToken.parse(label)
|
46
|
+
tokens.count.should eq(1)
|
47
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::HiddenToken")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::Tokens::MethodToken do
|
4
|
+
describe 'registering tokens' do
|
5
|
+
|
6
|
+
context "incorrect tokens" do
|
7
|
+
it "should not be registered" do
|
8
|
+
[
|
9
|
+
'Hello {user:}',
|
10
|
+
'Hello {} and welcome',
|
11
|
+
'Hello {user::}',
|
12
|
+
'You have {count} messages',
|
13
|
+
'You have {count:number}',
|
14
|
+
'Hello {user:gender}',
|
15
|
+
'Today is {today:date}',
|
16
|
+
'Hello {user_list:list}',
|
17
|
+
'{long_token_name} like this message',
|
18
|
+
'Hello {user1}',
|
19
|
+
'Hello {user1:user}',
|
20
|
+
'Hello {user1:user::pos} and welcome',
|
21
|
+
'{user:gender|his,her}',
|
22
|
+
'{count:number|message}',
|
23
|
+
'{count:number||message}',
|
24
|
+
'Dear {user:gender}, you have {count:number||message}',
|
25
|
+
'{count | message}',
|
26
|
+
'{count | message, messages}',
|
27
|
+
'{count:number | message, messages}',
|
28
|
+
'{user:gender | he, she, he/she}',
|
29
|
+
'{now:date | did, does, will do}',
|
30
|
+
'{users:list | all male, all female, mixed genders}',
|
31
|
+
'{count || message, messages}'
|
32
|
+
].each do |label|
|
33
|
+
Tr8n::Tokens::MethodToken.parse(label).count.should eq(0)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "correct tokens" do
|
39
|
+
it "should be registered" do
|
40
|
+
[
|
41
|
+
'Hello {user.name}',
|
42
|
+
'{user.name}',
|
43
|
+
'{user.name:gender}',
|
44
|
+
].each do |label|
|
45
|
+
tokens = Tr8n::Tokens::MethodToken.parse(label)
|
46
|
+
tokens.count.should eq(1)
|
47
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::MethodToken")
|
48
|
+
end
|
49
|
+
|
50
|
+
[
|
51
|
+
'Hello {user.first_name} [bold: {user.last_name}]',
|
52
|
+
].each do |label|
|
53
|
+
tokens = Tr8n::Tokens::MethodToken.parse(label)
|
54
|
+
tokens.count.should eq(2)
|
55
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::MethodToken")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
describe Tr8n::Tokens::TransformToken do
|
4
|
+
describe 'registering transform tokens' do
|
5
|
+
|
6
|
+
context 'incorrect tokens' do
|
7
|
+
it 'should not be registered' do
|
8
|
+
[
|
9
|
+
'Hello {user}',
|
10
|
+
'Hello {user:}',
|
11
|
+
'Hello {user::}'
|
12
|
+
].each do |label|
|
13
|
+
Tr8n::Tokens::TransformToken.parse(label).should be_empty
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'correct tokens' do
|
19
|
+
it 'should be registered' do
|
20
|
+
[
|
21
|
+
'{user:gender|his,her}',
|
22
|
+
'{count:number|message}',
|
23
|
+
'{count:number||message}',
|
24
|
+
'Dear {user:gender}, you have {count:number||message}',
|
25
|
+
'{count | message}',
|
26
|
+
'{count | message, messages}',
|
27
|
+
'{count:number | message, messages}',
|
28
|
+
'{user:gender | he, she, he/she}',
|
29
|
+
'{now:date | did, does, will do}',
|
30
|
+
'{users:list | all male, all female, mixed genders}',
|
31
|
+
'{count || message, messages}'
|
32
|
+
].each do |label|
|
33
|
+
tokens = Tr8n::Tokens::TransformToken.parse(label)
|
34
|
+
tokens.count.should eq(1)
|
35
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::TransformToken")
|
36
|
+
end
|
37
|
+
|
38
|
+
[
|
39
|
+
'{user:gender|He, She} received {count:number||message}',
|
40
|
+
'{user:gender | He, She } received {count:number || message, messages }'
|
41
|
+
].each do |label|
|
42
|
+
tokens = Tr8n::Tokens::TransformToken.parse(label)
|
43
|
+
tokens.count.should eq(2)
|
44
|
+
tokens.first.class.name.should eq("Tr8n::Tokens::TransformToken")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|