tr8n_core 4.0.6 → 4.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/lib/tr8n/api_client.rb +8 -0
- data/lib/tr8n/application.rb +8 -0
- data/lib/tr8n/base.rb +8 -0
- data/lib/tr8n/cache.rb +8 -0
- data/lib/tr8n/cache_adapters/cdb.rb +8 -0
- data/lib/tr8n/cache_adapters/file.rb +8 -0
- data/lib/tr8n/cache_adapters/memcache.rb +8 -0
- data/lib/tr8n/cache_adapters/redis.rb +9 -0
- data/lib/tr8n/component.rb +8 -0
- data/lib/tr8n/config.rb +8 -0
- data/lib/tr8n/decorators/base.rb +8 -0
- data/lib/tr8n/decorators/default.rb +8 -0
- data/lib/tr8n/decorators/html.rb +8 -0
- data/lib/tr8n/exception.rb +8 -0
- data/lib/tr8n/language.rb +8 -0
- data/lib/tr8n/language_case.rb +8 -0
- data/lib/tr8n/language_case_rule.rb +8 -0
- data/lib/tr8n/language_context.rb +8 -1
- data/lib/tr8n/language_context_rule.rb +8 -0
- data/lib/tr8n/logger.rb +8 -0
- data/lib/tr8n/rules_engine/evaluator.rb +8 -0
- data/lib/tr8n/rules_engine/parser.rb +8 -0
- data/lib/tr8n/session.rb +8 -0
- data/lib/tr8n/source.rb +8 -0
- data/lib/tr8n/tokens/data.rb +20 -14
- data/lib/tr8n/tokens/data_tokenizer.rb +8 -0
- data/lib/tr8n/tokens/decoration_tokenizer.rb +11 -22
- data/lib/tr8n/tokens/hidden.rb +8 -0
- data/lib/tr8n/tokens/method.rb +8 -0
- data/lib/tr8n/tokens/transform.rb +8 -0
- data/lib/tr8n/translation.rb +8 -0
- data/lib/tr8n/translation_key.rb +8 -0
- data/lib/tr8n/translator.rb +8 -0
- data/lib/tr8n/utils.rb +8 -0
- data/lib/tr8n_core/ext/array.rb +8 -0
- data/lib/tr8n_core/ext/date.rb +8 -0
- data/lib/tr8n_core/ext/fixnum.rb +8 -0
- data/lib/tr8n_core/ext/hash.rb +8 -0
- data/lib/tr8n_core/ext/string.rb +8 -0
- data/lib/tr8n_core/ext/time.rb +8 -0
- data/lib/tr8n_core/generators/cache/base.rb +8 -0
- data/lib/tr8n_core/generators/cache/cdb.rb +8 -0
- data/lib/tr8n_core/generators/cache/file.rb +8 -0
- data/lib/tr8n_core/version.rb +9 -2
- data/lib/tr8n_core.rb +9 -0
- data/spec/application_spec.rb +2 -2
- data/spec/cache/adapters/file_spec.rb +1 -1
- data/spec/cache/generators/file_generator_spec.rb +9 -9
- data/spec/config_spec.rb +3 -3
- data/spec/decorator_spec.rb +2 -0
- data/spec/ext/array_spec.rb +1 -1
- data/spec/ext/hash_spec.rb +1 -1
- data/spec/ext/string_spec.rb +1 -1
- data/spec/language_case_rule_spec.rb +8 -8
- data/spec/language_context_rule_spec.rb +16 -14
- data/spec/language_context_spec.rb +10 -8
- data/spec/language_spec.rb +1 -1
- data/spec/rules_engine/evaluator_spec.rb +52 -50
- data/spec/rules_engine/parser_spec.rb +2 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/tokens/hidden_spec.rb +1 -1
- data/spec/tokens/method_spec.rb +4 -4
- data/spec/tokens/transform_spec.rb +4 -4
- data/spec/translation_key_spec.rb +1 -1
- data/spec/translation_spec.rb +1 -1
- metadata +3 -3
data/lib/tr8n/tokens/hidden.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n/tokens/method.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n/translation.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n/translation_key.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n/translator.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n/utils.rb
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
#--
|
3
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
4
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
5
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
6
14
|
# a copy of this software and associated documentation files (the
|
7
15
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/array.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/date.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/fixnum.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/hash.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/string.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/ext/time.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
data/lib/tr8n_core/version.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
#--
|
2
2
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
3
|
#
|
4
|
+
# _______ _ _ _ ______ _
|
5
|
+
# |__ __| | | | | (_) | ____| | |
|
6
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
7
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
8
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
9
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
10
|
+
# __/ |
|
11
|
+
# |___/
|
4
12
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
13
|
# a copy of this software and associated documentation files (the
|
6
14
|
# "Software"), to deal in the Software without restriction, including
|
@@ -21,7 +29,6 @@
|
|
21
29
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
30
|
#++
|
23
31
|
|
24
|
-
|
25
32
|
module Tr8nCore
|
26
|
-
VERSION = "4.0.
|
33
|
+
VERSION = "4.0.7"
|
27
34
|
end
|
data/lib/tr8n_core.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
#--
|
2
3
|
# Copyright (c) 2014 Michael Berkovich, TranslationExchange.com
|
3
4
|
#
|
5
|
+
# _______ _ _ _ ______ _
|
6
|
+
# |__ __| | | | | (_) | ____| | |
|
7
|
+
# | |_ __ __ _ _ __ ___| | __ _| |_ _ ___ _ __ | |__ __ _____| |__ __ _ _ __ __ _ ___
|
8
|
+
# | | '__/ _` | '_ \/ __| |/ _` | __| |/ _ \| '_ \| __| \ \/ / __| '_ \ / _` | '_ \ / _` |/ _ \
|
9
|
+
# | | | | (_| | | | \__ \ | (_| | |_| | (_) | | | | |____ > < (__| | | | (_| | | | | (_| | __/
|
10
|
+
# |_|_| \__,_|_| |_|___/_|\__,_|\__|_|\___/|_| |_|______/_/\_\___|_| |_|\__,_|_| |_|\__, |\___|
|
11
|
+
# __/ |
|
12
|
+
# |___/
|
4
13
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
14
|
# a copy of this software and associated documentation files (the
|
6
15
|
# "Software"), to deal in the Software without restriction, including
|
data/spec/application_spec.rb
CHANGED
@@ -24,8 +24,8 @@ describe Tr8n::Application do
|
|
24
24
|
expect(@app.default_data_token('nbsp')).to eq(" ")
|
25
25
|
expect(@app.default_decoration_token('strong')).to eq("<strong>{$0}</strong>")
|
26
26
|
|
27
|
-
expect(@app.feature_enabled?(:language_cases)).to
|
28
|
-
expect(@app.feature_enabled?(:language_flags)).to
|
27
|
+
expect(@app.feature_enabled?(:language_cases)).to be_truthy
|
28
|
+
expect(@app.feature_enabled?(:language_flags)).to be_truthy
|
29
29
|
end
|
30
30
|
|
31
31
|
it "loads application language" do
|
@@ -13,15 +13,15 @@ describe Tr8nCore::Generators::Cache::File do
|
|
13
13
|
:path => "./cache"
|
14
14
|
}
|
15
15
|
|
16
|
-
g = Tr8nCore::Generators::Cache::File.new
|
17
|
-
g.started_at = Time.new(2014, 01, 01, 10, 11, 12)
|
18
|
-
expect(g.cache_path).to eq("./cache/files/tr8n_default_2014_01_01_10_11_12")
|
19
|
-
expect(g.symlink_path).to eq("./cache/files/current")
|
20
|
-
|
21
|
-
expect(g.file_path("test_key")).to eq("./cache/files/tr8n_default_2014_01_01_10_11_12/test_key.json")
|
22
|
-
|
23
|
-
g.cache("test_key", {"a" => "b"})
|
24
|
-
expect(File.exists?(g.file_path("test_key"))).to
|
16
|
+
#g = Tr8nCore::Generators::Cache::File.new
|
17
|
+
#g.started_at = Time.new(2014, 01, 01, 10, 11, 12)
|
18
|
+
#expect(g.cache_path).to eq("./cache/files/tr8n_default_2014_01_01_10_11_12")
|
19
|
+
#expect(g.symlink_path).to eq("./cache/files/current")
|
20
|
+
#
|
21
|
+
#expect(g.file_path("test_key")).to eq("./cache/files/tr8n_default_2014_01_01_10_11_12/test_key.json")
|
22
|
+
#
|
23
|
+
#g.cache("test_key", {"a" => "b"})
|
24
|
+
#expect(File.exists?(g.file_path("test_key"))).to be_truthy
|
25
25
|
|
26
26
|
end
|
27
27
|
|
data/spec/config_spec.rb
CHANGED
@@ -5,10 +5,10 @@ require 'spec_helper'
|
|
5
5
|
describe Tr8n::Config do
|
6
6
|
describe "loading defaults" do
|
7
7
|
it "should load correct values" do
|
8
|
-
expect(Tr8n.config.logger[:enabled]).to
|
9
|
-
expect(Tr8n.config.enabled?).to
|
8
|
+
expect(Tr8n.config.logger[:enabled]).to be_falsey
|
9
|
+
expect(Tr8n.config.enabled?).to be_truthy
|
10
10
|
expect(Tr8n.config.default_locale).to eq("en-US")
|
11
|
-
expect(Tr8n.config.cache[:enabled]).to
|
11
|
+
expect(Tr8n.config.cache[:enabled]).to be_falsey
|
12
12
|
expect(Tr8n.config.logger[:path]).to eq("./log/tr8n.log")
|
13
13
|
expect(Tr8n.config.cache[:adapter]).to eq("memcache")
|
14
14
|
end
|
data/spec/decorator_spec.rb
CHANGED
data/spec/ext/array_spec.rb
CHANGED
data/spec/ext/hash_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
|
|
5
5
|
describe Hash do
|
6
6
|
it "must provide correct attributes" do
|
7
7
|
h = {}.tr8n_translated
|
8
|
-
expect(h.tr8n_translated?).to
|
8
|
+
expect(h.tr8n_translated?).to be_truthy
|
9
9
|
|
10
10
|
h1 = {"a" => 100, "b" => 200, "c" => {"c1" => 12, "c2" => 14}}
|
11
11
|
h2 = {"b" => 254, "c" => 300, "c" => {"c1" => 16, "c3" => 94}}
|
data/spec/ext/string_spec.rb
CHANGED
@@ -16,10 +16,10 @@ describe Tr8n::LanguageCaseRule do
|
|
16
16
|
:operations => "(append \"'\" @value)"
|
17
17
|
)
|
18
18
|
|
19
|
-
expect(@rule.evaluate("Michael")).to
|
20
|
-
expect(@rule.evaluate("Anna")).to
|
19
|
+
expect(@rule.evaluate("Michael")).to be_falsey
|
20
|
+
expect(@rule.evaluate("Anna")).to be_falsey
|
21
21
|
|
22
|
-
expect(@rule.evaluate("friends")).to
|
22
|
+
expect(@rule.evaluate("friends")).to be_truthy
|
23
23
|
expect(@rule.apply("friends")).to eq("friends'")
|
24
24
|
|
25
25
|
@rule = Tr8n::LanguageCaseRule.new(
|
@@ -27,21 +27,21 @@ describe Tr8n::LanguageCaseRule do
|
|
27
27
|
:operations => "(append \"'s\" @value)"
|
28
28
|
)
|
29
29
|
|
30
|
-
expect(@rule.evaluate("Michael")).to
|
30
|
+
expect(@rule.evaluate("Michael")).to be_truthy
|
31
31
|
expect(@rule.apply("Michael")).to eq("Michael's")
|
32
32
|
|
33
|
-
expect(@rule.evaluate("Anna")).to
|
33
|
+
expect(@rule.evaluate("Anna")).to be_truthy
|
34
34
|
expect(@rule.apply("Anna")).to eq("Anna's")
|
35
35
|
|
36
|
-
expect(@rule.evaluate("friends")).to
|
36
|
+
expect(@rule.evaluate("friends")).to be_falsey
|
37
37
|
|
38
38
|
@rule = Tr8n::LanguageCaseRule.new(
|
39
39
|
:conditions => "(= '1' @value))",
|
40
40
|
:operations => "(quote 'first')"
|
41
41
|
)
|
42
42
|
|
43
|
-
expect(@rule.evaluate('2')).to
|
44
|
-
expect(@rule.evaluate('1')).to
|
43
|
+
expect(@rule.evaluate('2')).to be_falsey
|
44
|
+
expect(@rule.evaluate('1')).to be_truthy
|
45
45
|
expect(@rule.apply('1')).to eq("first")
|
46
46
|
|
47
47
|
@rule = Tr8n::LanguageCaseRule.new(
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Tr8n::LanguageContextRule do
|
@@ -11,20 +13,20 @@ describe Tr8n::LanguageContextRule do
|
|
11
13
|
describe "finding fallback rules" do
|
12
14
|
it "should return fallback rule" do
|
13
15
|
rule = Tr8n::LanguageContextRule.new(:keyword => "one", :conditions => "(= 1 @n)", :examples => "1")
|
14
|
-
expect(rule.fallback?).to
|
16
|
+
expect(rule.fallback?).to be_falsey
|
15
17
|
|
16
18
|
rule = Tr8n::LanguageContextRule.new(:keyword => "other", :examples => "0, 2-999; 1.2, 2.07...")
|
17
|
-
expect(rule.fallback?).to
|
19
|
+
expect(rule.fallback?).to be_truthy
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
23
|
describe "evaluating rules" do
|
22
24
|
it "should return correct results" do
|
23
25
|
rule = Tr8n::LanguageContextRule.new(:keyword => "one", :conditions => "(= 1 @n)", :examples => "1")
|
24
|
-
expect(rule.evaluate).to
|
25
|
-
expect(rule.evaluate({"@n" => 1})).to
|
26
|
-
expect(rule.evaluate({"@n" => 2})).to
|
27
|
-
expect(rule.evaluate({"@n" => 0})).to
|
26
|
+
expect(rule.evaluate).to be_falsey
|
27
|
+
expect(rule.evaluate({"@n" => 1})).to be_truthy
|
28
|
+
expect(rule.evaluate({"@n" => 2})).to be_falsey
|
29
|
+
expect(rule.evaluate({"@n" => 0})).to be_falsey
|
28
30
|
|
29
31
|
one = Tr8n::LanguageContextRule.new(:keyword => "one", :conditions => "(&& (= 1 (mod @n 10)) (!= 11 (mod @n 100)))", :description => "{n} mod 10 is 1 and {n} mod 100 is not 11", :examples => "1, 21, 31, 41, 51, 61...")
|
30
32
|
few = Tr8n::LanguageContextRule.new(:keyword => "few", :conditions => "(&& (in '2..4' (mod @n 10)) (not (in '12..14' (mod @n 100))))", :description => "{n} mod 10 in 2..4 and {n} mod 100 not in 12..14", :examples => "2-4, 22-24, 32-34...")
|
@@ -37,7 +39,7 @@ describe Tr8n::LanguageContextRule do
|
|
37
39
|
}.each do |vals, rule|
|
38
40
|
vals.each do |val|
|
39
41
|
vars = {"@n" => val}
|
40
|
-
expect(rule.evaluate(vars)).to
|
42
|
+
expect(rule.evaluate(vars)).to be_truthy
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -48,7 +50,7 @@ describe Tr8n::LanguageContextRule do
|
|
48
50
|
}.each do |vals, rule|
|
49
51
|
vals.each do |val|
|
50
52
|
vars = {"@n" => val}
|
51
|
-
expect(rule.evaluate(vars)).to
|
53
|
+
expect(rule.evaluate(vars)).to be_falsey
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -57,16 +59,16 @@ describe Tr8n::LanguageContextRule do
|
|
57
59
|
one_unknown = Tr8n::LanguageContextRule.new(:keyword => "one_unknown", :conditions => "(&& (= 1 (count @genders)) (all @genders 'unknown'))", :description => "List contains one user with unknown gender")
|
58
60
|
many = Tr8n::LanguageContextRule.new(:keyword => "many", :conditions => "(> (count @genders) 1)", :description => "List contains two or more users")
|
59
61
|
|
60
|
-
expect(one_male.evaluate({"@genders" => ["male"]})).to
|
61
|
-
expect(one_male.evaluate({"@genders" => ["male", "male"]})).to
|
62
|
+
expect(one_male.evaluate({"@genders" => ["male"]})).to be_truthy
|
63
|
+
expect(one_male.evaluate({"@genders" => ["male", "male"]})).to be_falsey
|
62
64
|
|
63
|
-
expect(one_female.evaluate({"@genders" => ["female"]})).to
|
64
|
-
expect(many.evaluate({"@genders" => ["female", "male"]})).to
|
65
|
+
expect(one_female.evaluate({"@genders" => ["female"]})).to be_truthy
|
66
|
+
expect(many.evaluate({"@genders" => ["female", "male"]})).to be_truthy
|
65
67
|
|
66
|
-
expect(one_unknown.evaluate({"@genders" => ["unknown"]})).to
|
68
|
+
expect(one_unknown.evaluate({"@genders" => ["unknown"]})).to be_truthy
|
67
69
|
|
68
70
|
many_male = Tr8n::LanguageContextRule.new(:keyword => "one", :conditions => "(&& (> (count @genders) 1) (all @genders 'male'))", :description => "List contains at least two users, all male")
|
69
|
-
expect(many_male.evaluate({"@genders" => ["male", "male"]})).to
|
71
|
+
expect(many_male.evaluate({"@genders" => ["male", "male"]})).to be_truthy
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Tr8n::LanguageContext do
|
@@ -34,14 +36,14 @@ describe Tr8n::LanguageContext do
|
|
34
36
|
)
|
35
37
|
|
36
38
|
expect(@context.token_expression).to eq(/.*(count|num|age|hours|minutes|years|seconds)(\d)*$/)
|
37
|
-
expect(@context.applies_to_token?("num")).to
|
38
|
-
expect(@context.applies_to_token?("num1")).to
|
39
|
-
expect(@context.applies_to_token?("profile_num1")).to
|
40
|
-
expect(@context.applies_to_token?("profile_num21")).to
|
41
|
-
expect(@context.applies_to_token?("profile")).to
|
42
|
-
expect(@context.applies_to_token?("num_years")).to
|
43
|
-
expect(@context.applies_to_token?("count1")).to
|
44
|
-
expect(@context.applies_to_token?("count2")).to
|
39
|
+
expect(@context.applies_to_token?("num")).to be_truthy
|
40
|
+
expect(@context.applies_to_token?("num1")).to be_truthy
|
41
|
+
expect(@context.applies_to_token?("profile_num1")).to be_truthy
|
42
|
+
expect(@context.applies_to_token?("profile_num21")).to be_truthy
|
43
|
+
expect(@context.applies_to_token?("profile")).to be_falsey
|
44
|
+
expect(@context.applies_to_token?("num_years")).to be_truthy
|
45
|
+
expect(@context.applies_to_token?("count1")).to be_truthy
|
46
|
+
expect(@context.applies_to_token?("count2")).to be_truthy
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
data/spec/language_spec.rb
CHANGED