lingohub 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,8 +9,8 @@ We use the option `--locale <locale as filter>` for `translation:down` because o
9
9
  stored in a folder per locale:
10
10
 
11
11
  ``` bash
12
- lingohub translation:down --locale 'en' --directory config/locales/en --project 'lingohub' --all
13
- lingohub translation:down --locale 'de' --directory config/locales/de --project 'lingohub' --all
12
+ lingohub resource:down --locale 'en' --directory config/locales/en --project 'lingohub' --all
13
+ lingohub resource:down --locale 'de' --directory config/locales/de --project 'lingohub' --all
14
14
  ```
15
15
 
16
16
 
@@ -46,7 +46,8 @@ module Lingohub::Command
46
46
  group.command 'project:info --project <name>', 'show project info, like web url and number of translations'
47
47
  group.command 'project:open --project <name>', 'open the project in a web browser'
48
48
  group.command 'project:rename <oldname> <newname>', 'rename the project'
49
- group.command 'project:archive --project <name>', 'archive the project'
49
+ group.command 'project:deactivate --project <name>', 'deactivates the project'
50
+ group.command 'project:activate --project <name>', 'activates a deactivated project again'
50
51
  group.space
51
52
  end
52
53
 
@@ -58,10 +59,10 @@ module Lingohub::Command
58
59
  end
59
60
 
60
61
  group 'Translation Commands' do |group|
61
- group.command 'translation:down --all --directory <path> --project <name>', 'download all resource files'
62
- group.command 'translation:down --locale <iso2_slug> --all --directory <path> --project <name>', 'download all resource files, using the given locale as filter'
63
- group.command 'translation:down <file1> <file2> ... --directory <path> --project <name>', 'download specific resource files'
64
- group.command 'translation:up <file1> <file2> ... --locale <iso2_slug> --project <name>', 'upload specific resource files, a locale may be specified to tell lingohub the locale of file content'
62
+ group.command 'resource:down --all --directory <path> --project <name>', 'download all resource files'
63
+ group.command 'resource:down --locale <iso2_slug> --all --directory <path> --project <name>', 'download all resource files, using the given locale as filter'
64
+ group.command 'resource:down <file1> <file2> ... --directory <path> --project <name>', 'download specific resource files'
65
+ group.command 'resource:up <file1> <file2> ... --locale <iso2_slug> --project <name>', 'upload specific resource files, a locale may be specified to tell lingohub the locale of file content'
65
66
  group.space
66
67
  end
67
68
  end
@@ -15,9 +15,11 @@ module Lingohub::Command
15
15
  def list
16
16
  list = lingohub.projects.all
17
17
  if list.size > 0
18
- display "Projects:\n" + list.keys.map { |name|
19
- "- #{name}"
20
- }.join("\n")
18
+ display "Projects:\n"
19
+ list.each_pair { |name, project|
20
+ inactive_str = project.inactive? ? '(inactive)' : ''
21
+ display "- #{name} #{inactive_str}"
22
+ }
21
23
  else
22
24
  display "You have no projects."
23
25
  end
@@ -50,18 +52,25 @@ module Lingohub::Command
50
52
  Launchy.open project.weburl
51
53
  end
52
54
 
53
- def archive
55
+ def deactivate
54
56
  display "=== #{project.title}"
55
57
  display "Web URL: #{project.weburl}"
56
58
  display "Owner: #{project.owner}"
57
59
 
58
60
  if confirm_command(project.title)
59
- redisplay "Destroying #{project.title} ... "
61
+ redisplay "Deactivating #{project.title} ... "
60
62
  project.destroy
61
63
  display "done"
62
64
  end
63
65
  end
64
66
 
67
+ def activate
68
+ redisplay "Activating #{project.title} ... "
69
+ project.activate
70
+ display "done"
71
+ end
72
+
73
+
65
74
  end
66
75
 
67
76
  end
@@ -1,22 +1,22 @@
1
1
  module Lingohub::Command
2
- class Translation < Base
2
+ class Resource < Base
3
3
  def down
4
4
  project #project validation
5
5
 
6
6
  directory = File.join(Dir.pwd, extract_directory_from_args || "")
