json-spec 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +13 -0
  3. data/Gemfile +3 -0
  4. data/README.md +27 -26
  5. data/cachivache/.gitignore +1 -1
  6. data/cachivache/README.md +176 -96
  7. data/cachivache/Rakefile +18 -9
  8. data/cachivache/Vagrantfile +3 -3
  9. data/cachivache/cachivache.rb +4 -6
  10. data/cachivache/lib/rake-helper.rb +27 -105
  11. data/cachivache/lib/shell-contexts/shell-context.rb +63 -0
  12. data/cachivache/lib/shell-contexts/shell-exec.rb +19 -0
  13. data/cachivache/lib/shell-contexts/shell_buffer.rb +25 -0
  14. data/cachivache/lib/shell-contexts/shell_debugger.rb +11 -0
  15. data/cachivache/lib/{sh-file-context.rb → shell-file-context.rb} +13 -16
  16. data/cachivache/lib/shell-if-context.rb +21 -0
  17. data/cachivache/lib/stuff-api-behaviour.rb +145 -0
  18. data/cachivache/lib/stuff-configuration.rb +55 -0
  19. data/cachivache/lib/stuff-reminders-behaviour.rb +11 -0
  20. data/cachivache/stuff/ruby-json-spec.rb +10 -14
  21. data/json-spec.gemspec +4 -2
  22. data/lib/cabeza-de-termo/json-spec/expectations-library/default-expectations/default-expectations-mapping.rb +1 -1
  23. data/lib/cabeza-de-termo/json-spec/expectations-library/definition-builders/expectation-builders/expectations-definition-builder.rb +2 -2
  24. data/lib/cabeza-de-termo/json-spec/expectations-library/definition-builders/expectation-library-definition-builder.rb +1 -1
  25. data/lib/cabeza-de-termo/json-spec/expectations-library/definition-builders/modifier-builders/modifiers-definition-builder.rb +1 -1
  26. data/lib/cabeza-de-termo/json-spec/expectations-library/expectations-library.rb +1 -1
  27. data/lib/cabeza-de-termo/json-spec/expressions/json-any-of.rb +1 -1
  28. data/lib/cabeza-de-termo/json-spec/expressions/json-each-field.rb +1 -1
  29. data/lib/cabeza-de-termo/json-spec/expressions/json-each.rb +1 -1
  30. data/lib/cabeza-de-termo/json-spec/expressions/json-expression.rb +2 -2
  31. data/lib/cabeza-de-termo/json-spec/expressions/json-field.rb +1 -1
  32. data/lib/cabeza-de-termo/json-spec/expressions/json-list.rb +1 -1
  33. data/lib/cabeza-de-termo/json-spec/expressions/json-object.rb +1 -1
  34. data/lib/cabeza-de-termo/json-spec/expressions/json-spec.rb +4 -4
  35. data/lib/cabeza-de-termo/json-spec/version.rb +1 -1
  36. metadata +27 -21
  37. data/cachivache/lib/let-behaviour.rb +0 -27
  38. data/cachivache/lib/sh-if-context.rb +0 -31
  39. data/lib/cabeza-de-termo/json-spec/utilities/bind.rb +0 -20
@@ -0,0 +1,55 @@
1
+ module Stuff
2
+ class Configuration
3
+ # Class methods
4
+ class << self
5
+ def variables()
6
+ @variables ||= {}
7
+ end
8
+
9
+ def has_variable?(name)
10
+ variables.key?(name)
11
+ end
12
+
13
+ def is_defined?(name)
14
+ has_variable?(name) && !self[name].nil?
15
+ end
16
+
17
+ def let(name, &block)
18
+ variables[name] = block
19
+ end
20
+
21
+ def [](name)
22
+ raise "Can't find variable named #{name.inspect}" unless has_variable?(name)
23
+ variables[name].call
24
+ end
25
+
26
+ protected
27
+
28
+ def method_missing(name, *more_args, &block)
29
+ return self[name] if more_args.empty? && block.nil?
30
+
31
+ super(name, *more_args, &block)
32
+ end
33
+
34
+ public
35
+
36
+ def class_named(class_name)
37
+ Object.const_get(class_name)
38
+ end
39
+
40
+ def ensure_subclass_exists(class_name)
41
+ define_subclass(class_name) unless is_class_defined?(class_name)
42
+ end
43
+
44
+ protected
45
+
46
+ def is_class_defined?(name)
47
+ Object.const_defined?(name)
48
+ end
49
+
50
+ def define_subclass(name)
51
+ Object.const_set(name, Class.new(self))
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,11 @@
1
+ module Stuff
2
+ module RemindersBehaviour
3
+ def show_reminders()
4
+ ShellContext.reminders.each { |alert| show_info(alert) }
5
+ end
6
+
7
+ def show_info(text)
8
+ ShellContext.show_info(text)
9
+ end
10
+ end
11
+ end
@@ -1,22 +1,18 @@
1
1
  dependencies = [
2
- :git,
2
+ :'projects-setup',
3
3
  :ruby
4
4
  ]
