mumukit-inspection 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YWQ3ZDg1ZGM5YWUzZTA0MjhhYWY0NzY3MWMxYzhhNDRkYjg5NzE1OQ==
5
+ data.tar.gz: !binary |-
6
+ MmU3M2UyOWFkNjU1MGIyMjhjYjY5ODIxYjNiOTNmNjVhYjBkNmYzOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ OGE0NjMxMTNmODZiN2NlMmJkN2E5OTVmZDU2MTllMWVkMzViZTc0YTFhODEz
10
+ NTEwMDhjM2NlNjc5NmQzOGY3ODgyZDE5MjA3YmY5ZGViOGY0MjUwMjk1NDUx
11
+ NWRhMjcwZGJmNjVkZTA4YjhlOGE0NzUxNzU5MzFkNGU0MjYzMGM=
12
+ data.tar.gz: !binary |-
13
+ OGRkODhkZmJmMmI1NDQ0ZGEwM2JhOWUyMWMxNDM5Mjg0NzU1ZDU0N2IwYzI2
14
+ N2EyNWZlZjQxMzI3OTFiZmIyMWNjZDU1Y2ZlZDZhOTVmNzQzNzI4MzJjNWZm
15
+ ZTk1NDhkZGE0NTFmNjZkZmRlYTQ2N2MwNjE2ZjQ0M2VkZjYwOTg=
@@ -0,0 +1,26 @@
1
+ ---
2
+ en:
3
+ expectation_HasArity: '%{binding} %{must} have %{target} parameters'
4
+ expectation_HasBinding: '%{binding} %{must} be defined'
5
+ expectation_HasComposition: '%{binding} %{must} use composition'
6
+ expectation_HasComprehension: '%{binding} %{must} use list comprehensions'
7
+ expectation_HasConditional: '%{binding} %{must} use conditionals'
8
+ expectation_HasDirectRecursion: '%{binding} %{must} use recursion'
9
+ expectation_HasForeach: '%{binding} %{must} use an indexed repetition (<i>foreach</i> statement)'
10
+ expectation_HasGuards: '%{binding} %{must} use guards'
11
+ expectation_HasIf: '%{binding} %{must} use if'
12
+ expectation_HasLambda: '%{binding} %{must} use lambda expressions'
13
+ expectation_HasRedundantBooleanComparison: '%{binding} has redundant boolean comparisons'
14
+ expectation_HasRedundantGuards: '%{binding} has redundant guards'
15
+ expectation_HasRedundantIf: '%{binding} has redundant ifs'
16
+ expectation_HasRedundantLambda: '%{binding} has redundant lambdas'
17
+ expectation_HasRedundantParameter: '%{binding} has redundant parameters - you may avoid them using point-free'
18
+ expectation_HasRepeat: '%{binding} %{must} use a simple repetition (<i>repeat</i> statement)'
19
+ expectation_HasRepeatOf: '%{binding} %{must} use a simple repetition (<i>repeat</i> sentence) of %{target}'
20
+ expectation_HasTypeDeclaration: type %{binding} %{must} be defined
21
+ expectation_HasTypeSignature: Signature for %{binding} %{must} be declared
22
+ expectation_HasUsage: '%{binding} %{must} use %{target}'
23
+ expectation_HasVariable: '%{binding} %{must} use variables'
24
+ expectation_HasWhile: '%{binding} %{must} use conditional repetition (<i>while</i> statement)'
25
+ expectation_must: must
26
+ expectation_must_not: must not
@@ -0,0 +1,26 @@
1
+ ---
2
+ es:
3
+ expectation_HasArity: '%{binding} %{must} tener %{target} parámetros'
4
+ expectation_HasBinding: '%{binding} %{must} estar definido'
5
+ expectation_HasComposition: '%{binding} %{must} usar composición'
6
+ expectation_HasComprehension: '%{binding} %{must} emplear listas por comprensión'
7
+ expectation_HasConditional: '%{binding} %{must} utilizar condicionales (guardas/if)'
8
+ expectation_HasDirectRecursion: '%{binding} %{must} emplear recursión'
9
+ expectation_HasForeach: '%{binding} %{must} usar una repetición indexada (sentencia <i>foreach</i>)'
10
+ expectation_HasGuards: '%{binding} %{must} usar guardas'
11
+ expectation_HasIf: '%{binding} %{must} usar if'
12
+ expectation_HasLambda: '%{binding} %{must} emplear expresiones lambda'
13
+ expectation_HasRedundantBooleanComparison: '%{binding} hace comparaciones booleanas innecesarias'
14
+ expectation_HasRedundantGuards: '%{binding} tiene guardas innecesarias'
15
+ expectation_HasRedundantIf: '%{binding} tiene ifs innecesarios'
16
+ expectation_HasRedundantLambda: '%{binding} tiene lambdas innecesarias'
17
+ expectation_HasRedundantParameter: '%{binding} tiene parámetros innecesarios (se pueden eliminar mediante point-free)'
18
+ expectation_HasRepeat: '%{binding} %{must} usar una repetición simple (sentencia <i>repeat</i>)'
19
+ expectation_HasRepeatOf: '%{binding} %{must} usar una repetición simple (sentencia <i>repeat</i>) de %{target}'
20
+ expectation_HasTypeDeclaration: '%{must} existir una declaración para el sinónimo de tipo %{binding}'
21
+ expectation_HasTypeSignature: La firma para %{binding} %{must} ser declarada
22
+ expectation_HasUsage: '%{binding} %{must} utilizar %{target}'
23
+ expectation_HasVariable: '%{binding} %{must} utilizar variables'
24
+ expectation_HasWhile: '%{binding} %{must} utilizar repetición condicional (sentencia <i>while</i>)'
25
+ expectation_must: debe
26
+ expectation_must_not: no debe
@@ -0,0 +1,86 @@
1
+ require 'i18n'
2
+ require 'i18n/backend/fallbacks'
3
+
4
+ I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
5
+ I18n.load_path += Dir[File.join(__dir__, '..', 'locales', '*.yml')]
6
+
7
+ I18n.backend.load_translations
8
+
9
+ require_relative '../mumukit/inspection/version'
10
+
11
+ module Mumukit
12
+ module Inspection
13
+ def self.parse(s)
14
+ not_match = s.match /^Not:(.*)$/
15
+ if not_match
16
+ NegatedInspection.new(parse_base_inspection(not_match[1]))
17
+ else
18
+ parse_base_inspection(s)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def self.parse_base_inspection(s)
25
+ target_match = s.match /^(.*):(.*)$/
26
+ if target_match
27
+ TargetedInspection.new(target_match[1], target_match[2])
28
+ else
29
+ PlainInspection.new(s)
30
+ end
31
+ end
32
+
33
+ class BaseInspection
34
+ def to_h
35
+ {negated: negated?, type: type, target: target}
36
+ end
37
+ end
38
+
39
+ class PositiveInspection < BaseInspection
40
+ attr_accessor :type
41
+
42
+ def negated?
43
+ false
44
+ end
45
+ end
46
+
47
+ class PlainInspection < PositiveInspection
48
+ def initialize(type)
49
+ @type = type
50
+ end
51
+
52
+ def target
53
+ nil
54
+ end
55
+ end
56
+
57
+ class TargetedInspection < PositiveInspection
58
+ attr_accessor :target
59
+
60
+ def initialize(type, target)
61
+ @type = type
62
+ @target = target
63
+ end
64
+ end
65
+
66
+ class NegatedInspection < BaseInspection
67
+ def initialize(inspection)
68
+ @inspection = inspection
69
+ end
70
+
71
+ def negated?
72
+ true
73
+ end
74
+
75
+ def target
76
+ @inspection.target
77
+ end
78
+
79
+ def type
80
+ @inspection.type
81
+ end
82
+ end
83
+ end
84
+ end
85
+
86
+ require_relative '../mumukit/inspection/i18n'
@@ -0,0 +1,38 @@
1
+ module Mumukit::Inspection
2
+
3
+ class Mumukit::Inspection::NegatedInspection
4
+ def must
5
+ 'must_not'
6
+ end
7
+ end
8
+
9
+ class Mumukit::Inspection::PositiveInspection
10
+ def must
11
+ 'must'
12
+ end
13
+ end
14
+
15
+ module I18n
16
+ class << self
17
+ def translate(expectation)
18
+ binding = expectation[:binding]
19
+ inspection = Mumukit::Inspection.parse expectation[:inspection]
20
+
21
+ ::I18n.t "expectation_#{inspection.type}",
22
+ binding: "<strong>#{binding}</strong>",
23
+ target: "<strong>#{inspection.target}</strong>",
24
+ must: t_must(inspection)
25
+ rescue
26
+ '<unknown expectation>'
27
+ end
28
+
29
+ alias t translate
30
+
31
+ private
32
+
33
+ def t_must(parsed)
34
+ ::I18n.t("expectation_#{parsed.must}")
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ module Mumukit
2
+ module Inspection
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumukit-inspection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: i18n
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.13'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: '2.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - flbulgarelli@yahoo.com.ar
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/locales/en.yml
91
+ - lib/locales/es.yml
92
+ - lib/mumukit/inspection.rb
93
+ - lib/mumukit/inspection/i18n.rb
94
+ - lib/mumukit/inspection/version.rb
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.5
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Minimal library for parsing Mumuki inspection language
119
+ test_files: []