Skip to content

Commit 646c42c

Browse files
committed
Replace export with pull
1 parent caae13b commit 646c42c

File tree

7 files changed

+39
-39
lines changed

7 files changed

+39
-39
lines changed

lib/poeditor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ module POEditor
99
autoload :UI, "poeditor/ui"
1010

1111
# core
12-
autoload :Exporter, "poeditor/core/exporter"
12+
autoload :Core, "poeditor/core"
1313

1414
# command
1515
autoload :Command, "poeditor/commands/command"
16-
autoload :ExportCommand, "poeditor/commands/export_command"
16+
autoload :PullCommand, "poeditor/commands/pull_command"
1717
autoload :HelpCommand, "poeditor/commands/help_command"
1818
autoload :VersionCommand, "poeditor/commands/version_command"
1919

2020
# configuration
21-
autoload :ExportConfiguration, "poeditor/configurations/export_configuration"
21+
autoload :Configuration, "poeditor/configuration"
2222
end

lib/poeditor/commands/command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def self.run(argv)
1313

1414
def self.command_class(argv)
1515
case argv[0]
16-
when "export"
17-
ExportCommand
16+
when "pull"
17+
PullCommand
1818
when "--version"
1919
VersionCommand
2020
else
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module POEditor
22
class HelpCommand
33
def run(argv)
4-
puts "Usage: poeditor export"
4+
puts "Usage: poeditor [pull|help]"
55
end
66
end
77
end
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module POEditor
2-
class ExportCommand
2+
class PullCommand
33
def run(argv)
44
UI.puts "Reading configuration"
55
configuration = get_configuration(argv)
66
UI.puts configuration
7-
exporter = POEditor::Exporter.new(configuration)
8-
exporter.export_all()
7+
client = POEditor::Core.new(configuration)
8+
client.pull()
99
end
1010

1111
# Detects and returns the location of `poeditor.yml` file from the given
@@ -23,11 +23,11 @@ def get_configuration_file_path(argv)
2323
end
2424
end
2525