5
5
 
6
- namespace :'stuff' do
7
- desc 'Install ruby-json-spec'
8
- task :'ruby-json-spec' => dependencies do
9
- sh %Q{
10
- cd #{RubyJsonSpec.project_folder}
6
+ desc 'Install ruby-json-spec'
7
+ stuff :'ruby-json-spec' => dependencies do
8
+ shell %Q{
9
+ cd #{RubyJsonSpec.project_folder}
11
10
 
12
- bundle install
13
- rake test
14
- }
15
- end
11
+ bundle install
12
+ rake test
13
+ }
16
14
  end
17
15
 
18
- class RubyJsonSpec
19
- include LetBehaviour
20
-
16
+ configure :RubyJsonSpec do
21
17
  let(:project_folder) { Cachivache.src_folder }
22
- end
18
+ end
@@ -19,11 +19,13 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ spec.required_ruby_version = '>= 2.0'
23
+
24
+ spec.add_dependency "cdt-utilities", '~> 0.1'
22
25
  spec.add_dependency "validates_email_format_of", "~> 1.6"
23
26
 
24
27
  spec.add_development_dependency "bundler", "~> 1.10"
25
28
  spec.add_development_dependency "rake", "~> 10.0"
26
29
  spec.add_development_dependency "minitest"
27
30
  spec.add_development_dependency "colorize"
28
- spec.add_development_dependency "simplecov"
29
- end
31
+ end
@@ -47,7 +47,7 @@ module CabezaDeTermo
47
47
  end
48
48
 
49
49
  def for_every_expression_of(json_expression_type, &block)
50
- Bind.evaluation of: block, to: DefaultExpectationBuilder.new(self, json_expression_type)
50
+ CdT.bind_evaluation_of block, to: DefaultExpectationBuilder.new(self, json_expression_type)
51
51
  end
52
52
  end
53
53
  end
@@ -19,7 +19,7 @@ module CabezaDeTermo
19
19
  @expectations_library = expectations_library
20
20
  reset_current_definition
21
21
 
22
- Bind.evaluation of: block, to: self
22
+ CdT.bind_evaluation_of block, to: self
23
23
  end
24
24
 
25
25
  # Accessing
@@ -57,7 +57,7 @@ module CabezaDeTermo
57
57
  def define(method_name, &block)
58
58
  @method_name = method_name.to_sym
59
59
 
60
- Bind.evaluation of: block, to: self
60
+ CdT.bind_evaluation_of block, to: self
61
61
 
62
62
  define_expectation_in_library
63
63
  define_expectation_message_in_library
@@ -27,7 +27,7 @@ module CabezaDeTermo
27
27
  end
28
28
 
29
29
  def default_expectations(&block)
30
- Bind.evaluation of: block, to: expectations_library.default_expectations
30
+ CdT.bind_evaluation_of block, to: expectations_library.default_expectations
31
31
  self
32
32
  end
33
33
  end
@@ -11,7 +11,7 @@ module CabezaDeTermo
11
11
  def initialize(expectations_library, &block)
12
12
  @expectations_library = expectations_library
13
13
 
14
- Bind.evaluation of: block, to: self
14
+ CdT.bind_evaluation_of block, to: self
15
15
  end
16
16
 
17
17
  # Accessing
@@ -76,7 +76,7 @@ module CabezaDeTermo
76
76
  # Defining
77
77
 
78
78
  def define(&block)
79
- Bind.evaluation of: block, to: ExpectationLibraryDefinitionBuilder.new(self)
79
+ CdT.bind_evaluation_of block, to: ExpectationLibraryDefinitionBuilder.new(self)
80
80
  end
81
81
 
82
82
  # Expectation messages
