tiendapp_validator 0.1.3 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0335ad02bf9cef037e1408bfbc5bfa7ac9c49f04
4
- data.tar.gz: 61376c5fa00b4572b311a952be879fa7f50657af
3
+ metadata.gz: fa8930701afe16b1326286654eb7281688427e39
4
+ data.tar.gz: 2d7d4beeaf66d12028d59cdd57508c891766629b
5
5
  SHA512:
6
- metadata.gz: ecdab7417e51d580a16f22ab850867335b319f6d7b868de6eb89be482ddbc57bb3e144d3c32f538d67fc305b64007fcb59a65c6a9e075824fd1e294234f0a853
7
- data.tar.gz: c121450bcb0e773c9a9ce982a0c76575b776cc3b756c945a975c7601510a5a047c9dcf94e5f05b210c6b9e7188755a3aaffb667c0fdabc71cab9c3baa7275821
6
+ metadata.gz: a65f0eda52bbdc2cda76051992b6518b734d2348da44591c5fcdf524ad5144e7abd5caab615339c746ed600de1ef3b0f0816a9db88a6bd61c22932e202a5fc3a
7
+ data.tar.gz: 6f13df006364808be300dab4614d8d168390a7733f55f704e5fc555e191167ca69d81a1090eb903d3ffc97f8f17cfd541b64362d1103c05b86b67d24cde5bb0b
@@ -2,11 +2,11 @@
2
2
  module TiendappValidator
3
3
  def self.root_path(path = nil)
4
4
  if path.nil?
5
- @root_path ||= DEFAULT_PATH
5
+ @root_path
6
6
  else
7
- @root_path = path
8
7
  @liquid_files = nil
9
8
  @customization_schemas = nil
9
+ @root_path = path
10
10
  end
11
11
  end
12
12
 
@@ -50,9 +50,9 @@ module TiendappValidator
50
50
  Find.find(root_path) do |p|
51
51
  next unless p.include? '.'
52
52
  next if permit_extension? p
53
- return response 'ERROR', 'not support extension: ' + p.split(root_path)[1], false
53
+ return response 'ERROR', I18n.t('error.not_support_extension', extension: p.split(root_path)[1]), false
54
54
  end
55
- response 'OK', 'all format support', true
55
+ response 'OK', I18n.t('ok.all_support_format'), true
56
56
  end
57
57
 
58
58
  def self.exist_liquid_file(str)
@@ -0,0 +1,21 @@
1
+ require 'yaml'
2
+ require 'i18n'
3
+
4
+ # TiendApp Validator I18n configurations
5
+ module TiendappValidator
6
+ DEFAULT_LANGUAGE = :es
7
+
8
+ yaml_dir_en = File.join(File.expand_path(__dir__), 'locales', 'en.yml')
9
+ yaml_dir_es = File.join(File.expand_path(__dir__), 'locales', 'es.yml')
10
+ I18n.backend.store_translations(:en, YAML.load(File.read(yaml_dir_en)))
11
+ I18n.backend.store_translations(:es, YAML.load(File.read(yaml_dir_es)))
12
+ I18n.locale = DEFAULT_LANGUAGE
13
+
14
+ def self.define_language(id)
15
+ if id == 'es'
16
+ I18n.locale = :es
17
+ elsif id == 'en'
18
+ I18n.locale = :en
19
+ end
20
+ end
21
+ end
@@ -6,9 +6,9 @@ module TiendappValidator
6
6
  def self.validate_liquid_files
7
7
  LIQUID_FILES.each do |liquid|
8
8
  next if liquid_files.include? root_path + liquid
9
- return response 'error', 'file not found: ' + liquid, false
9
+ return response 'error', I18n.t('error.file_not_found', liquid: liquid), false
10
10
  end
11
- response 'OK', 'found all liquid files.', true
11
+ response 'OK', I18n.t('ok.found_all_liquid_files'), true
12
12
  end
13
13
 
14
14
  # VL002 - Validar vistas parciales liquid
@@ -19,9 +19,9 @@ module TiendappValidator
19
19
  next if LIQUID_FILES.include? liquid
