wti_tasks 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tasks/wti.rake +41 -0
- data/lib/wti_tasks/commands.rb +66 -0
- data/lib/wti_tasks.rb +9 -0
- metadata +48 -0
data/lib/tasks/wti.rake
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative '../wti_tasks/commands'
|
3
|
+
|
4
|
+
namespace :wti do
|
5
|
+
projects = WtiTasks::Commands.find_projects
|
6
|
+
|
7
|
+
namespace :pull do
|
8
|
+
desc "Pull wti translations for all projects (.wti*)"
|
9
|
+
task :all => projects.keys
|
10
|
+
|
11
|
+
projects.each do |project, file|
|
12
|
+
desc "Pull wti translations for #{project} project (#{file})"
|
13
|
+
task project do
|
14
|
+
puts WtiTasks::Commands.pull(file)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :push do
|
20
|
+
desc "Push wti translations for all projects (.wti*)"
|
21
|
+
task :all => projects.keys
|
22
|
+
|
23
|
+
projects.each do |project, file|
|
24
|
+
desc "Push wti translations for #{project} project (#{file})"
|
25
|
+
task project do
|
26
|
+
puts WtiTasks::Commands.push(file)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "How to pass arguments to wti rake tasks"
|
32
|
+
task :help do
|
33
|
+
puts %{
|
34
|
+
wti command options can be passed on to rake tasks by
|
35
|
+
separating them from rake options with --.
|
36
|
+
Example:
|
37
|
+
|
38
|
+
rake wti:pull:default -- --locale es --force
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module WtiTasks
|
2
|
+
class Commands
|
3
|
+
def self.find_projects
|
4
|
+
new.find_projects
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.pull(*args)
|
8
|
+
new.pull(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.push(*args)
|
12
|
+
new.push(*args)
|
13
|
+
end
|
14
|
+
|
15
|
+
def find_projects
|
16
|
+
project_names file_list
|
17
|
+
end
|
18
|
+
|
19
|
+
def pull(filename)
|
20
|
+
run_command(:pull, filename)
|
21
|
+
end
|
22
|
+
|
23
|
+
def push(filename)
|
24
|
+
run_command(:push, filename)
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_list
|
28
|
+
Dir.glob '.wti*'
|
29
|
+
end
|
30
|
+
|
31
|
+
def project_names(files)
|
32
|
+
files.inject({}) do |result, f|
|
33
|
+
result[project_name(f)] = f
|
34
|
+
result
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def project_name(file)
|
39
|
+
file = strip_prefix(file)
|
40
|
+
file = rename_default(file)
|
41
|
+
file.to_sym
|
42
|
+
end
|
43
|
+
|
44
|
+
def strip_prefix(file)
|
45
|
+
file.gsub(/\.wti-/, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
def rename_default(file)
|
49
|
+
file == '.wti' ? 'default' : file
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_command(command, filename)
|
53
|
+
wti_command = build_command command, filename
|
54
|
+
`#{wti_command}`
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_command(command, filename)
|
58
|
+
"wti #{command} -c #{filename}" << options
|
59
|
+
end
|
60
|
+
|
61
|
+
def options(argv = ARGV)
|
62
|
+
argv[0] = nil
|
63
|
+
argv.join(' ')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/wti_tasks.rb
ADDED
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wti_tasks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Martin Svalin
|
9
|
+
- Hilla Duka
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-09-03 00:00:00.000000000 Z
|
14
|
+
dependencies: []
|
15
|
+
description: Rake tasks for wti project push and pull
|
16
|
+
email: dev@mynewsdesk.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/wti_tasks.rb
|
22
|
+
- lib/tasks/wti.rake
|
23
|
+
- lib/wti_tasks/commands.rb
|
24
|
+
homepage: http://rubygems.org/gems/wti_tasks
|
25
|
+
licenses: []
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 1.8.10
|
45
|
+
signing_key:
|
46
|
+
specification_version: 3
|
47
|
+
summary: WebTranslateIt rake tasks
|
48
|
+
test_files: []
|