@@ -34,7 +34,7 @@ module CabezaDeTermo
34
34
  def expect_a(type, &block)
35
35
  expression = add_posibble_expression( new_expression_for(type) )
36
36
 
37
- Bind.evaluation of: block, to: self unless block.nil?
37
+ CdT.bind_evaluation_of block, to: self unless block.nil?
38
38
 
39
39
  expression
40
40
  end
@@ -43,7 +43,7 @@ module CabezaDeTermo
43
43
  def expect_a(type, &block)
44
44
  @value_expression = new_expression_for(type)
45
45
 
46
- Bind.evaluation of: block, to: @value_expression unless block.nil?
46
+ CdT.bind_evaluation_of block, to: @value_expression unless block.nil?
47
47
 
48
48
  @value_expression
49
49
  end
@@ -43,7 +43,7 @@ module CabezaDeTermo
43
43
  def expect_a(type, &block)
44
44
  @each_item_expression = new_expression_for(type)
45
45
 
46
- Bind.evaluation of: block, to: @each_item_expression unless block.nil?
46
+ CdT.bind_evaluation_of block, to: @each_item_expression unless block.nil?
47
47
 
48
48
  @each_item_expression
49
49
  end
@@ -158,7 +158,7 @@ module CabezaDeTermo
158
158
 
159
159
  add_expectation(expectation)
160
160
 
161
- Bind.evaluation of: message.block, to: self unless message.block.nil?
161
+ CdT.bind_evaluation_of message.block, to: self unless message.block.nil?
162
162
 
163
163
  self
164
164
  end
@@ -178,7 +178,7 @@ module CabezaDeTermo
178
178
 
179
179
  run_modifier(modifier)
180
180
 
181
- Bind.evaluation of: message.block, to: self unless message.block.nil?
181
+ CdT.bind_evaluation_of message.block, to: self unless message.block.nil?
182
182
 
183
183
  self
184
184
  end
@@ -34,7 +34,7 @@ module CabezaDeTermo
34
34
 
35
35
  def to_be_a(type, &block)
36
36
  expression = set_value_expression( new_expression_for(type) )
37
- Bind.evaluation of: block, to: expression unless block.nil?
37
+ CdT.bind_evaluation_of block, to: expression unless block.nil?
38
38
  expression
39
39
  end
40
40
 
@@ -25,7 +25,7 @@ module CabezaDeTermo
25
25
  # Defining Expectations
26
26
 
27
27
  def each(&block)
28
- Bind.evaluation of: block, to: each_expression unless block.nil?
28
+ CdT.bind_evaluation_of block, to: each_expression unless block.nil?
29
29
 
30
30
  each_expression
31
31
  end
@@ -61,7 +61,7 @@ module CabezaDeTermo
61
61
  def each_field(&block)
62
62
  @each_field_expression = new_each_field
63
63
 
64
- Bind.evaluation of: block, to: @each_field_expression unless block.nil?
64
+ CdT.bind_evaluation_of block, to: @each_field_expression unless block.nil?
65
65
 
66
66
  @each_field_expression
67
67
  end
@@ -1,5 +1,5 @@
1
1
  require 'json'
2
- require "cabeza-de-termo/json-spec/utilities/bind"
2
+ require 'cdt/utilities/bind'
3
3
  require "cabeza-de-termo/json-spec/expectations-library/expectations-library"
4
4
  require "cabeza-de-termo/json-spec/walkers/validator/json-validator"
5
5
 
@@ -25,7 +25,7 @@ module CabezaDeTermo
25
25
  @expectation_messages_mapping = new_expectations_messages_mapping
26
26
  @default_expectations = new_default_expectations_mapping
27
27
 
28
- Bind.evaluation of: block, to: self unless block.nil?
28
+ CdT.bind_evaluation_of block, to: self unless block.nil?
29
29
  end
30
30
 
31
31
  # Accessing
@@ -49,7 +49,7 @@ module CabezaDeTermo
49
49
  # Default expectations
50
50
 
51
51
  def define(&block)
52
- Bind.evaluation of: block, to: ExpectationLibraryDefinitionBuilder.new(self)
52
+ CdT.bind_evaluation_of block, to: ExpectationLibraryDefinitionBuilder.new(self)
53
53
  end
54
54
 
55
55
  # Expectations
@@ -65,7 +65,7 @@ module CabezaDeTermo
65
65
  def expect_a(type, &block)