20
20
  next if liquid[0] == '_'
21
21
  next if (LIQUID_FILES_CHECKOUT + LIQUID_FILES_MAILER).include? liquid
22
- return response 'error', 'name invalid:' + liquid, false
22
+ return response 'error', I18n.t('error.name_invalid', liquid: liquid), false
23
23
  end
24
- response 'OK', 'partial liquid files are OK.', true
24
+ response 'OK', I18n.t('ok.partial_liquid_files'), true
25
25
  end
26
26
 
27
27
  # VL003 - Validar si todas las llamadas a vistas parciales existen
@@ -30,9 +30,9 @@ module TiendappValidator
30
30
  (LIQUID_FILES_CHECKOUT + LIQUID_FILES_MAILER).each do |liquid|
31
31
  next if liquid_files.include? path + CHECKOUT_PATH + liquid
32
32
  next if liquid_files.include? path + MAILER_PATH + liquid
33
- return response 'error', 'file not found: ' + liquid, false
33
+ return response 'error', I18n.t('error.file_not_found', liquid: liquid), false
34
34
  end
35
- response 'OK', 'found checkout liquid files', true
35
+ response 'OK', I18n.t('ok.found_checkout_liquid_files'), true
36
36
  end
37
37
 
38
38
  # VL004 - Validar si todas las llamadas a vistas parciales existen
@@ -42,11 +42,11 @@ module TiendappValidator
42
42
  includes = get_includes(content)
43
43
  includes.each do |include|
44
44
  unless exist_liquid_file(include[0])
45
- return response 'error', include[0] + 'not found', false
45
+ return response 'error', I18n.t('error.include_not_found', include: include[0]), false
46
46
  end
47
47
  end
48
48
  end
49
- response 'OK', 'all includes exists', true
49
+ response 'OK', I18n.t('ok.all_include_exists'), true
50
50
  end
51
51
 
52
52
  # VL006 - Valida que los archivos tengan sintaxis correcta en Liquid
@@ -54,8 +54,8 @@ module TiendappValidator
54
54
  file_paths = get_files root_path, 'liquid'
55
55
  file_paths.each do |liquid|
56
56
  next if Liquid::Template.parse(get_content(liquid), error_mode: :strict)
57
- return response 'error', 'syntax error: ' + liquid.split(root_path)[0], false
57
+ return response 'error', I18n.t(error.syntax_error, liquid: liquid.split(root_path)[0]), false
58
58
  end
59
- response 'OK', 'liquid files have correct syntax', true
59
+ response 'OK', I18n.t('ok.liquid_files_syntax'), true
60
60
  end
61
61
  end
@@ -0,0 +1,16 @@
1
+ error:
2
+ customization_schema_not_found: "Customization schema not found: '%{schema}'"
3
+ not_support_extension: "Not support extension: '%{extension}'"
4
+ file_not_found: "File not found: '%{liquid}'"
5
+ name_invalid: "Invalid name: '%{liquid}'"
6
+ include_not_found: "Partial '%{include}' don't exists"
7
+ syntax_error: "Syntax error: '%{file}'"
8
+ ok:
9
+ all_format_support: "All format supported"
10
+ found_all_customization_schema_files: "Found all customization schema files"
11
+ found_all_liquid_files: "Found all liquid files"
12
+ partial_liquid_files: "Partial liquid files are OK"
13
+ found_checkout_liquid_files: "Found checkout liquid files"
14
+ all_include_exists: "All includes exists"
15
+ liquid_files_syntax: "Liquid files have correct syntax"
16
+ all_validation: "All validation are OK"
@@ -0,0 +1,16 @@
1
+ error:
2
+ customization_schema_not_found: "No se encuentra esquema de customización: '%{schema}'"
3
+ not_support_extension: "Extensión no soportada: '%{extension}'"
4
+ file_not_found: "Archivo no encontrado: '%{liquid}'"
5
+ name_invalid: "Nombre invalido: '%{liquid}'"
6
+ include_not_found: "Vista parcial '%{include}' no existe"
7
+ syntax_error: "Error de sintaxis: '%{file}'"
8
+ ok:
9
+ all_format_support: "Todos los formatos soportados"
10
+ found_all_customization_schema_files: "Todos los esquemas de customización encontrados"
11
+ found_all_liquid_files: "Todos los archivos liquid entocontrados"
12
+ partial_liquid_files: "Las vistas parciales son correctas"
13
+ found_checkout_liquid_files: "Todos los archivos liquid de Checkout encontrados"
14
+ all_include_exists: "Todos los include encontrados"
15
+ liquid_files_syntax: "Los archivos liquid tienen sintaxis correcta"
16
+ all_validation: "Todas las validaciones están OK"
@@ -16,7 +16,6 @@ module TiendappValidator
16
16
  'shipped_order.liquid'].freeze