7
- raise(CommandFailed, "Error downloading translations. Path #{directory} does not exist") unless File.directory?(directory)
7
+ raise(CommandFailed, "Error downloading resources. Path #{directory} does not exist") unless File.directory?(directory)
8
8
 
9
9
  if extract_query_from_args
10
10
  pull_search_results(directory)
11
11
  else
12
- pull_resources(directory)
12
+ download_resources(directory)
13
13
  end
14
14
  end
15
15
 
16
16
  def up
17
17
  project #project validation
18
18
 
19
- push_resources(args)
19
+ upload_resources(args)
20
20
  end
21
21
 
22
22
  private
@@ -70,13 +70,13 @@ module Lingohub::Command
70
70
  end
71
71
  end
72
72
 
73
- def pull_resources(directory)
73
+ def download_resources(directory)
74
74
  files_source = extract_all_from_args ? project.resources.keys : args
75
75
  locale_as_filter = extract_locale_from_args
76
76
 
77
77
  files_source.each do |file_name|
78
78
  begin
79
- downloaded = project.pull_resource(directory, file_name, locale_as_filter)
79
+ downloaded = project.download_resource(directory, file_name, locale_as_filter)
80
80
  display("#{file_name} downloaded") if downloaded
81
81
  rescue
82
82
  display "Error downloading #{file_name}. Response: #{$!.message || $!.response}"
@@ -84,11 +84,11 @@ module Lingohub::Command
84
84
  end
85
85
  end
86
86
 
87
- def push_resources(resources)
87
+ def upload_resources(resources)
88
88
  resources.each do |file_name|
89
89
  begin
90
90
  path = File.expand_path(file_name, Dir.pwd)
91
- project.push_resource(path, extract_locale_from_args)
91
+ project.upload_resource(path, extract_locale_from_args)
92
92
  display("#{file_name} uploaded")
93
93
  rescue
94
94
  display "Error uploading #{file_name}. Response: #{$!.message || $!.response}"
@@ -19,8 +19,8 @@ module Lingohub
19
19
  end
20
20
 
21
21
 
22
- lazy_attr_accessor(:title, :link, :weburl, :resources_url, :collaborators_url, :invitations_url,
23
- :translations_url, :search_url, :owner, :description, :opensource, :project_locales)
22
+ lazy_attr_accessor(:title, :link, :deactivated_at, :weburl, :resources_url, :collaborators_url, :invitations_url,
23
+ :translations_url, :search_url, :activate_url, :owner, :description, :opensource, :project_locales)
24
24
 
25
25
  def initialize(client, link)
26
26
  @client = client
@@ -35,6 +35,10 @@ module Lingohub
35
35
  @client.delete self.link
36
36
  end
37
37
 
38
+ def activate
39
+ @client.put self.activate_url, {}
40
+ end
41
+
38
42
  def update(attributes={ })
39
43
  @client.put self.link, { :project => attributes }
40
44
  end
@@ -43,6 +47,10 @@ module Lingohub
43
47
  @client.post(self.invitations_url, :invitation => { :email => email })
44
48
  end
45
49
 
50
+ def inactive?
51
+ !deactivated_at.nil?
52
+ end
53
+
46
54
  def resources
47
55
  unless defined? @resources
48
56
  @resources = { }
@@ -74,7 +82,7 @@ module Lingohub
74
82
  @collaborators
75
83
  end
76
84
 
77
- def pull_resource(directory, filename, locale_as_filter = nil)
85
+ def download_resource(directory, filename, locale_as_filter = nil)
78
86
  raise "Project does not contain that file." unless self.resources.has_key?(filename)
79
87
  resource = self.resources[filename]
80
88
 
@@ -86,7 +94,7 @@ module Lingohub
86
94
  end
87
95
  end
88
96
 
89
- def push_resource(path, locale)
97
+ def upload_resource(path, locale)
90
98
  raise "Path #{path} does not exists" unless File.exists?(path)
91
99
  request = { :file => File.new(path, "rb") }
92
100
  request.merge!({ :iso2_slug => locale }) if locale
@@ -115,13 +123,15 @@ module Lingohub
115
123
  collaborators_url = links[4]["href"]
