tr8n 3.1.8 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/.gitignore +2 -1
  2. data/.rspec +1 -0
  3. data/.rvmrc +1 -1
  4. data/.watchr +18 -0
  5. data/Gemfile.lock +16 -10
  6. data/app/assets/images/tr8n/minus_node.png +0 -0
  7. data/app/assets/images/tr8n/pixel.gif +0 -0
  8. data/app/assets/images/tr8n/plus_node.png +0 -0
  9. data/app/assets/javascripts/tr8n/tr8n.js +1 -0
  10. data/app/assets/javascripts/tr8n/tr8n_client_sdk.js +581 -425
  11. data/app/assets/stylesheets/tr8n/layout.css.scss +1 -1
  12. data/app/assets/stylesheets/tr8n/tr8n.css.scss +20 -0
  13. data/app/controllers/tr8n/admin/base_controller.rb +4 -1
  14. data/app/controllers/tr8n/admin/clientsdk_controller.rb +1 -1
  15. data/app/controllers/tr8n/admin/metrics_controller.rb +30 -0
  16. data/app/controllers/tr8n/api/v1/base_controller.rb +12 -0
  17. data/app/controllers/tr8n/api/v1/language_controller.rb +7 -5
  18. data/app/controllers/tr8n/awards_controller.rb +1 -1
  19. data/app/controllers/tr8n/base_controller.rb +12 -6
  20. data/app/controllers/tr8n/dashboard_controller.rb +1 -1
  21. data/app/controllers/tr8n/forum_controller.rb +1 -1
  22. data/app/controllers/tr8n/glossary_controller.rb +1 -1
  23. data/app/controllers/tr8n/help_controller.rb +1 -1
  24. data/app/controllers/tr8n/phrases_controller.rb +1 -1
  25. data/app/controllers/tr8n/translator_controller.rb +8 -0
  26. data/app/helpers/tr8n/admin/base_helper.rb +1 -1
  27. data/app/helpers/tr8n/base_helper.rb +1 -1
  28. data/app/helpers/tr8n/dashboard_helper.rb +1 -1
  29. data/app/models/tr8n/base_filter.rb +1 -1
  30. data/app/models/tr8n/daily_language_metric.rb +1 -1
  31. data/app/models/tr8n/date_rule.rb +1 -1
  32. data/app/models/tr8n/gender_list_rule.rb +1 -1
  33. data/app/models/tr8n/gender_rule.rb +1 -1
  34. data/app/models/tr8n/glossary.rb +1 -1
  35. data/app/models/tr8n/glossary_filter.rb +1 -1
  36. data/app/models/tr8n/integration/ru/russian_gender_list_rule.rb +1 -1
  37. data/app/models/tr8n/integration/ru/russian_numeric_rule.rb +1 -1
  38. data/app/models/tr8n/ip_location.rb +1 -1
  39. data/app/models/tr8n/ip_location_filter.rb +1 -1
  40. data/app/models/tr8n/language.rb +19 -7
  41. data/app/models/tr8n/language_case.rb +1 -1
  42. data/app/models/tr8n/language_case_filter.rb +1 -1
  43. data/app/models/tr8n/language_case_rule.rb +1 -1
  44. data/app/models/tr8n/language_case_rule_filter.rb +1 -1
  45. data/app/models/tr8n/language_case_value_map.rb +1 -1
  46. data/app/models/tr8n/language_case_value_map_filter.rb +1 -1
  47. data/app/models/tr8n/language_filter.rb +1 -1
  48. data/app/models/tr8n/language_forum_abuse_report.rb +1 -1
  49. data/app/models/tr8n/language_forum_abuse_report_filter.rb +1 -1
  50. data/app/models/tr8n/language_forum_message.rb +1 -1
  51. data/app/models/tr8n/language_forum_message_filter.rb +1 -1
  52. data/app/models/tr8n/language_forum_topic.rb +1 -1
  53. data/app/models/tr8n/language_forum_topic_filter.rb +1 -1
  54. data/app/models/tr8n/language_metric.rb +1 -1
  55. data/app/models/tr8n/language_metric_filter.rb +1 -1
  56. data/app/models/tr8n/language_rule.rb +1 -1
  57. data/app/models/tr8n/language_rule_filter.rb +1 -1
  58. data/app/models/tr8n/language_user.rb +1 -1
  59. data/app/models/tr8n/language_user_filter.rb +1 -1
  60. data/app/models/tr8n/list_rule.rb +1 -1
  61. data/app/models/tr8n/monthly_language_metric.rb +1 -1
  62. data/app/models/tr8n/numeric_rule.rb +35 -28
  63. data/app/models/tr8n/sync_log.rb +1 -1
  64. data/app/models/tr8n/sync_log_filter.rb +1 -1
  65. data/app/models/tr8n/total_language_metric.rb +1 -1
  66. data/app/models/tr8n/translation.rb +4 -3
  67. data/app/models/tr8n/translation_domain.rb +11 -3
  68. data/app/models/tr8n/translation_domain_filter.rb +1 -1
  69. data/app/models/tr8n/translation_filter.rb +1 -1
  70. data/app/models/tr8n/translation_key.rb +73 -36
  71. data/app/models/tr8n/translation_key_comment.rb +1 -1
  72. data/app/models/tr8n/translation_key_comment_filter.rb +1 -1
  73. data/app/models/tr8n/translation_key_filter.rb +1 -1
  74. data/app/models/tr8n/translation_key_lock.rb +1 -1
  75. data/app/models/tr8n/translation_key_lock_filter.rb +1 -1
  76. data/app/models/tr8n/translation_key_source.rb +16 -5
  77. data/app/models/tr8n/translation_key_source_filter.rb +1 -1
  78. data/app/models/tr8n/translation_source.rb +12 -4
  79. data/app/models/tr8n/translation_source_filter.rb +1 -1
  80. data/app/models/tr8n/translation_source_language.rb +1 -1
  81. data/app/models/tr8n/translation_vote.rb +1 -1
  82. data/app/models/tr8n/translation_vote_filter.rb +1 -1
  83. data/app/models/tr8n/translator.rb +21 -5
  84. data/app/models/tr8n/translator_filter.rb +1 -1
  85. data/app/models/tr8n/translator_following.rb +1 -1
  86. data/app/models/tr8n/translator_following_filter.rb +1 -1
  87. data/app/models/tr8n/translator_log.rb +3 -3
  88. data/app/models/tr8n/translator_log_filter.rb +1 -1
  89. data/app/models/tr8n/translator_metric.rb +1 -1
  90. data/app/models/tr8n/translator_metric_filter.rb +1 -1
  91. data/app/models/tr8n/translator_report.rb +1 -1
  92. data/app/models/tr8n/translator_report_filter.rb +1 -1
  93. data/app/models/tr8n/value_rule.rb +1 -1
  94. data/app/views/tr8n/admin/clientsdk/index.html.erb +29 -29
  95. data/app/views/tr8n/admin/clientsdk/lb_samples.html.erb +1 -1
  96. data/app/views/tr8n/admin/metrics/_tabs.html.erb +22 -0
  97. data/app/views/tr8n/admin/metrics/index.html.erb +60 -0
  98. data/app/views/tr8n/common/_header.html.erb +3 -1
  99. data/app/views/tr8n/common/_language_selector.html.erb +4 -2
  100. data/app/views/tr8n/common/_scripts.html.erb +5 -0
  101. data/app/views/tr8n/common/_terms_of_service.html.erb +53 -0
  102. data/app/views/tr8n/help/credits.html.erb +4 -0
  103. data/app/views/tr8n/language/_select.html.erb +5 -1
  104. data/app/views/tr8n/translator/registration.html.erb +21 -0
  105. data/config/routes.rb +3 -1
  106. data/doc/classes.graffle +356 -7194
  107. data/lib/generators/tr8n/templates/config/tr8n/config.yml +9 -1
  108. data/lib/generators/tr8n/templates/config/tr8n/site/shortcuts.yml +1 -1
  109. data/lib/generators/tr8n/templates/config/tr8n/tokens/decorations.yml +4 -1
  110. data/lib/generators/tr8n/tr8n_generator.rb +1 -1
  111. data/lib/tasks/tr8n.rake +1 -1
  112. data/lib/tr8n.rb +23 -0
  113. data/lib/tr8n/active_dumper.rb +1 -1
  114. data/lib/tr8n/cache.rb +1 -8
  115. data/lib/tr8n/cache_adapters/memcached.rb +1 -1
  116. data/lib/tr8n/config.rb +37 -1
  117. data/lib/tr8n/dictionary.rb +1 -1
  118. data/lib/tr8n/engine.rb +4 -1
  119. data/lib/tr8n/exception.rb +1 -1
  120. data/lib/tr8n/extender.rb +1 -1
  121. data/lib/tr8n/extensions/action_controller_extension.rb +5 -4
  122. data/lib/tr8n/extensions/action_view_extension.rb +71 -20
  123. data/lib/tr8n/extensions/array_extension.rb +14 -1
  124. data/lib/tr8n/extensions/date_extension.rb +1 -1
  125. data/lib/tr8n/extensions/fixnum_extension.rb +1 -1
  126. data/lib/tr8n/extensions/hash_extension.rb +1 -1
  127. data/lib/tr8n/extensions/string_extension.rb +1 -1
  128. data/lib/tr8n/extensions/time_extension.rb +1 -1
  129. data/lib/tr8n/ip_address.rb +1 -1
  130. data/lib/tr8n/key_registration_exception.rb +1 -1
  131. data/lib/tr8n/keyboard_mapping.rb +1 -1
  132. data/lib/tr8n/logger.rb +1 -1
  133. data/lib/tr8n/railtie.rb +1 -1
  134. data/lib/tr8n/site_map.rb +1 -1
  135. data/lib/tr8n/site_map_section.rb +1 -1
  136. data/lib/tr8n/token.rb +1 -1
  137. data/lib/tr8n/token_exception.rb +1 -1
  138. data/lib/tr8n/tokenized_label.rb +2 -12
  139. data/lib/tr8n/tokens/data_token.rb +1 -1
  140. data/lib/tr8n/tokens/decoration_token.rb +1 -1
  141. data/lib/tr8n/tokens/hidden_token.rb +1 -1
  142. data/lib/tr8n/tokens/method_token.rb +1 -1
  143. data/lib/tr8n/tokens/transform_token.rb +1 -1
  144. data/lib/tr8n/version.rb +25 -1
  145. data/local/tr8n_server/app/models/user.rb +1 -0
  146. data/local/tr8n_server/config/environments/test.rb +1 -1
  147. data/local/tr8n_server/config/tr8n/config.yml +45 -39
  148. data/local/tr8n_server/config/tr8n/site/shortcuts.yml +1 -1
  149. data/local/tr8n_server/db/schema.rb +2 -0
  150. data/spec/controllers/awards_controller_spec.rb +22 -0
  151. data/spec/controllers/base_controller_spec.rb +6 -0
  152. data/spec/controllers/dashboard_controller_spec.rb +23 -0
  153. data/spec/controllers/forum_controller_spec.rb +23 -0
  154. data/spec/controllers/glossary_controller_spec.rb +22 -0
  155. data/spec/controllers/help_controller_spec.rb +22 -0
  156. data/spec/controllers/language_cases_controller_spec.rb +13 -0
  157. data/spec/controllers/language_controller_spec.rb +10 -0
  158. data/spec/controllers/phrases_controller_spec.rb +22 -0
  159. data/spec/controllers/translations_controller_spec.rb +23 -0
  160. data/spec/controllers/translator_controller_spec.rb +22 -0
  161. data/spec/lib/tokenized_label_spec.rb +42 -0
  162. data/spec/lib/tokens/data_token_spec.rb +49 -0
  163. data/spec/lib/tokens/decoration_token_spec.rb +49 -0
  164. data/spec/lib/tokens/hidden_token_spec.rb +53 -0
  165. data/spec/lib/tokens/method_token_spec.rb +61 -0
  166. data/spec/lib/tokens/transform_token_spec.rb +51 -0
  167. data/spec/models/tr8n/daily_language_metric_spec.rb +5 -0
  168. data/spec/models/tr8n/date_rule_spec.rb +5 -0
  169. data/spec/models/tr8n/gender_list_rule_spec.rb +5 -0
  170. data/spec/models/tr8n/gender_rule_spec.rb +141 -0
  171. data/spec/models/tr8n/glossary_spec.rb +5 -0
  172. data/spec/models/tr8n/ip_location_spec.rb +5 -0
  173. data/spec/models/tr8n/language_case_rule_spec.rb +5 -0
  174. data/spec/models/tr8n/language_case_spec.rb +5 -0
  175. data/spec/models/tr8n/language_case_value_map_spec.rb +5 -0
  176. data/spec/models/tr8n/language_forum_abuse_report_spec.rb +5 -0
  177. data/spec/models/tr8n/language_forum_message_spec.rb +5 -0
  178. data/spec/models/tr8n/language_forum_topic_spec.rb +5 -0
  179. data/spec/models/tr8n/language_metric_spec.rb +5 -0
  180. data/spec/models/tr8n/language_rule_spec.rb +5 -0
  181. data/spec/models/tr8n/language_spec.rb +79 -0
  182. data/spec/models/tr8n/language_user_spec.rb +5 -0
  183. data/spec/models/tr8n/list_rule_spec.rb +5 -0
  184. data/spec/models/tr8n/monthly_language_metric_spec.rb +5 -0
  185. data/spec/models/tr8n/numeric_rule_spec.rb +162 -0
  186. data/spec/models/tr8n/sync_log_spec.rb +5 -0
  187. data/spec/models/tr8n/total_language_metric_spec.rb +5 -0
  188. data/spec/models/tr8n/translation_domain_spec.rb +5 -0
  189. data/spec/models/tr8n/translation_key_comment_spec.rb +5 -0
  190. data/spec/models/tr8n/translation_key_lock_spec.rb +5 -0
  191. data/spec/models/tr8n/translation_key_source_spec.rb +5 -0
  192. data/spec/models/tr8n/translation_key_spec.rb +118 -0
  193. data/spec/models/tr8n/translation_source_language_spec.rb +5 -0
  194. data/spec/models/tr8n/translation_source_spec.rb +5 -0
  195. data/spec/models/tr8n/translation_spec.rb +5 -0
  196. data/spec/models/tr8n/translation_vote_spec.rb +5 -0
  197. data/spec/models/tr8n/translator_following_spec.rb +5 -0
  198. data/spec/models/tr8n/translator_log_spec.rb +5 -0
  199. data/spec/models/tr8n/translator_metric_spec.rb +5 -0
  200. data/spec/models/tr8n/translator_report_spec.rb +5 -0
  201. data/spec/models/tr8n/translator_spec.rb +140 -0
  202. data/spec/spec_helper.rb +26 -27
  203. data/tr8n.gemspec +3 -1
  204. metadata +173 -50
  205. data/local/tr8n_server/db/migrate/20110930041150_create_tr8n_tables.rb +0 -372
  206. data/spec/fake_app.rb +0 -50
  207. data/spec/lib/data_token_spec.rb +0 -26
  208. data/spec/lib/transform_token_spec.rb +0 -22
  209. data/spec/models/translation_key_spec.rb +0 -63
@@ -1,372 +0,0 @@
1
- #--
2
- # Copyright (c) 2010-2012 Michael Berkovich, tr8n.net
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- class CreateTr8nTables < ActiveRecord::Migration
25
- def self.up
26
- create_table :tr8n_languages do |t|
27
- t.string :locale, :null => false
28
- t.string :english_name, :null => false
29
- t.string :native_name
30
- t.boolean :enabled
31
- t.boolean :right_to_left
32
- t.integer :completeness
33
- t.integer :fallback_language_id
34
- t.text :curse_words
35
- t.integer :featured_index, :default => 0
36
- t.string :google_key
37
- t.string :facebook_key
38
- t.timestamps
39
- end
40
- add_index :tr8n_languages, [:locale], :name => :tr8n_ll
41
-
42
- create_table :tr8n_language_rules do |t|
43
- t.integer :language_id, :null => false
44
- t.integer :translator_id
45
- t.string :type
46
- t.text :definition
47
- t.timestamps
48
- end
49
- add_index :tr8n_language_rules, [:language_id], :name => :tr8n_lr_l
50
- add_index :tr8n_language_rules, [:language_id, :translator_id], :name => :tr8n_lr_lt
51
-
52
- create_table :tr8n_language_cases do |t|
53
- t.integer :language_id, :null => false
54
- t.integer :translator_id
55
- t.string :keyword
56
- t.string :latin_name
57
- t.string :native_name
58
- t.text :description
59
- t.string :application
60
- t.timestamps
61
- end
62
- add_index :tr8n_language_cases, [:language_id], :name => :tr8n_lc_l
63
- add_index :tr8n_language_cases, [:language_id, :translator_id], :name => :tr8n_lc_lt
64
- add_index :tr8n_language_cases, [:language_id, :keyword], :name => :tr8n_lc_lk
65
-
66
- create_table :tr8n_language_case_value_maps do |t|
67
- t.string :keyword, :null => false
68
- t.integer :language_id, :null => false
69
- t.integer :translator_id
70
- t.text :map
71
- t.boolean :reported
72
- t.timestamps
73
- end
74
- add_index :tr8n_language_case_value_maps, [:keyword, :language_id], :name => :tr8n_lcvm_kl
75
- add_index :tr8n_language_case_value_maps, [:translator_id], :name => :tr8n_lcvm_t
76
-
77
- create_table :tr8n_language_users do |t|
78
- t.integer :language_id, :null => false
79
- t.integer :user_id, :null => false
80
- t.integer :translator_id
81
- t.boolean :manager, :default => false
82
- t.timestamps
83
- end
84
- add_index :tr8n_language_users, [:user_id], :name => :tr8n_lu_u
85
- add_index :tr8n_language_users, [:language_id, :user_id], :name => :tr8n_lu_lu
86
- add_index :tr8n_language_users, [:language_id, :translator_id], :name => :tr8n_lu_lt
87
- add_index :tr8n_language_users, [:created_at], :name => :tr8n_lu_ca
88
- add_index :tr8n_language_users, [:updated_at], :name => :tr8n_lu_ua
89
-
90
- create_table :tr8n_language_metrics do |t|
91
- t.string :type
92
- t.integer :language_id, :null => false
93
- t.date :metric_date
94
- t.integer :user_count, :default => 0
95
- t.integer :translator_count, :default => 0
96
- t.integer :translation_count, :default => 0
97
- t.integer :key_count, :default => 0
98
- t.integer :locked_key_count, :default => 0
99
- t.integer :translated_key_count, :default => 0
100
-
101
- t.timestamps
102
- end
103
- add_index :tr8n_language_metrics, [:language_id], :name => :tr8n_lm_l
104
- add_index :tr8n_language_metrics, [:created_at], :name => :tr8n_lm_c
105
-
106
- create_table :tr8n_translators do |t|
107
- t.integer :user_id
108
- t.boolean :inline_mode, :default => false
109
- t.boolean :blocked, :default => false
110
- t.boolean :reported, :default => false
111
- t.integer :fallback_language_id
112
- t.integer :rank, :default => 0
113
- t.string :name
114
- t.string :gender
115
- t.string :email
116
- t.string :password
117
- t.string :mugshot
118
- t.string :link
119
- t.string :locale
120
- t.integer :level, :default => 0
121
- t.integer :manager
122
- t.string :last_ip
123
- t.string :country_code
124
- t.integer :remote_id
125
- t.timestamps
126
- end
127
- add_index :tr8n_translators, [:user_id], :name => :tr8n_t_u
128
- add_index :tr8n_translators, [:created_at], :name => :tr8n_t_c
129
- add_index :tr8n_translators, [:email], :name => :tr8n_t_e
130
- add_index :tr8n_translators, [:email, :password], :name => :tr8n_t_ep
131
-
132
- create_table :tr8n_translator_logs do |t|
133
- t.integer :translator_id
134
- t.integer :user_id, :limit => 8
135
- t.string :action
136
- t.integer :action_level
137
- t.string :reason
138
- t.string :reference
139
- t.timestamps
140
- end
141
- add_index :tr8n_translator_logs, [:translator_id], :name => :tr8n_tl_t
142
- add_index :tr8n_translator_logs, [:user_id], :name => :tr8n_tl_u
143
- add_index :tr8n_translator_logs, [:created_at], :name => :tr8n_tl_c
144
-
145
- create_table :tr8n_translator_metrics do |t|
146
- t.integer :translator_id, :null => false
147
- t.integer :language_id
148
- t.integer :total_translations, :default => 0
149
- t.integer :total_votes, :default => 0
150
- t.integer :positive_votes, :default => 0
151
- t.integer :negative_votes, :default => 0
152
- t.integer :accepted_translations, :default => 0
153
- t.integer :rejected_translations, :default => 0
154
- t.timestamps
155
- end
156
- add_index :tr8n_translator_metrics, [:translator_id], :name => :tr8n_tm_t
157
- add_index :tr8n_translator_metrics, [:translator_id, :language_id], :name => :tr8n_tm_tl
158
- add_index :tr8n_translator_metrics, [:created_at], :name => :tr8n_tm_c
159
-
160
- create_table :tr8n_translation_keys do |t|
161
- t.string :type
162
- t.string :key, :null => false
163
- t.text :label, :null => false
164
- t.text :description
165
- t.timestamp :verified_at
166
- t.integer :translation_count
167
- t.boolean :admin
168
- t.string :locale
169
- t.integer :level, :default => 0
170
- t.timestamp :synced_at
171
- t.timestamps
172
- end
173
- add_index :tr8n_translation_keys, [:key], :unique => true, :name => :tr8n_tk_k
174
-
175
- create_table :tr8n_translation_sources do |t|
176
- t.string :source
177
- t.integer :translation_domain_id
178
- t.timestamps
179
- end
180
- add_index :tr8n_translation_sources, [:source], :name => :tr8n_ts_s
181
-
182
- create_table :tr8n_translation_key_sources do |t|
183
- t.integer :translation_key_id, :null => false
184
- t.integer :translation_source_id, :null => false
185
- t.text :details
186
- t.timestamps
187
- end
188
- add_index :tr8n_translation_key_sources, [:translation_key_id], :name => :tr8n_tks_tk
189
- add_index :tr8n_translation_key_sources, [:translation_source_id], :name => :tr8n_tks_ts
190
-
191
- create_table :tr8n_translation_key_locks do |t|
192
- t.integer :translation_key_id, :null => false
193
- t.integer :language_id, :null => false
194
- t.integer :translator_id
195
- t.boolean :locked, :default => false
196
- t.timestamps
197
- end
198
- add_index :tr8n_translation_key_locks, [:translation_key_id, :language_id], :name => :tr8n_tkl_tl
199
-
200
- create_table :tr8n_translations do |t|
201
- t.integer :translation_key_id, :null => false
202
- t.integer :language_id, :null => false
203
- t.integer :translator_id, :null => false
204
- t.text :label, :null => false
205
- t.integer :rank, :default => 0
206
- t.integer :approved_by_id, :limit => 8
207
- t.text :rules
208
- t.timestamp :synced_at
209
- t.timestamps
210
- end
211
- add_index :tr8n_translations, [:translator_id], :name => :tr8n_trn_t
212
- add_index :tr8n_translations, [:translation_key_id, :translator_id, :language_id], :name => :tr8n_trn_tktl
213
- add_index :tr8n_translations, [:created_at], :name => :tr8n_trn_c
214
-
215
- create_table :tr8n_translation_votes do |t|
216
- t.integer :translation_id, :null => false
217
- t.integer :translator_id, :null => false
218
- t.integer :vote, :null => false
219
- t.timestamps
220
- end
221
- add_index :tr8n_translation_votes, [:translator_id], :name => :tr8n_tv_t
222
- add_index :tr8n_translation_votes, [:translation_id, :translator_id], :name => :tr8n_tv_tt
223
-
224
- create_table :tr8n_glossary do |t|
225
- t.string :keyword
226
- t.text :description
227
- t.timestamps
228
- end
229
- add_index :tr8n_glossary, [:keyword]
230
-
231
- create_table :tr8n_language_forum_topics do |t|
232
- t.integer :translator_id, :null => false
233
- t.integer :language_id
234
- t.text :topic, :null => false
235
- t.timestamps
236
- end
237
- add_index :tr8n_language_forum_topics, [:language_id], :name => :tr8n_lft_l
238
- add_index :tr8n_language_forum_topics, [:translator_id], :name => :tr8n_lft_t
239
-
240
- create_table :tr8n_language_forum_messages do |t|
241
- t.integer :language_id, :null => false
242
- t.integer :language_forum_topic_id, :null => false
243
- t.integer :translator_id, :null => false
244
- t.text :message, :null => false
245
- t.timestamps
246
- end
247
- add_index :tr8n_language_forum_messages, [:language_id], :name => :tr8n_lfm_l
248
- add_index :tr8n_language_forum_messages, [:translator_id], :name => :tr8n_lfm_t
249
- add_index :tr8n_language_forum_messages, [:language_id, :language_forum_topic_id], :name => :tr8n_lfm_ll
250
-
251
- create_table :tr8n_language_forum_abuse_reports do |t|
252
- t.integer :language_id, :null => false
253
- t.integer :translator_id, :null => false
254
- t.integer :language_forum_message_id, :null => false
255
- t.string :reason
256
- t.timestamps
257
- end
258
- add_index :tr8n_language_forum_abuse_reports, [:language_id], :name => :tr8n_lfar_l
259
- add_index :tr8n_language_forum_abuse_reports, [:language_id, :translator_id], :name => :tr8n_lfar_lt
260
- add_index :tr8n_language_forum_abuse_reports, [:language_forum_message_id], :name => :tr8n_lfar_lfm
261
-
262
- create_table :tr8n_translation_key_comments do |t|
263
- t.integer :language_id, :null => false
264
- t.integer :translation_key_id, :null => false
265
- t.integer :translator_id, :null => false
266
- t.text :message, :null => false
267
- t.timestamps
268
- end
269
- add_index :tr8n_translation_key_comments, [:language_id], :name => :tr8n_tkc_l
270
- add_index :tr8n_translation_key_comments, [:translator_id], :name => :tr8n_tkc_t
271
- add_index :tr8n_translation_key_comments, [:language_id, :translation_key_id], :name => :tr8n_tkc_lt
272
-
273
- create_table :tr8n_language_case_rules do |t|
274
- t.integer :language_case_id, :null => false
275
- t.integer :language_id
276
- t.integer :translator_id
277
- t.text :definition, :null => false
278
- t.integer :position
279
- t.timestamps
280
- end
281
- add_index :tr8n_language_case_rules, [:language_case_id], :name => :tr8n_lcr_lc
282
- add_index :tr8n_language_case_rules, [:language_id], :name => :tr8n_lcr_l
283
- add_index :tr8n_language_case_rules, [:translator_id], :name => :tr8n_lcr_t
284
-
285
- create_table :tr8n_translation_domains do |t|
286
- t.string :name
287
- t.string :description
288
- t.integer :source_count, :default => 0
289
- t.timestamps
290
- end
291
- add_index :tr8n_translation_domains, [:name], :unique => true, :name => :tr8n_td_n
292
-
293
- create_table :tr8n_translator_following do |t|
294
- t.integer :translator_id
295
- t.integer :object_id
296
- t.string :object_type
297
- t.timestamps
298
- end
299
- add_index :tr8n_translator_following, [:translator_id], :name => :tr8n_tf_t
300
-
301
- create_table :tr8n_translator_reports do |t|
302
- t.integer :translator_id
303
- t.string :state
304
- t.integer :object_id
305
- t.string :object_type
306
- t.string :reason
307
- t.text :comment
308
- t.timestamps
309
- end
310
- add_index :tr8n_translator_reports, [:translator_id], :name => :tr8n_tr_t
311
-
312
- create_table :tr8n_ip_locations do |t|
313
- t.integer :low, :limit => 8
314
- t.integer :high, :limit => 8
315
- t.string :registry, :limit => 20
316
- t.date :assigned
317
- t.string :ctry, :limit => 2
318
- t.string :cntry, :limit => 3
319
- t.string :country, :limit => 80
320
- t.timestamps
321
- end
322
- add_index :tr8n_ip_locations, [:low], :name => :tr8n_il_l
323
- add_index :tr8n_ip_locations, [:high], :name => :tr8n_il_h
324
-
325
- create_table :tr8n_translation_source_languages do |t|
326
- t.integer :language_id
327
- t.integer :translation_source_id
328
- t.timestamps
329
- end
330
- add_index :tr8n_translation_source_languages, [:language_id, :translation_source_id], :name => :tr8n_tsl_lt
331
-
332
- create_table :tr8n_sync_logs do |t|
333
- t.timestamp :started_at
334
- t.timestamp :finished_at
335
- t.integer :keys_sent
336
- t.integer :translations_sent
337
- t.integer :keys_received
338
- t.integer :translations_received
339
- t.timestamps
340
- end
341
- end
342
-
343
- def self.down
344
- drop_table :tr8n_languages
345
- drop_table :tr8n_language_rules
346
- drop_table :tr8n_language_users
347
- drop_table :tr8n_language_cases
348
- drop_table :tr8n_language_case_value_maps
349
- drop_table :tr8n_language_metrics
350
- drop_table :tr8n_translators
351
- drop_table :tr8n_translator_logs
352
- drop_table :tr8n_translator_metrics
353
- drop_table :tr8n_translation_keys
354
- drop_table :tr8n_translation_sources
355
- drop_table :tr8n_translation_key_sources
356
- drop_table :tr8n_translation_key_locks
357
- drop_table :tr8n_translations
358
- drop_table :tr8n_translation_votes
359
- drop_table :tr8n_glossary
360
- drop_table :tr8n_language_forum_messages
361
- drop_table :tr8n_language_forum_topics
362
- drop_table :tr8n_language_forum_abuse_reports
363
- drop_table :tr8n_translation_key_comments
364
- drop_table :tr8n_language_case_rules
365
- drop_table :tr8n_translation_domains
366
- drop_table :tr8n_translator_following
367
- drop_table :tr8n_translator_reports
368
- drop_table :tr8n_ip_locations
369
- drop_table :tr8n_translation_source_languages
370
- drop_table :tr8n_sync_logs
371
- end
372
- end
@@ -1,50 +0,0 @@
1
- require 'active_record'
2
- require 'action_controller/railtie'
3
- require 'action_view/railtie'
4
-
5
- # database
6
- ActiveRecord::Base.configurations = {'test' => {:adapter => 'sqlite3', :database => ':memory:'}}
7
- ActiveRecord::Base.establish_connection('test')
8
-
9
- # config
10
- app = Class.new(Rails::Application)
11
- app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
12
- app.config.session_store :cookie_store, :key => "_myapp_session"
13
- app.config.active_support.deprecation = :log
14
- app.initialize!
15
-
16
- # routes
17
- app.routes.draw do
18
- resources :users
19
- end
20
-
21
- # models
22
- Dir["#{File.dirname(__FILE__)}/../local/tr8n_server/app/models/*.rb"].each do |f|
23
- if [:user, :admin].include?(f.split("/").last.gsub('.rb', '').to_sym)
24
- require f
25
- end
26
- end
27
-
28
- # controllers
29
- class ApplicationController < ActionController::Base; end
30
- class UsersController < ApplicationController
31
- def index
32
- @users = User.filter(:params => params)
33
- render :inline => <<-ERB
34
- <%= will_filter_tag(@users) %>
35
- ERB
36
- end
37
- end
38
-
39
- # helpers
40
- Object.const_set(:ApplicationHelper, Module.new)
41
-
42
- #migrations
43
- class CreateAllTables < ActiveRecord::Migration
44
- def self.up
45
- Dir["#{File.dirname(__FILE__)}/../local/tr8n_server/db/migrate/*.rb"].each do |f|
46
- require f
47
- f.split("/").last.gsub('.rb', '').split('_')[1..-1].join('_').camelcase.constantize.up
48
- end
49
- end
50
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
-
3
- describe Tr8n::Tokens::DataToken do
4
- describe '#register_data_tokens' do
5
-
6
- context "registering correct data tokens" do
7
- it "should register all tokens" do
8
- tokens = Tr8n::Tokens::DataToken.parse("Hello {user}")
9
- tokens.count.should == 1
10
- tokens.first.class.name.should == "Tr8n::Tokens::DataToken"
11
-
12
- tokens = Tr8n::Tokens::DataToken.parse("{user} has {count} messages")
13
- tokens.count.should == 2
14
- tokens.first.class.name.should == "Tr8n::Tokens::DataToken"
15
- end
16
- end
17
-
18
- context "registering incorrect data tokens" do
19
- it "should not register any tokens" do
20
- Tr8n::Tokens::DataToken.parse("Hello {user:}").count.should == 0
21
- Tr8n::Tokens::DataToken.parse("Hello {}").count.should == 0
22
- Tr8n::Tokens::DataToken.parse("Hello {user::}").count.should == 0
23
- end
24
- end
25
- end
26
- end
@@ -1,22 +0,0 @@
1
- require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
-
3
- describe Tr8n::Tokens::TransformToken do
4
- describe '#register_data_tokens' do
5
-
6
- context "registering correct transform tokens" do
7
- it "should register all tokens" do
8
- Tr8n::Tokens::TransformToken.parse("{user:gender|his,her}").count.should == 1
9
- Tr8n::Tokens::TransformToken.parse("{count:number|message}").count.should == 1
10
- Tr8n::Tokens::TransformToken.parse("{count:number||message}").count.should == 1
11
- end
12
- end
13
-
14
- context "registering incorrect transform tokens" do
15
- it "should not register any tokens" do
16
- Tr8n::Tokens::TransformToken.parse("Hello {user}").count.should == 0
17
- Tr8n::Tokens::TransformToken.parse("Hello {user:}").count.should == 0
18
- Tr8n::Tokens::TransformToken.parse("Hello {user::}").count.should == 0
19
- end
20
- end
21
- end
22
- end