yamln8tor 0.0.3 → 0.0.4

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/.rbenv-version CHANGED
@@ -1 +1 @@
1
- 1.9.2-p290
1
+ ree-1.8.7-2012.02
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile CHANGED
@@ -1,3 +1,8 @@
1
1
  source :rubygems
2
2
 
3
3
  gemspec
4
+
5
+ gem "rspec", "~> 2.13.0"
6
+ gem "guard-rspec"
7
+ gem "rb-fsevent"
8
+ gem "pry"
data/Gemfile.lock CHANGED
@@ -1,18 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yamln8tor (0.0.1)
5
- psych
4
+ yamln8tor (0.0.3)
6
5
  thor
6
+ ya2yaml
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- psych (1.3.4)
11
+ coderay (0.9.8)
12
+ diff-lcs (1.2.4)
13
+ guard (1.4.0)
14
+ listen (>= 0.4.2)
15
+ thor (>= 0.14.6)
16
+ guard-rspec (1.2.1)
17
+ guard (>= 1.1)
18
+ listen (0.6.0)
19
+ method_source (0.6.5)
20
+ ruby_parser (>= 2.0.5)
21
+ pry (0.9.3)
22
+ coderay (>= 0.9.8)
23
+ method_source (>= 0.6.0)
24
+ ruby_parser (>= 2.0.5)
25
+ slop (~> 1.9.0)
26
+ rb-fsevent (0.9.2)
27
+ rspec (2.13.0)
28
+ rspec-core (~> 2.13.0)
29
+ rspec-expectations (~> 2.13.0)
30
+ rspec-mocks (~> 2.13.0)
31
+ rspec-core (2.13.1)
32
+ rspec-expectations (2.13.0)
33
+ diff-lcs (>= 1.1.3, < 2.0)
34
+ rspec-mocks (2.13.1)
35
+ ruby_parser (2.3.0)
36
+ sexp_processor (~> 3.0)
37
+ sexp_processor (3.0.6)
38
+ slop (1.9.1)
12
39
  thor (0.18.1)
40
+ ya2yaml (0.31)
13
41
 
14
42
  PLATFORMS
15
43
  ruby
16
44
 
17
45
  DEPENDENCIES
46
+ guard-rspec
47
+ pry
48
+ rb-fsevent
49
+ rspec (~> 2.13.0)
18
50
  yamln8tor!
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
9
+
data/lib/yamln8tor/cli.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "thor"
2
- require "psych"
2
+ require "yamln8tor/validator"
3
3
 
4
4
  module Yamln8tor
5
5
  class Cli < Thor
@@ -11,16 +11,18 @@ module Yamln8tor
11
11
 
12
12
  Dir.chdir(directory)
13
13
  files = Dir.glob "**/*.yml"
14
- files.each do |f|
15
- begin
16
- Psych.load_file(f)
17
- rescue Psych::SyntaxError => e
18
- errors << e
19
- puts e.message
20
- end
14
+
15
+ files.each do | file |
16
+ v = Validator.new(file)
17
+ v.validate
18
+ errors += v.errors unless v.errors.empty?
21
19
  end
22
20
 