66
66
  @root_expression = new_expression_for(type)
67
67
 
68
- Bind.evaluation of: block, to: @root_expression unless block.nil?
68
+ CdT.bind_evaluation_of block, to: @root_expression unless block.nil?
69
69
 
70
70
  @root_expression
71
71
  end
@@ -1,5 +1,5 @@
1
1
  module CabezaDeTermo
2
2
  module JsonSpec
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Rubi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cdt-utilities
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: validates_email_format_of
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +94,6 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: simplecov
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
97
  description: You can use this json expectations to validate jsons you send or receive
98
98
  in your application, or to test your API with unit tests.
99
99
  email:
@@ -104,6 +104,7 @@ extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
106
  - ".gitmodules"
107
+ - ".travis.yml"
107
108
  - Gemfile
108
109
  - LICENSE.txt
109
110
  - README.md
@@ -115,10 +116,16 @@ files:
115
116
  - cachivache/Rakefile
116
117
  - cachivache/Vagrantfile
117
118
  - cachivache/cachivache.rb
118
- - cachivache/lib/let-behaviour.rb
119
119
  - cachivache/lib/rake-helper.rb
120
- - cachivache/lib/sh-file-context.rb
121
- - cachivache/lib/sh-if-context.rb
120
+ - cachivache/lib/shell-contexts/shell-context.rb
121
+ - cachivache/lib/shell-contexts/shell-exec.rb
122
+ - cachivache/lib/shell-contexts/shell_buffer.rb
123
+ - cachivache/lib/shell-contexts/shell_debugger.rb
124
+ - cachivache/lib/shell-file-context.rb
125
+ - cachivache/lib/shell-if-context.rb
126
+ - cachivache/lib/stuff-api-behaviour.rb
127
+ - cachivache/lib/stuff-configuration.rb
128
+ - cachivache/lib/stuff-reminders-behaviour.rb
122
129
  - cachivache/stuff/.gitkeep
123
130
  - cachivache/stuff/ruby-json-spec.rb
124
131
  - examples/example-1-simple.rb
@@ -200,7 +207,6 @@ files:
200
207
  - lib/cabeza-de-termo/json-spec/modifiers/modifier-composite.rb
201
208
  - lib/cabeza-de-termo/json-spec/signals/signal.rb
202
209
  - lib/cabeza-de-termo/json-spec/signals/skip-branch-signal.rb
203
- - lib/cabeza-de-termo/json-spec/utilities/bind.rb
204
210
  - lib/cabeza-de-termo/json-spec/utilities/range.rb
205
211
  - lib/cabeza-de-termo/json-spec/value-holders/accessors-chain.rb
206
212
  - lib/cabeza-de-termo/json-spec/value-holders/missing-value.rb
@@ -226,7 +232,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
232
  requirements:
227
233
  - - ">="
228
234
  - !ruby/object:Gem::Version
229
- version: '0'
235
+ version: '2.0'
230
236
  required_rubygems_version: !ruby/object:Gem::Requirement
231
237
  requirements:
232
238
  - - ">="
@@ -1,27 +0,0 @@
1
- module LetBehaviour
2
- def self.included(base)
3
- base.extend(self)
4
- end
5
-
6
- def variables()
7
- @variables ||= {}
8
- end
9
-
10
- def has_variable?(name)
11
- variables.key?(name)
12
- end
13
-
14
- def is_defined?(name)
15
- has_variable?(name) && !variables[name].nil?
16
- end
17
-
18
- def let(name, &block)
19
- variables[name] = block.call
20
- end
21
-
22
- def method_missing(method_name, *args, &block)
23
- return variables[method_name] if has_variable?(method_name)
24
-
25
- super(method_name, *args, &block)
26
- end
27
- end
@@ -1,31 +0,0 @@
1
- class ShIfContext
2
- def self.with(args, &block)
3
- new(args).evaluate_with block
4
- end
5
-
6
- def initialize(args)
7
- @guard = args[:guard]
8
- @text = ''
9
- end
10
-
11
- def text
12
- @text
13
- end
14
-
15
- def evaluate_with(block)
16
- self << "if #{@guard}; then"
17
-
18
- instance_eval(&block)
19
-
20
- self << "fi"
21
- end
22
-
23
- def sh(string)
24
- self << string
25
- end
26
-
27
- def <<(string)
28
- text << "\n" unless @text.empty?
29
- text << string
30
- end
31
- end