apstrings 0.3.7 → 0.3.8

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: 214c6ebcd43ed72910ca02d269eceb66a9638407
4
- data.tar.gz: 2def09e490405096cbb85edbe0ba3d61b8e9ca53
3
+ metadata.gz: a5484430ea8af15f7c1cee46c176d1208c32353a
4
+ data.tar.gz: 69d503ac2b6c2eb39f0f9ec3bcf000485849b2a6
5
5
  SHA512:
6
- metadata.gz: 74c27433007ed1dfaa1486b58a8a1b2cc0f0300d52538ea5ecef08aff5de2c5f9f408d2e320fa480fb1dd207354e733191268cfdf75471ae99dcae7edb1738bb
7
- data.tar.gz: 18643aff518885079e3ed02b2165a6bbeb5711b65e147bd66b1b50fc25db28581e2a71ade167b3794bcaa5a823b84f2a9e2e0dc22bbc1502af2f1897be27d39c
6
+ metadata.gz: e6664b1c85584555a343ed344caf63a7086932d9ed09c4d88e9e8a13e20d5245748310bcc7bfd696a5fd31bb789d6e58660038096a6f053cc0aec0f1d9cdf8a8
7
+ data.tar.gz: 2eaff8297a82c636ac6dd4139abefc6584e16c8334fdb84706d01c1078d1537881e19408c5b5df7a17674a47540ee2cb1bcdfc968a420d4a2c157dfba1566aec
@@ -42,7 +42,8 @@ module Apstrings
42
42
  end
43
43
 
44
44
  def key_value_pair?
45
- !!(/^\s*"([^"]+)"\s*=/.match(content))
45
+ #Bugfix: 支持 "Key text \" with \" " = "Value text \" with \" "; 格式
46
+ !!(/^\s*"([^"]+)\S*\s*=/.match(content))
46
47
  end
47
48
 
48
49
  def cleaned_content
@@ -53,7 +54,7 @@ module Apstrings
53
54
  if key_value_pair?
54
55
  !!(/;[\s]*$/.match(content))
55
56
  else
56
- true
57
+ false
57
58
  end
58
59
  end
59
60
 
@@ -16,7 +16,6 @@ module Apstrings
16
16
  current_comment = nil
17
17
  comments_for_keys = {}
18
18
  @read_file.each do |content_line|
19
-
20
19
  current_line = Line.new(content_line)
21
20
  next if (current_line.empty_line? && current_line.in_comment == false) || !content_line.strip.start_with?("\"")
22
21
 
@@ -31,8 +31,8 @@ module Apstrings
31
31
  end
32
32
 
33
33
  def to_hash
34
- { :file=> File.basename(@file),
35
- :masterFile => File.basename(@masterFile),
34
+ { :file=> @file,
35
+ :masterFile => @masterFile,
36
36
  :master_special_character_error => @master_special_character_error,
37
37
  :file_special_character_errors => @file_special_character_errors ,
38
38
  :missing_keys => @missing_keys ,
@@ -1,3 +1,3 @@
1
1
  module Apstrings
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
@@ -2,14 +2,16 @@
2
2
  * Formats validate.
3
3
  *
4
4
  * Example
5
- * var master = 'Amount: %d Object: %@ String: %s Other: %u ';
6
- * var slave = '数值: %d OC对象: %@ 字符串: %s 其它: %u ';
7
- * var slave_err = '数值: % OC对象: %@ 字符串: %s 其它: %u ';
8
- * var result = validate(master, slave) // true
9
- * var result = validate(master, slave_err) // false
5
+ * var master = 'Amount: %.2f %2$lld Object: %@ String: %s Other: %u ';
6
+ * var slave = '数值: %.2f %2$lld OC对象: %@ 字符串: %s 其它: %u ';
7
+ * var slave_err = '数值: % f %2$lld OC对象: %@ 字符串: %s 其它: %u ';
8
+ * var result = formats_validate(master, slave) // true
9
+ * var result_err = formats_validate(master, slave_err) // false
10
10
  *
11
- * Created by Jason Kaer on 6/17/16.
11
+ * This implements format validation in IEEE Std 1003.1, 2004 Edition .
12
+ * Ref: http://pubs.opengroup.org/onlinepubs/009695399/functions/printf.html
12
13
  *
14
+ * Created by Jason Kaer on 6/17/16.
13
15
  */
14
16
 
15
17
  /***
@@ -57,7 +59,7 @@ function formats_validate(master, slave) {
57
59
  try {
58
60
  var format_m = formats_in_string(master);
59
61
  var format_s = formats_in_string(slave);
60
- return format_m.sort().equals(format_s.sort());
62
+ return format_m.equals(format_s);
61
63
  } catch (err) {
62
64
  console.log(err);
63
65
  return false;
@@ -73,7 +75,7 @@ function formats_validate(master, slave) {
73
75
  function formats_in_string(input) {
74
76
 
75
77
  var fix_regex = /%\d\$/g ;
76
- var scan_regex = /%[hlqLztj]?[@%dDuUxXoOfeEgGcCsSpaAF]/g ;
78
+ var scan_regex = /%['\-\+\#0]*[shlqLztj\.\*\d]*[@%diDuUxXoOfeEgGcCsSpPaAFn]/g ;
77
79
 
78
80
  //Strip numbered format placeholders , e.g. %1$@ --> %@
79
81
  var fixed_input = input.replace(fix_regex, "%");
@@ -88,3 +90,5 @@ function formats_in_string(input) {
88
90
 
89
91
  return result;
90
92
  }
93
+
94
+
data/lib/test.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  require './apstrings.rb'
2
2
 
3
- puts Apstrings.parse('/Users/Jason/Desktop/test.strings').to_json
3
+ puts Apstrings.parse('/Users/Jason/Desktop/zh-Hans.strings').to_json
4
4
 
5
-
6
- puts "aa : \" ".rstrip
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apstrings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - JasonWorking
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -95,7 +95,6 @@ files:
95
95
  - LICENSE.txt
96
96
  - README.md
97
97
  - Rakefile
98
- - apstrings-0.3.7.gem
99
98
  - apstrings.gemspec
100
99
  - bin/apstrings
101
100
  - lib/apstrings.rb
data/apstrings-0.3.7.gem DELETED
Binary file