116
124
  invitations_url = links[5]["href"]
117
125
  search_url = links[6]["href"]
126
+ activate_url = links[7]["href"]
118
127
 
119
- init_attributes :title => project_hash["title"], :link => link, :weburl => weburl,
128
+ init_attributes :title => project_hash["title"], :link => link,
129
+ :deactivated_at => project_hash["deactivated_at"], :weburl => weburl,
120
130
  :owner => project_hash["owner_email"], :description => project_hash["description"],
121
131
  :opensource => project_hash["opensource"], :project_locales => project_hash["project_locales"],
122
132
  :translations_url => translations_url, :resources_url => resources_url,
123
133
  :collaborators_url => collaborators_url, :invitations_url => invitations_url,
124
- :search_url => search_url
134
+ :search_url => search_url, :activate_url => activate_url
125
135
  end
126
136
 
127
137
  def init_attributes(attributes)
@@ -1,4 +1,4 @@
1
1
  module Lingohub
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  API_VERSION = 'v1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lingohub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-08 00:00:00.000000000 Z
12
+ date: 2012-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &70097816752880 !ruby/object:Gem::Requirement
16
+ requirement: &70136106529520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.6.7
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70097816752880
24
+ version_requirements: *70136106529520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: launchy
27
- requirement: &70097816752380 !ruby/object:Gem::Requirement
27
+ requirement: &70136106529020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70097816752380
35
+ version_requirements: *70136106529020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: stringex
38
- requirement: &70097816751920 !ruby/object:Gem::Requirement
38
+ requirement: &70136106528560 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.3.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70097816751920
46
+ version_requirements: *70136106528560
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70097816751460 !ruby/object:Gem::Requirement
49
+ requirement: &70136106528100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.9.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70097816751460
57
+ version_requirements: *70136106528100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec
60
- requirement: &70097816751000 !ruby/object:Gem::Requirement
60
+ requirement: &70136106527640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.8.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70097816751000
68
+ version_requirements: *70136106527640
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakefs
71
- requirement: &70097816750540 !ruby/object:Gem::Requirement
71
+ requirement: &70136106527180 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.4.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70097816750540
79
+ version_requirements: *70136106527180
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: taps
82
- requirement: &70097816750080 !ruby/object:Gem::Requirement
82
+ requirement: &70136106526720 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.3.23
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70097816750080
90
+ version_requirements: *70136106526720
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &70097816749620 !ruby/object:Gem::Requirement
93
+ requirement: &70136106526260 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.8.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70097816749620
101
+ version_requirements: *70136106526260
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: i18n
104
- requirement: &70097816749160 !ruby/object:Gem::Requirement
104
+ requirement: &70136106525800 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.6.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70097816749160
112
+ version_requirements: *70136106525800
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: vcr
115
- requirement: &70097816748700 !ruby/object:Gem::Requirement
115
+ requirement: &70136106525340 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: 2.0.0
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70097816748700
123
+ version_requirements: *70136106525340
124
124
  description: Client library and command-line tool to translate Ruby based apps with
125
125
  lingohub.
126
126
  email:
@@ -137,7 +137,7 @@ files:
137
137
  - lib/lingohub/commands/collaborator.rb
138
138
  - lib/lingohub/commands/help.rb
139
139
  - lib/lingohub/commands/project.rb
140
- - lib/lingohub/commands/translation.rb
140
+ - lib/lingohub/commands/resource.rb
141
141
  - lib/lingohub/commands/version.rb
142
142
  - lib/lingohub/helpers.rb
143
143
  - lib/lingohub/models/collaborator.rb
@@ -170,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  version: '0'
171
171
  segments:
172
172
  - 0
173
- hash: -467139527390330171
173
+ hash: 3946943841404928865
174
174
  required_rubygems_version: !ruby/object:Gem::Requirement
175
175
  none: false
176
176
  requirements:
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  segments:
181
181
  - 0
182
- hash: -467139527390330171
182
+ hash: 3946943841404928865
183
183
  requirements: []
184
184
  rubyforge_project:
185
185
  rubygems_version: 1.8.17