stringy 0.0.1 → 0.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: d244e57d49544f32e39dbf8bb44c021de56ec2b3
4
- data.tar.gz: 63bef50a62337f5bd07d0d747153eab76c245ffa
3
+ metadata.gz: 55871567022ba990377fed2910968c91ea3010b1
4
+ data.tar.gz: 730893de0de29a9b3461a10f2b7cb70156c23565
5
5
  SHA512:
6
- metadata.gz: 4178b8760042fe03c1cb6534abeb6465eccc3d2f887de16555ecd827e767b2050864a04ddecbee0b72b512ac5d3a2fe9b78c67b54e06946ae0764d908966f7c7
7
- data.tar.gz: a0401dafe6ad309ae0c0c209a3edb4bc048791efe81d0ad40b3b122ae7ed29e35b979cc45ba71f587918199806193437ccbebf79becea485adeb8e452d5210fb
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=".strings.new"
47
-
48
- isNewStringsFile = false
48
+ newStringsExt=".new"
49
49
 
50
50
  # Loop the storyboards in base
51
- Dir.glob("Base.lproj/*#{storyboardExt}") do |storyboardPath|
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
- if File.file?(baseStringsPath)
61
- isNewStringsFile = false
60
+ stringFileIsMissing = !File.file?(baseStringsPath)
61
+ if !stringFileIsMissing
62
+ storyboardIsNewer = File.mtime(storyboardPath) > File.mtime(baseStringsPath)
62
63
  else
63
- # If it we need to create the file.
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 isNewStringsFile || `find #{storyboardPath.chomp} -prune -newer #{baseStringsPath.chomp} -print | grep -q .` then
71
+ if options[:force] || stringFileIsMissing || storyboardIsNewer then
75
72
 
76
- puts storyboardPath + " is modified; update " + baseStringsPath if options[:verbose]
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
- if isNewStringsFile == false
86
- puts "Running: ibtool --export-strings-file #{newBaseStringsPath.chomp} #{storyboardPath.chomp}" if options[:verbose]
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 " + localeStringsDir if options[:verbose]
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 "" if !options[:verbose]
110
+ puts "" #just to add a line for formating
114
111
  end
115
112
  end
116
113
  end
@@ -1,3 +1,3 @@
1
1
  module Stringy
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
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-10 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler