iye 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 726ab6075869c596ef587416dd1a1150e703454c
4
+ data.tar.gz: 1aa23bd0ef6399eb05bdff363a0dd696ed434806
5
+ SHA512:
6
+ metadata.gz: 84db15448835dff74e8345cd2de525e63ab3302818f87205523428c87ed5bd43c2d8a6a1178cd4244f0bc7fceef7fd2eee1d3174c83821652e074d7a1366a315
7
+ data.tar.gz: 5a4dc380f329e9979a2c3f50e68ad7c75070924557f75eeb9dbe325c7a9269112358f8e7df484a16a9038cacce7ee2eec3f4f93978bea504eafee8ce5a6e7a9d
data/README.md CHANGED
@@ -42,7 +42,16 @@ The source ships with a `config.ru` suitable for development use with `shotgun(1
42
42
 
43
43
  shotgun -p 5050
44
44
 
45
+ To run tests:
46
+
47
+ bundle install
48
+ bundle exec rake
49
+
45
50
  ## Troubleshooting
46
51
 
47
52
  **``psych.rb:203:in `parse': wrong number of arguments(2 for 1) (ArgumentError)``**
48
53
  : This is caused by a mismatch of the `psych` in standard library and the gem. The bug is fixed in Ruby 1.9.3-p194.
54
+
55
+ ## Build status
56
+
57
+ ![](https://travis-ci.org/firmafon/iye.svg?branch=master)
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "iye"
3
- s.version = "1.0.2"
4
- s.date = "2013-11-12"
3
+ s.version = "1.1.0"
4
+ s.date = "2015-04-17"
5
5
  s.summary = "I18n Yaml Editor"
6
6
  s.email = "hv@firmafon.dk"
7
7
  s.homepage = "http://github.com/firmafon/iye"
@@ -25,9 +25,9 @@ module I18nYamlEditor
25
25
  keys = key.split(".")
26
26
  keys.each_with_index {|k, idx|
27
27
  if keys.size - 1 == idx
28
- sub_result[k.to_sym] = value
28
+ sub_result[k.to_s] = value
29
29
  else
30
- sub_result = (sub_result[k.to_sym] ||= {})
30
+ sub_result = (sub_result[k.to_s] ||= {})
31
31
  end
32
32
  }
33
33
  rescue => e
@@ -2,12 +2,25 @@
2
2
 
3
3
  module I18nYamlEditor
4
4
  class Translation
5
- attr_accessor :name, :file, :text
5
+ attr_accessor :name, :file
6
+ attr_writer :text
6
7
 
7
8
  def initialize attributes={}
8
9
  @name, @file, @text = attributes.values_at(:name, :file, :text)
9
10
  end
10
11
 
12
+ def text
13
+ if @text.is_a?(String)
14
+ if @text.match(/\A\s*\z/)
15
+ nil
16
+ else
17
+ @text.gsub(/\r\n/, "\n")
18
+ end
19
+ else
20
+ @text
21
+ end
22
+ end
23
+
11
24
  def key
12
25
  @key ||= self.name.split(".")[1..-1].join(".")
13
26
  end
@@ -15,5 +28,13 @@ module I18nYamlEditor
15
28
  def locale
16
29
  @locale ||= self.name.split(".").first
17
30
  end
31
+
32
+ def number_of_lines
33
+ if text
34
+ text.scan(/\n/).size + 1
35
+ else
36
+ 1
37
+ end
38
+ end
18
39
  end
19
40
  end
@@ -1,6 +1,6 @@
1
1
  require "minitest/autorun"
2
2
  require "i18n_yaml_editor"
3
3
 
4
- class MiniTest::Unit::TestCase
4
+ class Minitest::Test
5
5
  include I18nYamlEditor
6
6
  end
@@ -3,5 +3,5 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/app"
5
5
 
6
- class TestApp < MiniTest::Unit::TestCase
6
+ class TestApp < Minitest::Test
7
7
  end
@@ -3,5 +3,5 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/category"
5
5
 
6
- class TestCategory < MiniTest::Unit::TestCase
6
+ class TestCategory < Minitest::Test
7
7
  end
@@ -3,7 +3,7 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/key"
5
5
 
6
- class TestKey < MiniTest::Unit::TestCase
6
+ class TestKey < Minitest::Test
7
7
  def test_category
8
8
  key = Key.new(name: "session.login")
9
9
  assert_equal "session", key.category
@@ -3,7 +3,7 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/store"
5
5
 
6
- class TestStore < MiniTest::Unit::TestCase
6
+ class TestStore < Minitest::Test
7
7
  def test_add_translations
8
8
  store = Store.new
9
9
  translation = Translation.new(:name => "da.session.login")
@@ -125,23 +125,24 @@ class TestStore < MiniTest::Unit::TestCase
125
125
  def test_to_yaml
126
126
  expected = {
127
127
  "/tmp/session.da.yml" => {
128
- da: {
129
- session: {
130
- login: "Log ind",
131
- logout: "Log ud"
128
+ "da" => {
129
+ "session" => {
130
+ "login" => "Log ind",
131
+ "logout" => "Log ud"
132
132
  }
133
133
  }
134
134
  },
135
135
  "/tmp/session.en.yml" => {
136
- en: {
137
- session: {
138
- login: "Sign in"
136
+ "en" => {
137
+ "session" => {
138
+ "login" => "Sign in"
139
139
  }
140
140
  }
141
141
  },
142
142
  "/tmp/da.yml" => {
143
- da: {
144
- app_name: "Oversætter"
143
+ "da" => {
144
+ "app_name" => "Oversætter",
145
+ "empty_string" => nil
145
146
  }
146
147
  }
147
148
  }
@@ -151,6 +152,7 @@ class TestStore < MiniTest::Unit::TestCase
151
152
  store.add_translation Translation.new(name: "en.session.login", text: "Sign in", file: "/tmp/session.en.yml")
152
153
  store.add_translation Translation.new(name: "da.session.logout", text: "Log ud", file: "/tmp/session.da.yml")
153
154
  store.add_translation Translation.new(name: "da.app_name", text: "Oversætter", file: "/tmp/da.yml")
155
+ store.add_translation Translation.new(name: "da.empty_string", text: "", file: "/tmp/da.yml")
154
156
 
155
157
  assert_equal expected, store.to_yaml
156
158
  end
@@ -3,14 +3,14 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/transformation"
5
5
 
6
- class TestTransformation < MiniTest::Unit::TestCase
6
+ class TestTransformation < Minitest::Test
7
7
  def test_flatten_hash
8
8
  input = {
9
- da: {
10
- session: {login: "Log ind", logout: "Log ud"}
9
+ "da" => {
10
+ "session" => {"login" => "Log ind", "logout" => "Log ud"}
11
11
  },
12
- en: {
13
- session: {login: "Log in", logout: "Log out"}
12
+ "en" => {
13
+ "session" => {"login" => "Log in", "logout" => "Log out"}
14
14
  }
15
15
  }
16
16
  expected = {
@@ -31,11 +31,11 @@ class TestTransformation < MiniTest::Unit::TestCase
31
31
  "en.session.logout" => "Log out"
32
32
  }
33
33
  expected = {
34
- da: {
35
- session: {login: "Log ind", logout: "Log ud"}
34
+ "da" => {
35
+ "session" => {"login" => "Log ind", "logout" => "Log ud"}
36
36
  },
37
- en: {
38
- session: {login: "Log in", logout: "Log out"}
37
+ "en" => {
38
+ "session" => {"login" => "Log in", "logout" => "Log out"}
39
39
  }
40
40
  }
41
41
 
@@ -3,7 +3,52 @@
3
3
  require "test_helper"
4
4
  require "i18n_yaml_editor/translation"
5
5
 
6
- class TestTranslation < MiniTest::Unit::TestCase
6
+ class TestTranslation < Minitest::Test
7
+ def test_text
8
+ translation = Translation.new(text: "Some string")
9
+ assert_equal "Some string", translation.text
10
+ end
11
+
12
+ def test_empty_text_is_nil
13
+ translation = Translation.new(text: "")
14
+ assert_nil translation.text
15
+ end
16
+
17
+ def test_text_with_space_is_nil
18
+ translation = Translation.new(text: " ")
19
+ assert_nil translation.text
20
+ end
21
+
22
+ def test_text_with_tab_is_nil
23
+ translation = Translation.new(text: "\t")
24
+ assert_nil translation.text
25
+ end
26
+
27
+ def test_text_is_array
28
+ translation = Translation.new(text: %w(a b c))
29
+ assert_equal %w(a b c), translation.text
30
+ end
31
+
32
+ def test_text_normalize_newlines
33
+ translation = Translation.new(text: "foo\r\nbar")
34
+ assert_equal "foo\nbar", translation.text
35
+ end
36
+
37
+ def test_number_of_lines_nil
38
+ translation = Translation.new(text: nil)
39
+ assert_equal 1, translation.number_of_lines
40
+ end
41
+
42
+ def test_number_of_lines_single_line
43
+ translation = Translation.new(text: "foo")
44
+ assert_equal 1, translation.number_of_lines
45
+ end
46
+
47
+ def test_number_of_lines_multiple_lines
48
+ translation = Translation.new(text: "foo\nbar\nbaz")
49
+ assert_equal 3, translation.number_of_lines
50
+ end
51
+
7
52
  def test_key
8
53
  translation = Translation.new(name: "da.session.login")
9
54
  assert_equal "session.login", translation.key
@@ -63,7 +63,7 @@
63
63
  width: 300px;
64
64
  }
65
65
 
66
- table.locales td.value input {
66
+ table.locales td.value textarea {
67
67
  width: 600px;
68
68
  }
69
69
 
@@ -19,7 +19,7 @@
19
19
  <td class="locale"><%= translation.locale %>:</td>
20
20
  <td class="value">
21
21
  <% if translation.text.nil? || translation.text.is_a?(String) %>
22
- <input type="text" name="translations[<%= translation.name %>]" value="<%= Rack::Utils.escape_html translation.text %>" />
22
+ <textarea cols=80 rows=<%= translation.number_of_lines %> name="translations[<%= translation.name %>]"><%= Rack::Utils.escape_html translation.text %></textarea>
23
23
  <% else %>
24
24
  [read only]
25
25
  <%= translation.text.class.name %>
@@ -41,4 +41,4 @@
41
41
  $('#save-on-top').click(function() {
42
42
  $('#updateform').submit();
43
43
  });
44
- </script>
44
+ </script>
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iye
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Harry Vangberg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-12 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cuba
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '3'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: tilt
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '1.3'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '1.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: psych
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.3.4
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.3.4
62
55
  description: I18n YAML Editor
@@ -68,8 +61,8 @@ extra_rdoc_files: []
68
61
  files:
69
62
  - README.md
70
63
  - Rakefile
71
- - iye.gemspec
72
64
  - bin/iye
65
+ - iye.gemspec
73
66
  - lib/i18n_yaml_editor.rb
74
67
  - lib/i18n_yaml_editor/app.rb
75
68
  - lib/i18n_yaml_editor/category.rb
@@ -78,9 +71,6 @@ files:
78
71
  - lib/i18n_yaml_editor/transformation.rb
79
72
  - lib/i18n_yaml_editor/translation.rb
80
73
  - lib/i18n_yaml_editor/web.rb
81
- - views/layout.erb
82
- - views/categories.html.erb
83
- - views/translations.html.erb
84
74
  - test/test_helper.rb
85
75
  - test/unit/test_app.rb
86
76
  - test/unit/test_category.rb
@@ -88,29 +78,31 @@ files:
88
78
  - test/unit/test_store.rb
89
79
  - test/unit/test_transformation.rb
90
80
  - test/unit/test_translation.rb
81
+ - views/categories.html.erb
82
+ - views/layout.erb
83
+ - views/translations.html.erb
91
84
  homepage: http://github.com/firmafon/iye
92
85
  licenses: []
86
+ metadata: {}
93
87
  post_install_message:
94
88
  rdoc_options: []
95
89
  require_paths:
96
90
  - lib
97
91
  required_ruby_version: !ruby/object:Gem::Requirement
98
- none: false
99
92
  requirements:
100
- - - ! '>='
93
+ - - ">="
101
94
  - !ruby/object:Gem::Version
102
95
  version: '0'
103
96
  required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
97
  requirements:
106
- - - ! '>='
98
+ - - ">="
107
99
  - !ruby/object:Gem::Version
108
100
  version: '0'
109
101
  requirements: []
110
102
  rubyforge_project:
111
- rubygems_version: 1.8.23
103
+ rubygems_version: 2.4.5
112
104
  signing_key:
113
- specification_version: 3
105
+ specification_version: 4
114
106
  summary: I18n Yaml Editor
115
107
  test_files:
116
108
  - test/test_helper.rb
@@ -120,4 +112,3 @@ test_files:
120
112
  - test/unit/test_store.rb
121
113
  - test/unit/test_transformation.rb
122
114
  - test/unit/test_translation.rb
123
- has_rdoc: