sy18nc 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.
data/README.md CHANGED
@@ -6,7 +6,7 @@ Simple tool to synchronize Rails .ymls with locales.
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'sy18nc', '~> 0.0.1'
9
+ gem 'sy18nc', '~> 0.0.2'
10
10
 
11
11
  And then execute:
12
12
 
data/ext/array.rb CHANGED
@@ -3,30 +3,30 @@ class Array
3
3
  # element in the array if it's a hash, otherwise returns a blank hash.
4
4
  #
5
5
  # def options(*args)
6
- # args.extract_options!
6
+ # args.sy18nc_extract_options!
7
7
  # end
8
8
  #
9
9
  # options(1, 2) # => {}
10
10
  # options(1, 2, :a => :b) # => {:a=>:b}
11
- def extract_options!
12
- if last.is_a?(Hash) && last.extractable_options?
11
+ def sy18nc_extract_options!
12
+ if last.is_a?(Hash) && last.sy18nc_extractable_options?
13
13
  pop
14
14
  else
15
15
  {}
16
16
  end
17
17
  end
18
18
 
19
- def append!(val)
19
+ def sy18nc_append!(val)
20
20
  self.each do |v|
21
- v.append!(val)
21
+ v.sy18nc_append!(val)
22
22
  end
23
23
 
24
24
  self
25
25
  end
26
26
 
27
- def mark_fixme!
27
+ def sy18nc_mark_fixme!
28
28
  self.each do |v|
29
- v.mark_fixme!
29
+ v.sy18nc_mark_fixme!
30
30
  end
31
31
 
32
32
  self
data/ext/hash.rb CHANGED
@@ -2,13 +2,13 @@
2
2
  class Hash
3
3
  # Merge the two nested hashes, if the key is missing,
4
4
  # we replace it and deeply mark fixme
5
- def deep_merge!(other_hash)
5
+ def sy18nc_deep_merge!(other_hash)
6
6
  other_hash.each_pair do |other_key, other_value|
7
7
  self_value = self[other_key]
8
8
  self[other_key] = if self_value.is_a?(Hash) && other_value.is_a?(Hash)
9
- self_value.deep_merge!(other_value)
9
+ self_value.sy18nc_deep_merge!(other_value)
10
10
  elsif self_value.nil?
11
- other_value.mark_fixme!
11
+ other_value.sy18nc_mark_fixme!
12
12
  else
13
13
  self_value
14
14
  end
@@ -17,19 +17,19 @@ class Hash
17
17
  end
18
18
 
19
19
  # Appends the val to the every string in nested hash
20
- def append!(val)
20
+ def sy18nc_append!(val)
21
21
  self.each_pair do |key, value|
22
- self[key] = value.append!(val)
22
+ self[key] = value.sy18nc_append!(val)
23
23
  end
24
24
 
25
25
  self
26
26
  end
27
27
 
28
28
  # Marks the nested hash values with g FIXME
29
- # see also mark_fixme! in string
30
- def mark_fixme!
29
+ # see also sy18nc_mark_fixme! in string
30
+ def sy18nc_mark_fixme!
31
31
  self.each_pair do |key, value|
32
- self[key] = value.mark_fixme!
32
+ self[key] = value.sy18nc_mark_fixme!
33
33
  end
34
34
 
35
35
  self
@@ -38,9 +38,9 @@ class Hash
38
38
  # By default, only instances of Hash itself are extractable.
39
39
  # Subclasses of Hash may implement this method and return
40
40
  # true to declare themselves as extractable. If a Hash
41
- # is extractable, Array#extract_options! pops it from
41
+ # is extractable, Array#sy18nc_extract_options! pops it from
42
42
  # the Array when it is the last element of the Array.
43
- def extractable_options?
43
+ def sy18nc_extractable_options?
44
44
  instance_of?(Hash)
45
45
  end
46
46
  end
data/ext/object.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  class Object
2
- def append!(val)
2
+ def sy18nc_append!(val)
3
3
  self
4
4
  end
5
5
 
6
- def mark_fixme!
6
+ def sy18nc_mark_fixme!
7
7
  self
8
8
  end
9
9
  end
data/ext/string.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class String
2
- def mark_fixme!
2
+ def sy18nc_mark_fixme!
3
3
  # skip if it is already marked or its an alias
4
4
  if self =~ /g FIXME/ || self =~ /\*([a-z]*(\_)?)*/
5
5
  return self
@@ -8,7 +8,7 @@ class String
8
8
  self.replace("#{self} g FIXME")
9
9
  end
10
10
 
11
- def append!(val)
11
+ def sy18nc_append!(val)
12
12
  return self if self == ""
13
13
 
14
14
  self.replace("#{self}#{val}")
data/lib/sy18nc/locale.rb CHANGED
@@ -19,7 +19,7 @@ module Sy18nc
19
19
 
20
20
  # little hack
21
21
  # force double-quotes everywhere
22
- hash.append!("foo \nbar")
22
+ hash.sy18nc_append!("foo \nbar")
23
23
  end
24
24
 
25
25
  def synchronizable?
@@ -31,7 +31,7 @@ module Sy18nc
31
31
  end
32
32
 
33
33
  def synchronize(other)
34
- body.deep_merge!(other.body)
34
+ body.sy18nc_deep_merge!(other.body)
35
35
  end
36
36
 
37
37
  def to_yaml
@@ -1,7 +1,7 @@
1
1
  module Sy18nc
2
2
  class Synchronizer
3
3
  def initialize(*files)
4
- @options = files.extract_options!
4
+ @options = files.sy18nc_extract_options!
5
5
  @path, @base, *@locales = files
6
6
 
7
7
  @path = File.expand_path(@path)
@@ -1,3 +1,3 @@
1
1
  module Sy18nc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/ext_spec.rb CHANGED
@@ -3,17 +3,17 @@ require_relative 'spec_helper'
3
3
  describe Array do
4
4
  it "extracts options" do
5
5
  a = [1, 2, 3, 4, { option: true, option2: false }]
6
- a.extract_options!.must_equal({ option: true, option2: false })
6
+ a.sy18nc_extract_options!.must_equal({ option: true, option2: false })
7
7
  a.must_equal([1,2,3,4])
8
8
 
9
- a.extract_options!.must_equal({})
9
+ a.sy18nc_extract_options!.must_equal({})
10
10
  a.must_equal([1,2,3,4])
11
11
  end
12
12
 
13
13
  it "appends" do
14
14
  a = ["hello", "world"]
15
15
 
16
- a.append!("appended_string")
16
+ a.sy18nc_append!("appended_string")
17
17
 
18
18
  a.must_equal ["helloappended_string", "worldappended_string"]
19
19
  end
@@ -57,7 +57,7 @@ describe Hash do
57
57
  }
58
58
  }
59
59
 
60
- @hash.append!("appended_string").must_equal appended_hash
60
+ @hash.sy18nc_append!("appended_string").must_equal appended_hash
61
61
 
62
62
  hash2 = {
63
63
  :key1 => "helloworld",
@@ -77,7 +77,7 @@ describe Hash do
77
77
  ]
78
78
  }
79
79
 
80
- hash2.append!("appended_string").must_equal appended_hash2
80
+ hash2.sy18nc_append!("appended_string").must_equal appended_hash2
81
81
  end
82
82
 
83
83
  it "deep marks fixme" do
@@ -98,7 +98,7 @@ describe Hash do
98
98
  }
99
99
  }
100
100
 
101
- @hash.mark_fixme!
101
+ @hash.sy18nc_mark_fixme!
102
102
  @hash.must_equal fixme_hash
103
103
  end
104
104
 
@@ -131,7 +131,7 @@ describe Hash do
131
131
  }
132
132
  }
133
133
 
134
- other_hash.deep_merge!(@hash).must_equal result
134
+ other_hash.sy18nc_deep_merge!(@hash).must_equal result
135
135
  end
136
136
 
137
137
  it "deep merges hashes with nested arrays" do
@@ -139,11 +139,11 @@ describe Hash do
139
139
 
140
140
  describe String do
141
141
  it "marks fixme" do
142
- "Hello".mark_fixme!.must_equal("Hello g FIXME")
142
+ "Hello".sy18nc_mark_fixme!.must_equal("Hello g FIXME")
143
143
 
144
- "Hello g FIXME".mark_fixme!.must_equal("Hello g FIXME")
144
+ "Hello g FIXME".sy18nc_mark_fixme!.must_equal("Hello g FIXME")
145
145
 
146
- "*hello_world".mark_fixme!.must_equal("*hello_world")
146
+ "*hello_world".sy18nc_mark_fixme!.must_equal("*hello_world")
147
147
  end
148
148
  end
149
149
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sy18nc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-06 00:00:00.000000000 Z
12
+ date: 2013-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: psych