23
- puts "Finished validating YAML files. Found #{errors.count} errors."
21
+ puts "Finished validating #{files.count} YAML files. Found #{errors.count} errors."
22
+
23
+ errors.each do |e|
24
+ puts e.filename + ": " + e.message
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -0,0 +1,31 @@
1
+ require "ya2yaml"
2
+ require "ostruct"
3
+ require "yaml"
4
+ $KCODE = "UTF8"
5
+
6
+ module Yamln8tor
7
+ class Validator
8
+ attr_reader :filename, :errors
9
+
10
+ def initialize(filename)
11
+ @filename = filename
12
+ @errors = []
13
+ end
14
+
15
+ def validate
16
+ ym = ::YAML.load read_file
17
+ ym.ya2yaml(:syck_compatible => true)
18
+ return true
19
+ rescue ArgumentError => e
20
+ error = ::OpenStruct.new(:message => e.message, :filename => filename)
21
+ errors << error
22
+ return false
23
+ end
24
+
25
+ private
26
+
27
+ def read_file
28
+ File.open(filename, "r")
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Yamln8tor
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Yamln8tor::Cli do
4
+ it "is testable"
5
+ end
@@ -0,0 +1 @@
1
+ en:
@@ -0,0 +1 @@
1
+ es:
@@ -0,0 +1 @@
1
+ it:
@@ -0,0 +1 @@
1
+ ko:j
@@ -0,0 +1,4 @@
1
+ lunch_choices:
2
+ - "muracci's curry"
3
+ - "galette 88"
4
+ - "super duper burger"
@@ -0,0 +1,4 @@
1
+ lunch_choices:
2
+ "muracci's curry
3
+ - "galette 88"
4
+ - "super duper burger"
@@ -0,0 +1,19 @@
1
+ require 'yamln8tor'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
@@ -0,0 +1,41 @@
1
+ require "spec_helper"
2
+
3
+ describe Yamln8tor::Validator do
4
+ let(:yaml_path) { "spec/fixtures/correct.yml" }
5
+ subject(:validator) { Yamln8tor::Validator.new(yaml_path) }
6
+
7
+ it "returns instance of validator" do
8
+ validator.should be_instance_of Yamln8tor::Validator
9
+ end
10
+
11
+ describe "#errors" do
12
+ subject(:errors) { validator.validate; validator.errors }
13
+
14
+ context "for valid file" do
15
+ let(:yaml_path) { "spec/fixtures/correct.yml" }
16
+
17
+ it { should be_empty }
18
+ end
19
+
20
+ context "for invalid file" do
21
+ let(:yaml_path) { "spec/fixtures/malformed.yml"}
22
+ it { should be_all { |err| err.message && err.filename == yaml_path } }
23
+ end
24
+ end
25
+
26
+ describe "#validate" do
27
+ subject(:validate) { validator.validate }
28
+
29
+ context "for valid file" do
30
+ let(:yaml_path) { "spec/fixtures/correct.yml" }
31
+
32
+ it { should be_true }
33
+ end
34
+
35
+ context "for invalid file" do
36
+ let(:yaml_path) { "spec/fixtures/malformed.yml"}
37
+
38
+ it { should be_false }
39
+ end
40
+ end
41
+ end
data/yamln8tor.gemspec CHANGED
@@ -15,5 +15,5 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Yamln8tor::VERSION
17
17
  gem.add_dependency "thor"
18
- gem.add_dependency "psych"
18
+ gem.add_dependency "ya2yaml"
19
19
  end
metadata CHANGED
@@ -1,90 +1,124 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: yamln8tor
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Andrew Hao
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-05-17 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-05-21 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: thor
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: psych
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: ya2yaml
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- description: Provides syntax checking on YAML files over Rails' i18n framework file
47
- structure
48
- email:
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: Provides syntax checking on YAML files over Rails' i18n framework file structure
49
+ email:
49
50
  - ahao@blurb.com
50
- executables:
51
+ executables:
51
52
  - yamln8tor
52
53
  extensions: []
54
+
53
55
  extra_rdoc_files: []
54
- files:
56
+
57
+ files:
55
58
  - .gitignore
56
59
  - .rbenv-version
60
+ - .rspec
57
61
  - Gemfile
58
62
  - Gemfile.lock
63
+ - Guardfile
59
64
  - README.md
60
65
  - Rakefile
61
66
  - bin/yamln8tor
62
67
  - lib/yamln8tor.rb
63
68
  - lib/yamln8tor/cli.rb
69
+ - lib/yamln8tor/validator.rb
64
70
  - lib/yamln8tor/version.rb
71
+ - spec/cli_spec.rb
72
+ - spec/fixtures/content/en.yml
73
+ - spec/fixtures/content/es.yml
74
+ - spec/fixtures/content/it.yml
75
+ - spec/fixtures/content/ko.yml
76
+ - spec/fixtures/correct.yml
77
+ - spec/fixtures/malformed.yml
78
+ - spec/spec_helper.rb
79
+ - spec/validator_spec.rb
65
80
  - yamln8tor.gemspec
66
81
  homepage: http://github.com/blurb/yamln8tor
67
82
  licenses: []
83
+
68
84
  post_install_message:
69
85
  rdoc_options: []
70
- require_paths:
86
+
87
+ require_paths:
71
88
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
89
+ required_ruby_version: !ruby/object:Gem::Requirement
73
90
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ hash: 3
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
99
  none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3
104
+ segments:
105
+ - 0
106
+ version: "0"
84
107
  requirements: []
108
+
85
109
  rubyforge_project:
86
- rubygems_version: 1.8.23
110
+ rubygems_version: 1.8.15
87
111
  signing_key:
88
112
  specification_version: 3
89
113
  summary: A Rails i18n yml validation framework.
90
- test_files: []
114
+ test_files:
115
+ - spec/cli_spec.rb
116
+ - spec/fixtures/content/en.yml
117
+ - spec/fixtures/content/es.yml
118
+ - spec/fixtures/content/it.yml
119
+ - spec/fixtures/content/ko.yml
120
+ - spec/fixtures/correct.yml
121
+ - spec/fixtures/malformed.yml
122
+ - spec/spec_helper.rb
123
+ - spec/validator_spec.rb
124
+ has_rdoc: