ObjCLocalizableConst 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f905f792a3726b70775b614ad1203a52f284fe1b
4
+ data.tar.gz: 9746235262c1cc5194f38e4a5691f5d7fb74e80d
5
+ SHA512:
6
+ metadata.gz: 58797f0d737afdfea61211ede73c341c777b561ac4e79e6e781508e6d7b0a8bd2fdd8fd82f2f08aebf0013ae02929b5a8b4593defd04c3a3a20aa536a49da556
7
+ data.tar.gz: 43ec8ad3d753ed3c676d64839d8018b1d6b380dc8527adf0383a8e45576601349290f7b18e9a05b63515076bce7d9b932bc53d6ed4f35d3df63df4ea1226edcb
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'ObjCLocalizableConst'
3
+ ObjCLocalizableConst.running(ARGV[0], ARGV[1])
@@ -0,0 +1,50 @@
1
+ class ObjCLocalizableConst
2
+ def self.running(constantFile, path)
3
+ if constantFile.nil?
4
+ puts "É necessário informar o caminho da classe de Constants Localize."
5
+ end
6
+
7
+ @constantFile = constantFile
8
+ @constants = getMatchConst
9
+
10
+ if path.nil?
11
+ puts "É necessário informar o caminho dos arquivos que deseja trocar para Constant."
12
+ return false
13
+ end
14
+
15
+ path = path.chomp("/").chomp("\\")
16
+
17
+ if File.directory?(path)
18
+ replaceInFiles(Dir["#{path}/**/*.*"])
19
+ elsif File.file?(path)
20
+ replaceInFiles([path])
21
+ else
22
+ puts "Pasta ou arquivo inválido."
23
+ return false
24
+ end
25
+
26
+ end
27
+
28
+ def self.getMatchConst
29
+ content = File.read(@constantFile)
30
+ regx = /static NSString \* const (.+) = (@".+");/
31
+ return content.scan(regx).map{|e| {e[0] => e[1]}}.inject(:merge)
32
+ end
33
+
34
+ def self.replaceInFiles(files)
35
+ files.delete(@constantFile)
36
+ files.each do |file|
37
+ if File.file?(file)
38
+ content = File.read(file)
39
+ new_content = content.dup
40
+ @constants.each { |key, value| new_content.gsub!(value, key) if content.include?(value) }
41
+ if content != new_content
42
+ File.open(file, "w") {|file| file.puts new_content }
43
+ puts "[Alterado] - #{file}"
44
+ else
45
+ puts "[SEM Alteração] - #{file}"
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ObjCLocalizableConst
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Dias
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Objective C Localizable to Constants.
14
+ email: rodrigogd@ciandt.com.br
15
+ executables:
16
+ - ObjCLocalizableConst
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/ObjCLocalizableConst
21
+ - lib/ObjCLocalizableConst.rb
22
+ homepage: http://rubygems.org/gems/ObjCLocalizableConst
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.8
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Objective C Localizable to Constants!
46
+ test_files: []