26-
# Returns {#POEditor::ExportConfiguration} from the given system arguments.
26+
# Returns {#POEditor::Configuration} from the given system arguments.
2727
#
2828
# @param argv [Array<String>] System arguments
2929
#
30-
# @return [POEditor::ExportConfiguration] The export configuration
30+
# @return [POEditor::Configuration] The export configuration
3131
def get_configuration(argv)
3232
config_path = get_configuration_file_path(argv)
3333
unless File.exist?(config_path)
@@ -37,7 +37,7 @@ def get_configuration(argv)
3737
}
3838
end
3939
yaml = YAML.load(File.read(config_path))
40-
ExportConfiguration.new(
40+
Configuration.new(
4141
api_key: get_or_raise(yaml, "api_key"),
4242
project_id: get_or_raise(yaml, "project_id"),
4343
type: get_or_raise(yaml, "type"),

lib/poeditor/configurations/export_configuration.rb renamed to lib/poeditor/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module POEditor
2-
class ExportConfiguration
2+
class Configuration
33
# @return [String] POEditor API key
44
# @see https://poeditor.com/account/api POEditor API Access
55
attr_accessor :api_key
@@ -29,7 +29,7 @@ def initialize(api_key:, project_id:, type:, tags:nil,
2929
languages:, language_alias:nil,
3030
path:, path_replace:nil)
3131
@api_key = from_env(api_key)
32-
@project_id = from_env(project_id)
32+
@project_id = from_env(project_id.to_s)
3333
@type = type
3434
@tags = tags || []
3535

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
require "net/http"
33

44
module POEditor
5-
class Exporter
6-
# @return [POEditor::ExportConfiguration] The configuration for export
5+
class Core
6+
# @return [POEditor::Configuration] The configuration for export
77
attr_accessor :configuration
88

9-
# @param configuration [POEditor::ExportConfiguration]
9+
# @param configuration [POEditor::Configuration]
1010
def initialize(configuration)
11-
unless configuration.is_a? ExportConfiguration
11+
unless configuration.is_a? Configuration
1212
raise POEditor::Exception.new \
13-
"`configuration` should be an `ExportConfiguration`"
13+
"`configuration` should be an `Configuration`"
1414
end
1515
@configuration = configuration
1616
end
@@ -31,8 +31,8 @@ def api(action, api_token, options={})
3131
return Net::HTTP.post_form(uri, options)
3232
end
3333

34-
# Exports all translations
35-
def export_all()
34+
# Pull translations
35+
def pull()
3636
UI.puts "\nExport translations"
3737
for language in @configuration.languages
3838
UI.puts " - Exporting '#{language}'"
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require_relative "test"
22

3-
class ExportTest < Test
3+
class CoreTest < Test
44

55
def clean
66
FileUtils.rm_rf("TestProj")
@@ -33,10 +33,10 @@ def teardown
3333
clean()
3434
end
3535

36-
def get_exporter(type:,
37-
languages:, language_alias:nil,
38-
path:, path_replace:nil)
39-
configuration = POEditor::ExportConfiguration.new(
36+
def get_client(type:,
37+
languages:, language_alias:nil,
38+
path:, path_replace:nil)
39+
configuration = POEditor::Configuration.new(
4040
:api_key => "TEST",
4141
:project_id => 12345,
4242
:type => type,
@@ -46,26 +46,26 @@ def get_exporter(type:,
4646
:path_replace => path_replace,
4747
:path => path,
4848
)
49-
POEditor::Exporter.new(configuration)
49+
POEditor::Core.new(configuration)
5050
end
5151

52-
def test_export_failure
52+
def test_pull_failure
5353
stub_api_export_failure()
54-
exporter = get_exporter(
54+
client = get_client(
5555
:type => "apple_strings",
5656
:languages => ["en", "ko"],
5757
:path => "",
5858
)
59-
assert_raises POEditor::Exception do exporter.export_all() end
59+
assert_raises POEditor::Exception do client.pull() end
6060
end
6161

62-
def test_export
63-
exporter = get_exporter(
62+
def test_pull
63+
client = get_client(
6464
:type => "apple_strings",
6565
:languages => ["en", "ko", "zh-Hans", "zh-Hant"],
6666
:path => "TestProj/{LANGUAGE}.lproj/Localizable.strings"
6767
)
68-
exporter.export_all()
68+
client.pull()
6969

7070
assert_match "Hi, %@!",
7171
File.read("TestProj/en.lproj/Localizable.strings")
@@ -83,14 +83,14 @@ def test_export
8383
assert File.read("TestProj/zh.lproj/Localizable.strings").length == 0
8484
end
8585

86-
def test_export_language_alias
87-
exporter = get_exporter(
86+
def test_pull_language_alias
87+
client = get_client(
8888
:type => "apple_strings",
8989
:languages => ["en", "ko", "zh-Hans", "zh-Hant"],
9090
:language_alias => {"zh" => "zh-Hans"},
9191
:path => "TestProj/{LANGUAGE}.lproj/Localizable.strings",
9292
)
93-
exporter.export_all()
93+
client.pull()
9494

9595
assert_match "Simplified 你好, %@!",
9696
File.read("TestProj/zh-Hans.lproj/Localizable.strings")
@@ -99,14 +99,14 @@ def test_export_language_alias
9999
File.read("TestProj/zh.lproj/Localizable.strings")
100100
end
101101

102-
def test_export_path_replace
103-
exporter = get_exporter(
102+
def test_pull_path_replace
103+
client = get_client(
104104
:type => "android_strings",
105105
:languages => ["en", "ko", "zh-rCN", "zh-rTW"],
106106
:path => "TestProj/values-{LANGUAGE}/strings.xml",
107107
:path_replace => {"en" => "TestProj/values/strings.xml"},
108108
)
109-
exporter.export_all()
109+
client.pull()
110110

111111
refute File.exist?("TestProj/values-en/strings.xml")
112112
assert_match "Hi, %s!",

0 commit comments

Comments
 (0)