17
17
 
18
18
  # Paths basicos de los archivos necesarios
19
- DEFAULT_PATH = 'public/store_templates/public/'.freeze
20
19
  CHECKOUT_PATH = 'checkout/'.freeze
21
20
  MAILER_PATH = 'mailer/'.freeze
22
21
 
@@ -4,8 +4,8 @@ module TiendappValidator
4
4
  def self.validate_customation_schema_file
5
5
  SCHEMA_FILES.each do |schema|
6
6
  next if customization_schemas.include? root_path + 'config/' + schema
7
- response 'Error', 'Customization schema not found: ' + schema, false
7
+ return response 'Error', I18n.t('error.customization_schema_not_found', schema: schema) , false
8
8
  end
9
- response 'OK', 'found all customization schema files', true
9
+ response 'OK', I18n.t('ok.found_all_customization_schema_files'), true
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module TiendappValidator
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
@@ -3,6 +3,7 @@ require 'tiendapp_validator/required_files'
3
3
  require 'tiendapp_validator/auxiliar_methods'
4
4
  require 'tiendapp_validator/liquid_validators'
5
5
  require 'tiendapp_validator/schema_validators'
6
+ require 'tiendapp_validator/i18n'
6
7
  require 'find'
7
8
 
8
9
  # TiendApp Validator
@@ -22,7 +23,7 @@ module TiendappValidator
22
23
  next if res[:valid]
23
24
  return res
24
25
  end
25
- response 'OK', 'All validation are OK', true
26
+ response 'OK', I18n.t('ok.all_validation'), true
26
27
  end
27
28
 
28
29
  def self.print_response(res)
Binary file
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_runtime_dependency "liquid", "~> 3.0", ">= 3.0.6"
30
+ spec.add_runtime_dependency "i18n", "~> 0.7.0", ">= 0.7.0"
30
31
 
31
32
  spec.add_development_dependency "bundler", "~> 1.11"
32
33
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiendapp_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nahif
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-25 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.0.6
33
+ - !ruby/object:Gem::Dependency
34
+ name: i18n
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.7.0
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 0.7.0
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 0.7.0
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.7.0
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: bundler
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +110,10 @@ files:
90
110
  - bin/setup
91
111
  - lib/tiendapp_validator.rb
92
112
  - lib/tiendapp_validator/auxiliar_methods.rb
113
+ - lib/tiendapp_validator/i18n.rb
93
114
  - lib/tiendapp_validator/liquid_validators.rb
115
+ - lib/tiendapp_validator/locales/en.yml
116
+ - lib/tiendapp_validator/locales/es.yml
94
117
  - lib/tiendapp_validator/required_files.rb
95
118
  - lib/tiendapp_validator/schema_validators.rb
96
119
  - lib/tiendapp_validator/version.rb
@@ -157,6 +180,7 @@ files:
157
180
  - tiendapp_validator-0.1.0.gem
158
181
  - tiendapp_validator-0.1.1.gem
159
182
  - tiendapp_validator-0.1.2.gem
183
+ - tiendapp_validator-0.1.3.gem
160
184
  - tiendapp_validator-1.0.0.gem
161
185
  - tiendapp_validator.gemspec
162
186
  homepage: http://www.tiendapp.cl