rosette-core 1.0.1

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.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +26 -0
  3. data/History.txt +3 -0
  4. data/README.md +94 -0
  5. data/Rakefile +18 -0
  6. data/lib/rosette/core.rb +110 -0
  7. data/lib/rosette/core/branch_utils.rb +152 -0
  8. data/lib/rosette/core/commands.rb +139 -0
  9. data/lib/rosette/core/commands/errors.rb +17 -0
  10. data/lib/rosette/core/commands/git/commit_command.rb +65 -0
  11. data/lib/rosette/core/commands/git/diff_base_command.rb +301 -0
  12. data/lib/rosette/core/commands/git/diff_command.rb +188 -0
  13. data/lib/rosette/core/commands/git/diff_entry.rb +44 -0
  14. data/lib/rosette/core/commands/git/fetch_command.rb +27 -0
  15. data/lib/rosette/core/commands/git/repo_snapshot_command.rb +40 -0
  16. data/lib/rosette/core/commands/git/show_command.rb +70 -0
  17. data/lib/rosette/core/commands/git/snapshot_command.rb +50 -0
  18. data/lib/rosette/core/commands/git/status_command.rb +128 -0
  19. data/lib/rosette/core/commands/git/with_non_merge_ref.rb +48 -0
  20. data/lib/rosette/core/commands/git/with_ref.rb +92 -0
  21. data/lib/rosette/core/commands/git/with_refs.rb +92 -0
  22. data/lib/rosette/core/commands/git/with_repo_name.rb +50 -0
  23. data/lib/rosette/core/commands/git/with_snapshots.rb +45 -0
  24. data/lib/rosette/core/commands/queuing/enqueue_commit_command.rb +37 -0
  25. data/lib/rosette/core/commands/queuing/requeue_commit_command.rb +46 -0
  26. data/lib/rosette/core/commands/translations/export_command.rb +257 -0
  27. data/lib/rosette/core/commands/translations/translation_lookup_command.rb +66 -0
  28. data/lib/rosette/core/commands/translations/with_locale.rb +47 -0
  29. data/lib/rosette/core/configurator.rb +160 -0
  30. data/lib/rosette/core/error_reporters/buffered_error_reporter.rb +96 -0
  31. data/lib/rosette/core/error_reporters/error_reporter.rb +31 -0
  32. data/lib/rosette/core/error_reporters/nil_error_reporter.rb +25 -0
  33. data/lib/rosette/core/error_reporters/printing_error_reporter.rb +58 -0
  34. data/lib/rosette/core/error_reporters/raising_error_reporter.rb +27 -0
  35. data/lib/rosette/core/errors.rb +93 -0
  36. data/lib/rosette/core/extractor/commit_log.rb +33 -0
  37. data/lib/rosette/core/extractor/commit_log_status.rb +57 -0
  38. data/lib/rosette/core/extractor/commit_processor.rb +109 -0
  39. data/lib/rosette/core/extractor/extractor.rb +72 -0
  40. data/lib/rosette/core/extractor/extractor_config.rb +74 -0
  41. data/lib/rosette/core/extractor/locale.rb +118 -0
  42. data/lib/rosette/core/extractor/phrase.rb +76 -0
  43. data/lib/rosette/core/extractor/phrase/phrase_index_policy.rb +108 -0
  44. data/lib/rosette/core/extractor/phrase/phrase_to_hash.rb +33 -0
  45. data/lib/rosette/core/extractor/repo_config.rb +339 -0
  46. data/lib/rosette/core/extractor/serializer_config.rb +55 -0
  47. data/lib/rosette/core/extractor/static_extractor.rb +44 -0
  48. data/lib/rosette/core/extractor/translation.rb +44 -0
  49. data/lib/rosette/core/extractor/translation/translation_to_hash.rb +28 -0
  50. data/lib/rosette/core/git/diff_finder.rb +131 -0
  51. data/lib/rosette/core/git/ref.rb +116 -0
  52. data/lib/rosette/core/git/repo.rb +378 -0
  53. data/lib/rosette/core/path_matcher_factory.rb +330 -0
  54. data/lib/rosette/core/resolvers/extractor_id.rb +37 -0
  55. data/lib/rosette/core/resolvers/integration_id.rb +37 -0
  56. data/lib/rosette/core/resolvers/preprocessor_id.rb +38 -0
  57. data/lib/rosette/core/resolvers/resolver.rb +115 -0
  58. data/lib/rosette/core/resolvers/serializer_id.rb +37 -0
  59. data/lib/rosette/core/snapshots/cached_head_snapshot_factory.rb +51 -0
  60. data/lib/rosette/core/snapshots/cached_snapshot_factory.rb +67 -0
  61. data/lib/rosette/core/snapshots/head_snapshot_factory.rb +58 -0
  62. data/lib/rosette/core/snapshots/repo_config_path_filter.rb +83 -0
  63. data/lib/rosette/core/snapshots/snapshot_factory.rb +184 -0
  64. data/lib/rosette/core/string_utils.rb +23 -0
  65. data/lib/rosette/core/translation_status.rb +81 -0
  66. data/lib/rosette/core/validators.rb +18 -0
  67. data/lib/rosette/core/validators/commit_validator.rb +62 -0
  68. data/lib/rosette/core/validators/commits_validator.rb +32 -0
  69. data/lib/rosette/core/validators/encoding_validator.rb +32 -0
  70. data/lib/rosette/core/validators/locale_validator.rb +37 -0
  71. data/lib/rosette/core/validators/repo_validator.rb +33 -0
  72. data/lib/rosette/core/validators/serializer_validator.rb +37 -0
  73. data/lib/rosette/core/validators/validator.rb +31 -0
  74. data/lib/rosette/core/version.rb +8 -0
  75. data/lib/rosette/data_stores.rb +11 -0
  76. data/lib/rosette/data_stores/errors.rb +26 -0
  77. data/lib/rosette/data_stores/phrase_status.rb +59 -0
  78. data/lib/rosette/integrations.rb +12 -0
  79. data/lib/rosette/integrations/errors.rb +15 -0
  80. data/lib/rosette/integrations/integratable.rb +58 -0
  81. data/lib/rosette/integrations/integration.rb +23 -0
  82. data/lib/rosette/preprocessors.rb +11 -0
  83. data/lib/rosette/preprocessors/errors.rb +14 -0
  84. data/lib/rosette/preprocessors/preprocessor.rb +48 -0
  85. data/lib/rosette/queuing.rb +14 -0
  86. data/lib/rosette/queuing/commits.rb +19 -0
  87. data/lib/rosette/queuing/commits/commit_conductor.rb +90 -0
  88. data/lib/rosette/queuing/commits/commit_job.rb +93 -0
  89. data/lib/rosette/queuing/commits/commits_queue_configurator.rb +60 -0
  90. data/lib/rosette/queuing/commits/extract_stage.rb +46 -0
  91. data/lib/rosette/queuing/commits/fetch_stage.rb +51 -0
  92. data/lib/rosette/queuing/commits/finalize_stage.rb +76 -0
  93. data/lib/rosette/queuing/commits/phrase_storage_granularity.rb +20 -0
  94. data/lib/rosette/queuing/commits/push_stage.rb +91 -0
  95. data/lib/rosette/queuing/commits/stage.rb +96 -0
  96. data/lib/rosette/queuing/job.rb +74 -0
  97. data/lib/rosette/queuing/queue.rb +28 -0
  98. data/lib/rosette/queuing/queue_configurator.rb +76 -0
  99. data/lib/rosette/queuing/worker.rb +30 -0
  100. data/lib/rosette/serializers.rb +10 -0
  101. data/lib/rosette/serializers/serializer.rb +98 -0
  102. data/lib/rosette/tms.rb +9 -0
  103. data/lib/rosette/tms/repository.rb +95 -0
  104. data/rosette-core.gemspec +24 -0
  105. data/spec/core/branch_utils_spec.rb +110 -0
  106. data/spec/core/commands/git/commit_command_spec.rb +60 -0
  107. data/spec/core/commands/git/diff_command_spec.rb +263 -0
  108. data/spec/core/commands/git/fetch_command_spec.rb +61 -0
  109. data/spec/core/commands/git/repo_snapshot_command_spec.rb +72 -0
  110. data/spec/core/commands/git/show_command_spec.rb +128 -0
  111. data/spec/core/commands/git/snapshot_command_spec.rb +86 -0
  112. data/spec/core/commands/git/status_command_spec.rb +154 -0
  113. data/spec/core/commands/queuing/enqueue_commit_command_spec.rb +34 -0
  114. data/spec/core/commands/queuing/requeue_commit_command_spec.rb +46 -0
  115. data/spec/core/commands/translations/export_command_spec.rb +113 -0
  116. data/spec/core/commands/translations/translation_lookup_command_spec.rb +58 -0
  117. data/spec/core/configurator_spec.rb +47 -0
  118. data/spec/core/error_reporters/buffered_error_reporter_spec.rb +61 -0
  119. data/spec/core/error_reporters/nil_error_reporter_spec.rb +16 -0
  120. data/spec/core/error_reporters/printing_error_reporter_spec.rb +60 -0
  121. data/spec/core/extractor/commit_log_status_spec.rb +216 -0
  122. data/spec/core/extractor/commit_processor_spec.rb +68 -0
  123. data/spec/core/extractor/extractor_config_spec.rb +47 -0
  124. data/spec/core/extractor/extractor_spec.rb +26 -0
  125. data/spec/core/extractor/locale_spec.rb +92 -0
  126. data/spec/core/extractor/phrase/phrase_index_policy_spec.rb +116 -0
  127. data/spec/core/extractor/phrase/phrase_to_hash_spec.rb +18 -0
  128. data/spec/core/extractor/repo_config_spec.rb +147 -0
  129. data/spec/core/extractor/translation/translation_to_hash_spec.rb +25 -0
  130. data/spec/core/git/diff_finder_spec.rb +74 -0
  131. data/spec/core/git/ref_spec.rb +118 -0
  132. data/spec/core/git/repo_spec.rb +216 -0
  133. data/spec/core/path_matcher_factory_spec.rb +139 -0
  134. data/spec/core/resolvers/extractor_id_spec.rb +47 -0
  135. data/spec/core/resolvers/integration_id_spec.rb +47 -0
  136. data/spec/core/resolvers/preprocessor_id_spec.rb +47 -0
  137. data/spec/core/resolvers/serializer_id_spec.rb +47 -0
  138. data/spec/core/snapshots/snapshot_factory_spec.rb +145 -0
  139. data/spec/core/string_utils_spec.rb +19 -0
  140. data/spec/core/translation_status_spec.rb +91 -0
  141. data/spec/core/validators/commit_validator_spec.rb +40 -0
  142. data/spec/core/validators/encoding_validator_spec.rb +30 -0
  143. data/spec/core/validators/locale_validator_spec.rb +31 -0
  144. data/spec/core/validators/repo_validator_spec.rb +30 -0
  145. data/spec/core/validators/serializer_validator_spec.rb +31 -0
  146. data/spec/integrations/integratable_spec.rb +58 -0
  147. data/spec/queuing/commits/commit_conductor_spec.rb +71 -0
  148. data/spec/queuing/commits/commit_job_spec.rb +87 -0
  149. data/spec/queuing/commits/extract_stage_spec.rb +68 -0
  150. data/spec/queuing/commits/fetch_stage_spec.rb +101 -0
  151. data/spec/queuing/commits/finalize_stage_spec.rb +88 -0
  152. data/spec/queuing/commits/push_stage_spec.rb +145 -0
  153. data/spec/queuing/commits/stage_spec.rb +80 -0
  154. data/spec/queuing/job_spec.rb +33 -0
  155. data/spec/queuing/queue_configurator_spec.rb +44 -0
  156. data/spec/spec_helper.rb +90 -0
  157. data/spec/test_helpers/fake_commit_stage.rb +17 -0
  158. metadata +257 -0
@@ -0,0 +1,74 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Queuing
5
+
6
+ # Base class for jobs that can be run on a Rosette queue implementation.
7
+ class Job
8
+ # The name of the queue to use when no custom queue name is specified.
9
+ DEFAULT_QUEUE_NAME = 'default'
10
+
11
+ # The default minimum number of seconds to wait before executing each job.
12
+ DEFAULT_DELAY = 0
13
+
14
+ class << self
15
+ # Returns the name of the queue this job will be run in. For
16
+ # implementations that don't offer named queues, this value should be
17
+ # ignored.
18
+ #
19
+ # @return [String] The name of the queue.
20
+ def queue_name
21
+ @queue_name || DEFAULT_QUEUE_NAME
22
+ end
23
+
24
+ # Sets the name of the queue this job will be run in. Implementations
25
+ # that don't offer named queues shouldn't need to call this method,
26
+ # although nothing bad will happen if they do.
27
+ #
28
+ # @param [String] queue_name The name of the queue to run the job in.
29
+ # @return [void]
30
+ def set_queue_name(queue_name)
31
+ @queue_name = queue_name
32
+ end
33
+ end
34
+
35
+ # Performs this job's task.
36
+ #
37
+ # @param [Configurator] rosette_config The rosette config to pass to the
38
+ # job when executing.
39
+ # @param [Logger] logger The logger to pass to the job when executing.
40
+ # @return [void]
41
+ def work(rosette_config, logger)
42
+ raise NotImplementedError,
43
+ 'expected to be implemented in derived classes'
44
+ end
45
+
46
+ # Gets an array of the arguments to use to re-create this job later. Most
47
+ # implementations will expect these arguments to be serializable in some
48
+ # way so they can be stored in a cache or database.
49
+ #
50
+ # @return [Array<Object>] the list of job arguments.
51
+ def to_args
52
+ raise NotImplementedError,
53
+ 'expected to be implemented in derived classes'
54
+ end
55
+
56
+ # Returns the minimum number of seconds to wait before executing this job.
57
+ #
58
+ # @return [Fixnum]
59
+ def delay
60
+ @delay || DEFAULT_DELAY
61
+ end
62
+
63
+ # Sets the amount of time to wait before executing this job.
64
+ #
65
+ # @param [Fixnum] delay The minimum amount of time in seconds to wait
66
+ # before executing this job.
67
+ # @return [void]
68
+ def set_delay(delay)
69
+ @delay = delay
70
+ end
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Queuing
5
+
6
+ # Base class for Rosette queue implementations. Really just an interface.
7
+ class Queue
8
+ # Creates a new queue instance. Options vary per implementation.
9
+ #
10
+ # @param [Hash] options A hash of options used by the underlying
11
+ # queue implementation.
12
+ # @return [Queue]
13
+ def initialize(options = {})
14
+ end
15
+
16
+ # Add a job instance to the queue. If not implemented by a derived class,
17
+ # raises +NotImplementedError+.
18
+ #
19
+ # @param [Job] job The job to enqueue.
20
+ # @return [void]
21
+ def enqueue(job)
22
+ raise NotImplementedError,
23
+ 'expected to be implemented in derived classes'
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Queuing
5
+
6
+ # Configuration used to initialize a queue implementation.
7
+ #
8
+ # @!attribute [r] queue_options
9
+ # @return [Hash] a hash of options to be used by the queue implementation.
10
+ # @!attribute [r] queue_configs
11
+ # @return [Array] an array of queue config objects. These classes are
12
+ # provided by each type of queue. For example, the queue that processes
13
+ # commits (see [Rosette::Queuing::Commits]) defines its own configurator
14
+ # that gets instantiated and added to this array.
15
+ class QueueConfigurator
16
+ attr_reader :queue_options, :queue_configs
17
+
18
+ # Creates a new +QueueConfigurator+ instance.
19
+ #
20
+ # @return [QueueConfigurator]
21
+ def initialize
22
+ @queue_options = {}
23
+ @queue_configs = []
24
+ end
25
+
26
+ # Sets an options hash that will be used to initialize the underlying
27
+ # queue implementation (eg. resque, sidekiq, etc).
28
+ #
29
+ # @param [Hash] options The options hash to use to initialize the
30
+ # underlying queue implementation (eg. resque, sidekiq, etc).
31
+ # @return [void]
32
+ def set_queue_options(options = {})
33
+ @queue_options = options
34
+ end
35
+
36
+ # Configures and adds a queue to process jobs from. Note that the term
37
+ # "queue" here refers to a sequence of jobs, not a queue implementation.
38
+ #
39
+ # @param [String] queue_name The name of the queue to configure.
40
+ # @return [void]
41
+ def enable_queue(queue_name)
42
+ if const = find_queue_configurator_const(queue_name)
43
+ config = const.new(queue_name)
44
+ yield config if block_given?
45
+ queue_configs << config
46
+ else
47
+ raise ArgumentError, "'#{queue_name}' couldn't be found."
48
+ end
49
+ end
50
+
51
+ # Looks up a queue configuration object by name.
52
+ #
53
+ # @param [String] queue_name The name of the queue to look up.
54
+ # @return [Object, nil] The queue config object, or +nil+ if none could
55
+ # be found.
56
+ def get_queue_config(queue_name)
57
+ queue_configs.find { |q| q.name == queue_name }
58
+ end
59
+
60
+ protected
61
+
62
+ def find_queue_configurator_const(name)
63
+ const_str = Rosette::Core::StringUtils.camelize(name)
64
+
65
+ if Rosette::Queuing.const_defined?(const_str)
66
+ mod = Rosette::Queuing.const_get(const_str)
67
+
68
+ if mod.const_defined?(:"#{const_str}QueueConfigurator")
69
+ mod.const_get(:"#{const_str}QueueConfigurator")
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ end
76
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Queuing
5
+
6
+ # Base class for Rosette queue worker implementations. Really just an
7
+ # interface.
8
+ class Worker
9
+ # Creates a new worker instance. Options vary per implementation.
10
+ #
11
+ # @param [Configurator] rosette_config The Rosette config to use.
12
+ # @param [Logger] logger The logger to print messages with.
13
+ # @param [Hash] options A hash of options used by the underlying
14
+ # queue implementation.
15
+ # @return [Worker]
16
+ def initialize(rosette_config, logger, options = {})
17
+ end
18
+
19
+ # Tells this worker to start processing jobs. Should block. If not
20
+ # implemented by the derived class, raises +NotImplementedError+.
21
+ #
22
+ # @return [void]
23
+ def start
24
+ raise NotImplementedError,
25
+ 'expected to be implemented in derived classes'
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+
5
+ # Namespace for all of Rosette's serializers.
6
+ module Serializers
7
+ autoload :Serializer, 'rosette/serializers/serializer'
8
+ end
9
+
10
+ end
@@ -0,0 +1,98 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Serializers
5
+
6
+ # Base class for all Rosette's serializers.
7
+ #
8
+ # @!attribute [r] stream
9
+ # @return [#write, #flush] an IO-style object to write the serialized
10
+ # phrases or translations to.
11
+ # @!attribute [r] locale
12
+ # @return [String] the locale to expect the phrases or tranlsations to
13
+ # be written in.
14
+ # @!attribute [r] encoding
15
+ # @return [String, Encoding] the encoding to use when writing the phrases
16
+ # or translations to +stream+.
17
+ class Serializer
18
+ attr_reader :stream, :locale, :encoding
19
+
20
+ class << self
21
+ # Creates a new serializer around the given stream.
22
+ #
23
+ # @param [#write, #flush] stream The stream object to write serialized
24
+ # phrases and translations to.
25
+ # @param [Locale] locale The associated locale.
26
+ # @return [Serializer]
27
+ def from_stream(stream, locale)
28
+ new(stream, locale)
29
+ end
30
+
31
+ # Creates a new serializer around the given file. Opens the file and
32
+ # instantiates a new serializer with the handle.
33
+ #
34
+ # @param [String] file The file.
35
+ # @param [Locale] locale The associated locale.
36
+ def open(file, locale)
37
+ new(File.open(file), locale)
38
+ end
39
+
40
+ # Returns the default file extension for the file type this serializer
41
+ # generates. For example, if this is the yaml/rails serializer, the
42
+ # default extension would be '.yml'.
43
+ #
44
+ # @raise [NotImplementedError]
45
+ def default_extension
46
+ raise NotImplementedError,
47
+ 'expected to be implemented in derived classes'
48
+ end
49
+ end
50
+
51
+ # Creates a new serializer.
52
+ #
53
+ # @param [#write, #flush] stream The stream to write serialized phrases
54
+ # or translations to.
55
+ # @param [String] locale The locale of the translations to write to
56
+ # +stream+.
57
+ # @param [String, Encoding] encoding The encoding to use when writing the
58
+ # phrases or translations to +stream+.
59
+ def initialize(stream, locale, encoding = Encoding::UTF_8)
60
+ @stream = stream
61
+ @locale = locale
62
+ @encoding = encoding
63
+ end
64
+
65
+ # Serializes and writes a key/value pair to the stream. The key is often
66
+ # a phrase key or meta key, and the value is often a foreign-language
67
+ # translation.
68
+ #
69
+ # @param [String] key The phrase key or meta key.
70
+ # @param [String] value
71
+ # @return [void]
72
+ # @raise [NotImplementedError]
73
+ def write_key_value(key, value)
74
+ raise NotImplementedError,
75
+ 'expected to be implemented in derived classes'
76
+ end
77
+
78
+ # Writes raw text to +stream+ without serializing it first.
79
+ #
80
+ # @param [String] text The raw text to write.
81
+ # @return [void]
82
+ # @raise [NotImplementedError]
83
+ def write_raw(text)
84
+ raise NotImplementedError,
85
+ 'expected to be implemented in derived classes'
86
+ end
87
+
88
+ # Flushes any buffered text from +stream+ (i.e. forces buffered text
89
+ # to be written immediately).
90
+ #
91
+ # @return [void]
92
+ def flush
93
+ stream.flush
94
+ end
95
+ end
96
+
97
+ end
98
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Tms
5
+
6
+ autoload :Repository, 'rosette/tms/repository'
7
+
8
+ end
9
+ end
@@ -0,0 +1,95 @@
1
+ # encoding: UTF-8
2
+
3
+ module Rosette
4
+ module Tms
5
+ class Repository
6
+ # Creates a new instance of this repository.
7
+ #
8
+ # @param [Object] configurator The implementation-specific configuration
9
+ # object for this repository.
10
+ # @return [Repository]
11
+ def initialize(configurator)
12
+ end
13
+
14
+ # Retrieves a list of translations for the given phrases.
15
+ #
16
+ # @param [Locale] locale The locale of the translations to retrieve.
17
+ # @param [Array<Phrase>] phrases The list of phrases to retrieve
18
+ # translations for.
19
+ # @return [Array<String>] an array of translations (note that the array
20
+ # contains strings, not [Translation] instances). The array may also
21
+ # contain +nil+ entries where translations could not be found.
22
+ def lookup_translations(locale, phrases)
23
+ raise NotImplementedError,
24
+ 'expected to be implemented in derived classes'
25
+ end
26
+
27
+ # Retrieves a single translation for the given phrase.
28
+ #
29
+ # @param [Locale] locale The locale of the translation to retrieve.
30
+ # @param [Phrase] phrase The phrase to retrieve the translation for.
31
+ # @return [String] the translation or nil of one cannot be found.
32
+ def lookup_translation(locale, phrase)
33
+ raise NotImplementedError,
34
+ 'expected to be implemented in derived classes'
35
+ end
36
+
37
+ # Publishes a list of phrases in the repository. For web-based translation
38
+ # management systems, this probably means uploading phrases to be
39
+ # translated over HTTP.
40
+ #
41
+ # @param [Array<Phrase>] phrases The list of phrases to store.
42
+ # @param [String] commit_id The commit id to associate the phrases with.
43
+ # @return [void]
44
+ def store_phrases(phrases, commit_id)
45
+ raise NotImplementedError,
46
+ 'expected to be implemented in derived classes'
47
+ end
48
+
49
+ # Publishes a phrase in the repository. For web-based translation
50
+ # management systems, this probably means uploading the phrase over HTTP.
51
+ #
52
+ # @param [Phrase] phrase The phrase to store.
53
+ # @param [String] commit_id The commit id to associate the phrase with.
54
+ # @return [void]
55
+ def store_phrase(phrase, commit_id)
56
+ raise NotImplementedError,
57
+ 'expected to be implemented in derived classes'
58
+ end
59
+
60
+ # Calculates a single unique value for the phrases and translations
61
+ # associated with a given commit id. Often this is calculated using a
62
+ # one-way hash like MD5 or SHA1. Checksum values can be compared to
63
+ # determine when translations for the given commit id have changed.
64
+ #
65
+ # @param [Locale] locale The locale to calculate the checksum for.
66
+ # @param [String] commit_id The commit id that contains the phrases and
67
+ # translations to calculate the checksum for.
68
+ # @return [String] the calculated checksum value
69
+ def checksum_for(locale, commit_id)
70
+ raise NotImplementedError,
71
+ 'expected to be implemented in derived classes'
72
+ end
73
+
74
+ # Collects and calculates status information for the phrases contained in
75
+ # the given commit as well as their translations per locale.
76
+ #
77
+ # @param [String] commit_id The commit id to calculate the status for.
78
+ # @return [TranslationStatus]
79
+ def status(commit_id)
80
+ raise NotImplementedError,
81
+ 'expected to be implemented in derived classes'
82
+ end
83
+
84
+ # Signals the repository to perform any cleanup tasks that may be required
85
+ # for the given commit once it's been fully processed.
86
+ #
87
+ # @param [String] commit_id
88
+ def finalize(commit_id)
89
+ raise NotImplementedError,
90
+ 'expected to be implemented in derived classes'
91
+ end
92
+
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,24 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+ require 'rosette/core/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "rosette-core"
6
+ s.version = ::Rosette::Core::VERSION
7
+ s.authors = ["Cameron Dutro"]
8
+ s.email = ["camertron@gmail.com"]
9
+ s.homepage = "http://github.com/camertron"
10
+
11
+ s.description = s.summary = "Core classes for the Rosette internationalization platform."
12
+
13
+ s.platform = Gem::Platform::RUBY
14
+ s.has_rdoc = true
15
+
16
+ s.add_dependency 'progress-reporters', '~> 1.0.0'
17
+ s.add_dependency 'activesupport', '>= 3.2.0'
18
+ s.add_dependency 'aasm', '~> 4.1.0'
19
+ s.add_dependency 'concurrent-ruby', '~> 0.7'
20
+ s.requirements << "jar 'org.eclipse.jgit:org.eclipse.jgit', '3.4.1.201406201815-r'"
21
+
22
+ s.require_path = 'lib'
23
+ s.files = Dir["{lib,spec}/**/*", "Gemfile", "History.txt", "README.md", "Rakefile", "rosette-core.gemspec"]
24
+ end