ObjCLocalizableConst 1.0.1 → 1.0.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 391c372852c7170bf9e0df99a0681a38646ff237
|
4
|
+
data.tar.gz: ace9757711d96cf213beb052ed265dc09ca164ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e22707aa27fdc098fe3bec90c9c494bf1cebc7f93566d5c20d687120075667ad4b2219969254d278c8f2ddf49d3fa14f4bc82be77c51d2329b2474ce491540
|
7
|
+
data.tar.gz: 124fa5263e3764f956bf097ba5d6b00c5e186b74f94a55ab3df3b7655d8d725ae1788011b2d03ab58e2c948f375ea082b64db120d07baea1d12e81339fa07164
|
data/bin/ObjCLocalizableConst
CHANGED
@@ -1,3 +1,33 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander/import'
|
5
|
+
require 'active_support/all'
|
6
|
+
|
7
|
+
require_relative '../lib/ObjCLocalizableConstGenerate'
|
8
|
+
require_relative '../lib/ObjCLocalizableConstReplace'
|
9
|
+
|
10
|
+
program :name, 'ObjCLocalizableConst'
|
11
|
+
program :version, '1.0.2'
|
12
|
+
program :description, 'Objective C Localizable to Constants!'
|
13
|
+
|
14
|
+
command :generate do |c|
|
15
|
+
c.syntax = 'generate <LocalizeFile> <DestSave> [options]'
|
16
|
+
c.summary = 'Create file constants from localize.strings'
|
17
|
+
c.example 'description', 'generate {PATH} {DIR}'
|
18
|
+
|
19
|
+
c.action do |args, options|
|
20
|
+
ObjCLocalizableConstGenerate.running(args[0], args[1])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
command :replace do |c|
|
25
|
+
c.syntax = 'replace <LocalizeFile> <Folder or File> [options]'
|
26
|
+
c.summary = 'Replace Strings in Folder using ConstFile.h'
|
27
|
+
c.example 'description', 'replace {PATH} {DIR or FILE}'
|
28
|
+
|
29
|
+
c.action do |args, options|
|
30
|
+
ObjCLocalizableConstReplace.running(args[0], args[1])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class ObjCLocalizableConstGenerate
|
2
|
+
def self.running(constantFile, path)
|
3
|
+
fail 'É necessário informar o arquivo de Constantes válido' if constantFile.nil? || !File.file?(constantFile)
|
4
|
+
fail 'É necessário informar onde deseja salvar o arquivo' if path.nil?
|
5
|
+
|
6
|
+
@contentConst = File.read(constantFile)
|
7
|
+
regx = /"(.+)"\s*=\s*"(.+)"\s*;/
|
8
|
+
@contentConst.gsub!(regx) do
|
9
|
+
key = $1
|
10
|
+
"static NSString * const kLocalizable#{key.gsub(".","_").camelcase} = @\"#{key}\";"
|
11
|
+
end
|
12
|
+
|
13
|
+
File.open(path, "w") {|file| file.puts @contentConst }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
class
|
1
|
+
class ObjCLocalizableConstReplace
|
2
2
|
def self.running(constantFile, path)
|
3
|
-
if constantFile.nil?
|
4
|
-
|
3
|
+
if constantFile.nil? || !File.file?(constantFile)
|
4
|
+
fail "É necessário informar do caminho do ClasseDeConstants.h Localize Válido"
|
5
5
|
end
|
6
6
|
|
7
7
|
@constantFile = constantFile
|
8
8
|
@constants = getMatchConst
|
9
9
|
|
10
10
|
if path.nil?
|
11
|
-
puts "É necessário informar o caminho dos arquivos que deseja trocar para Constant
|
11
|
+
puts "É necessário informar o caminho dos arquivos que deseja trocar para Constant"
|
12
12
|
return false
|
13
13
|
end
|
14
14
|
|
@@ -19,7 +19,7 @@ class ObjCLocalizableConst
|
|
19
19
|
elsif File.file?(path)
|
20
20
|
replaceInFiles([path])
|
21
21
|
else
|
22
|
-
puts "Pasta ou arquivo inválido
|
22
|
+
puts "Pasta ou arquivo inválido"
|
23
23
|
return false
|
24
24
|
end
|
25
25
|
|
@@ -37,7 +37,18 @@ class ObjCLocalizableConst
|
|
37
37
|
if File.file?(file)
|
38
38
|
content = File.read(file)
|
39
39
|
new_content = content.dup
|
40
|
-
@constants.each
|
40
|
+
@constants.each do |key, value|
|
41
|
+
if content.include?(value)
|
42
|
+
new_content.gsub!(value, key)
|
43
|
+
regex = /(^.*?(\w+)?\s*=\s*#{key};.*$)/
|
44
|
+
const_to_const = new_content.scan(regex)
|
45
|
+
unless const_to_const.empty?
|
46
|
+
new_content.gsub!(const_to_const[0][0], "")
|
47
|
+
new_content.gsub!(/(\W)#{const_to_const[0][1]}(\W)/){"#{$1}#{key}#{$2}"}
|
48
|
+
new_content.gsub!(/^$\n{2,}/, "\n")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
41
52
|
if content != new_content
|
42
53
|
File.open(file, "w") {|file| file.puts new_content }
|
43
54
|
puts "[Alterado] - #{file}"
|
@@ -47,4 +58,5 @@ class ObjCLocalizableConst
|
|
47
58
|
end
|
48
59
|
end
|
49
60
|
end
|
61
|
+
|
50
62
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ObjCLocalizableConst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Dias
|
@@ -9,7 +9,35 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-05-09 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.1'
|
13
41
|
description: Objective C Localizable to Constants.
|
14
42
|
email: rodrigogd@ciandt.com.br
|
15
43
|
executables:
|
@@ -18,7 +46,8 @@ extensions: []
|
|
18
46
|
extra_rdoc_files: []
|
19
47
|
files:
|
20
48
|
- bin/ObjCLocalizableConst
|
21
|
-
- lib/
|
49
|
+
- lib/ObjCLocalizableConstGenerate.rb
|
50
|
+
- lib/ObjCLocalizableConstReplace.rb
|
22
51
|
homepage: http://rubygems.org/gems/ObjCLocalizableConst
|
23
52
|
licenses:
|
24
53
|
- MIT
|