stringy 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stringy/cli.rb +23 -26
- data/lib/stringy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55871567022ba990377fed2910968c91ea3010b1
|
4
|
+
data.tar.gz: 730893de0de29a9b3461a10f2b7cb70156c23565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f43bb9cc998a3f8bf4bb38d1a25ba240653c8e4782c686c376d3b27b0f24c9bce4783be884319ef6b17b846d652e1996a91fb64d6d7f79615a5e8711c900695
|
7
|
+
data.tar.gz: cf8ceadc46b6654ee98767375022fcd2d8b8f425c3fd94560672562c9d8e37e52b26d9dc788a7656201ed040588dc6d6c54db537445444d4c654bc35a66ae43b
|
data/lib/stringy/cli.rb
CHANGED
@@ -9,6 +9,7 @@ Thread.abort_on_exception = true
|
|
9
9
|
module Stringy
|
10
10
|
class CLI < Thor
|
11
11
|
class_option :verbose, :type => :boolean, :aliases => "-v"
|
12
|
+
class_option :force, :type => :boolean, :aliases => "-f"
|
12
13
|
|
13
14
|
method_option :overwrite, :type => :boolean, :aliases => "-o"
|
14
15
|
desc "update -v -o", "Updates then base stings and optionaly overwrites the tranlations"
|
@@ -40,15 +41,14 @@ module Stringy
|
|
40
41
|
|
41
42
|
# Set up some extentions
|
42
43
|
storyboardExt = ".storyboard"
|
44
|
+
xibExt = ".xib"
|
43
45
|
stringsExt = ".strings"
|
44
46
|
localeDirExt = ".lproj"
|
45
47
|
|
46
|
-
newStringsExt=".
|
47
|
-
|
48
|
-
isNewStringsFile = false
|
48
|
+
newStringsExt=".new"
|
49
49
|
|
50
50
|
# Loop the storyboards in base
|
51
|
-
Dir.glob("Base.lproj
|
51
|
+
Dir.glob("Base.lproj/*{#{storyboardExt},#{xibExt}}") do |storyboardPath|
|
52
52
|
|
53
53
|
# Create the base path (eg. settings)
|
54
54
|
baseStringsPath = storyboardPath.chomp(File.extname(storyboardPath)) + stringsExt
|
@@ -57,39 +57,34 @@ module Stringy
|
|
57
57
|
puts "Starting " + baseStringsPath if options[:verbose]
|
58
58
|
|
59
59
|
# Check if it exists
|
60
|
-
|
61
|
-
|
60
|
+
stringFileIsMissing = !File.file?(baseStringsPath)
|
61
|
+
if !stringFileIsMissing
|
62
|
+
storyboardIsNewer = File.mtime(storyboardPath) > File.mtime(baseStringsPath)
|
62
63
|
else
|
63
|
-
|
64
|
-
puts baseStringsPath + " file doesn't exist; create" if options[:verbose]
|
65
|
-
puts "Running: ibtool --export-strings-file #{baseStringsPath.chomp} #{storyboardPath.chomp}" if options[:verbose]
|
66
|
-
system("ibtool --export-strings-file #{baseStringsPath.chomp} #{storyboardPath.chomp}"+warningSuppressor)
|
67
|
-
|
68
|
-
puts baseStringsPath + " file created" if options[:verbose]
|
69
|
-
|
70
|
-
isNewStringsFile = true
|
64
|
+
storyboardIsNewer = false
|
71
65
|
end
|
72
66
|
|
67
|
+
puts "String file is missing" if options[:verbose] && stringFileIsMissing
|
68
|
+
puts "Storyboard is newer" if options[:verbose] && storyboardIsNewer
|
69
|
+
|
73
70
|
# Create strings file only when storyboard file newer and not just been created
|
74
|
-
if
|
71
|
+
if options[:force] || stringFileIsMissing || storyboardIsNewer then
|
75
72
|
|
76
|
-
puts
|
73
|
+
puts "Updating " + baseStringsPath if options[:verbose]
|
77
74
|
|
78
75
|
# Get storyboard file name and folder
|
79
76
|
storyboardDir = File.dirname(storyboardPath)
|
80
77
|
|
81
78
|
# Get New Base strings file full path and strings file name
|
82
|
-
newBaseStringsPath = `echo "#{storyboardPath}" | sed "s/#{storyboardExt}/#{newStringsExt}/"`.chomp
|
83
79
|
stringsFile = File.basename(baseStringsPath)
|
80
|
+
newBaseStringsPath = "#{storyboardDir}/#{stringsFile}#{newStringsExt}"
|
84
81
|
|
85
|
-
|
86
|
-
|
87
|
-
system("ibtool --export-strings-file #{newBaseStringsPath.chomp} #{storyboardPath.chomp}"+warningSuppressor)
|
88
|
-
|
89
|
-
puts "Running: iconv -f UTF-16 -t UTF-8 #{newBaseStringsPath.chomp} > #{baseStringsPath.chomp}" if options[:verbose]
|
90
|
-
system("iconv -f UTF-16 -t UTF-8 #{newBaseStringsPath.chomp} > #{baseStringsPath.chomp}"+warningSuppressor)
|
91
|
-
end
|
82
|
+
puts "Running: ibtool --export-strings-file #{newBaseStringsPath.chomp} #{storyboardPath.chomp}" if options[:verbose]
|
83
|
+
system("ibtool --export-strings-file #{newBaseStringsPath.chomp} #{storyboardPath.chomp}"+warningSuppressor)
|
92
84
|
|
85
|
+
puts "Running: iconv -f UTF-16 -t UTF-8 #{newBaseStringsPath.chomp} > #{baseStringsPath.chomp}" if options[:verbose]
|
86
|
+
system("iconv -f UTF-16 -t UTF-8 #{newBaseStringsPath.chomp} > #{baseStringsPath.chomp}")
|
87
|
+
|
93
88
|
FileUtils.rm(newBaseStringsPath) if File.exists?(newBaseStringsPath)
|
94
89
|
|
95
90
|
if options[:overwrite] then
|
@@ -101,16 +96,18 @@ module Stringy
|
|
101
96
|
|
102
97
|
localeStringsPath = localeStringsDir+"/"+stringsFile
|
103
98
|
|
104
|
-
puts "Move strings file in " +
|
99
|
+
puts "Move strings file in " + localeStringsPath if options[:verbose]
|
105
100
|
FileUtils.mkdir_p(File.dirname(localeStringsPath))
|
106
101
|
FileUtils.cp(baseStringsPath, localeStringsPath)
|
107
102
|
end
|
108
103
|
end
|
109
104
|
end
|
105
|
+
else
|
106
|
+
puts "No action needed" if options[:verbose]
|
110
107
|
end
|
111
108
|
end
|
112
109
|
|
113
|
-
puts ""
|
110
|
+
puts "" #just to add a line for formating
|
114
111
|
end
|
115
112
|
end
|
116
113
|
end
|
data/lib/stringy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Briggs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|