toolchain 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +5 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +10 -0
  5. data/Gemfile.lock +34 -0
  6. data/LICENSE +22 -0
  7. data/README.md +254 -0
  8. data/Rakefile +1 -0
  9. data/lib/toolchain.rb +2 -0
  10. data/lib/toolchain/attributes.rb +154 -0
  11. data/lib/toolchain/attributes/configuration.rb +41 -0
  12. data/lib/toolchain/attributes/errors.rb +5 -0
  13. data/lib/toolchain/attributes/errors/invalid_hash_transformation.rb +4 -0
  14. data/lib/toolchain/attributes/errors/invalid_mass_assignment.rb +4 -0
  15. data/lib/toolchain/attributes/errors/type_mismatch.rb +4 -0
  16. data/lib/toolchain/attributes/ext/boolean.rb +4 -0
  17. data/lib/toolchain/attributes/helpers.rb +72 -0
  18. data/lib/toolchain/validations.rb +103 -0
  19. data/lib/toolchain/validations/delegation.rb +31 -0
  20. data/lib/toolchain/validations/delegator.rb +51 -0
  21. data/lib/toolchain/validations/helpers.rb +58 -0
  22. data/lib/toolchain/validations/validation_errors.rb +82 -0
  23. data/lib/toolchain/validations/validators.rb +12 -0
  24. data/lib/toolchain/validations/validators/acceptance.rb +25 -0
  25. data/lib/toolchain/validations/validators/base.rb +54 -0
  26. data/lib/toolchain/validations/validators/confirmation.rb +39 -0
  27. data/lib/toolchain/validations/validators/email.rb +26 -0
  28. data/lib/toolchain/validations/validators/exclusion.rb +29 -0
  29. data/lib/toolchain/validations/validators/format.rb +25 -0
  30. data/lib/toolchain/validations/validators/inclusion.rb +29 -0
  31. data/lib/toolchain/validations/validators/length.rb +60 -0
  32. data/lib/toolchain/validations/validators/presence.rb +25 -0
  33. data/lib/toolchain/version.rb +3 -0
  34. data/spec/spec_helper.rb +11 -0
  35. data/spec/toolchain/attributes/attribute_spec.rb +47 -0
  36. data/spec/toolchain/attributes/attributes_spec.rb +193 -0
  37. data/spec/toolchain/attributes/base_helper.rb +37 -0
  38. data/spec/toolchain/attributes/boolean_spec.rb +38 -0
  39. data/spec/toolchain/attributes/configuration_spec.rb +33 -0
  40. data/spec/toolchain/attributes/date_time_spec.rb +21 -0
  41. data/spec/toolchain/attributes/hash_spec.rb +61 -0
  42. data/spec/toolchain/attributes/include_attributes_spec.rb +19 -0
  43. data/spec/toolchain/attributes/initializer_spec.rb +32 -0
  44. data/spec/toolchain/validations/base_helper.rb +2 -0
  45. data/spec/toolchain/validations/custom_validations_spec.rb +26 -0
  46. data/spec/toolchain/validations/delegation_spec.rb +70 -0
  47. data/spec/toolchain/validations/include_validations_spec.rb +20 -0
  48. data/spec/toolchain/validations/inheritence_spec.rb +26 -0
  49. data/spec/toolchain/validations/multiple_validations_spec.rb +19 -0
  50. data/spec/toolchain/validations/nested_validations_spec.rb +68 -0
  51. data/spec/toolchain/validations/validation_errors_spec.rb +9 -0
  52. data/spec/toolchain/validations/validators/acceptance_spec.rb +48 -0
  53. data/spec/toolchain/validations/validators/confirmation_spec.rb +86 -0
  54. data/spec/toolchain/validations/validators/email_spec.rb +41 -0
  55. data/spec/toolchain/validations/validators/exclusion_spec.rb +53 -0
  56. data/spec/toolchain/validations/validators/format_spec.rb +44 -0
  57. data/spec/toolchain/validations/validators/inclusion_spec.rb +50 -0
  58. data/spec/toolchain/validations/validators/length_spec.rb +134 -0
  59. data/spec/toolchain/validations/validators/presence_spec.rb +34 -0
  60. data/toolchain.gemspec +21 -0
  61. metadata +161 -0
@@ -0,0 +1,34 @@
1
+ require_relative "../base_helper"
2
+
3
+ describe Toolchain::Validations::Validators::Presence do
4
+
5
+ class UserPresence
6
+ include Toolchain::Validations
7
+ attr_accessor :name
8
+ validates :name, presence: true
9
+ end
10
+
11
+ it "should be valid" do
12
+ user = UserPresence.new
13
+ user.name = "Michael"
14
+ user.should be_valid
15
+ end
16
+
17
+ it "is invalid if blank" do
18
+ user = UserPresence.new
19
+ user.should_not be_valid
20
+ user.errors[:name].should == ["can't be blank"]
21
+ end
22
+
23
+ class UserPresenceMessage
24
+ include Toolchain::Validations
25
+ attr_accessor :name
26
+ validates :name, presence: { message: "is required" }
27
+ end
28
+
29
+ it "should have a custom error message" do
30
+ user = UserPresenceMessage.new
31
+ user.should_not be_valid
32
+ user.errors[:name].should == ["is required"]
33
+ end
34
+ end
data/toolchain.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "toolchain/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "toolchain"
7
+ spec.version = Toolchain::VERSION
8
+ spec.authors = ["Michael van Rooijen", "Tom de Bruijn"]
9
+ spec.email = ["michael@machinery.io", "tom@machinery.io"]
10
+ spec.summary = %q{Collection of Ruby light-weight modules that enhance plain Ruby classes with zero runtime dependencies.}
11
+ spec.homepage = "https://github.com/machinery/toolchain"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0")
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.5"
20
+ spec.add_development_dependency "rake"
21
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toolchain
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael van Rooijen
8
+ - Tom de Bruijn
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-03-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description:
43
+ email:
44
+ - michael@machinery.io
45
+ - tom@machinery.io
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE
55
+ - README.md
56
+ - Rakefile
57
+ - lib/toolchain.rb
58
+ - lib/toolchain/attributes.rb
59
+ - lib/toolchain/attributes/configuration.rb
60
+ - lib/toolchain/attributes/errors.rb
61
+ - lib/toolchain/attributes/errors/invalid_hash_transformation.rb
62
+ - lib/toolchain/attributes/errors/invalid_mass_assignment.rb
63
+ - lib/toolchain/attributes/errors/type_mismatch.rb
64
+ - lib/toolchain/attributes/ext/boolean.rb
65
+ - lib/toolchain/attributes/helpers.rb
66
+ - lib/toolchain/validations.rb
67
+ - lib/toolchain/validations/delegation.rb
68
+ - lib/toolchain/validations/delegator.rb
69
+ - lib/toolchain/validations/helpers.rb
70
+ - lib/toolchain/validations/validation_errors.rb
71
+ - lib/toolchain/validations/validators.rb
72
+ - lib/toolchain/validations/validators/acceptance.rb
73
+ - lib/toolchain/validations/validators/base.rb
74
+ - lib/toolchain/validations/validators/confirmation.rb
75
+ - lib/toolchain/validations/validators/email.rb
76
+ - lib/toolchain/validations/validators/exclusion.rb
77
+ - lib/toolchain/validations/validators/format.rb
78
+ - lib/toolchain/validations/validators/inclusion.rb
79
+ - lib/toolchain/validations/validators/length.rb
80
+ - lib/toolchain/validations/validators/presence.rb
81
+ - lib/toolchain/version.rb
82
+ - spec/spec_helper.rb
83
+ - spec/toolchain/attributes/attribute_spec.rb
84
+ - spec/toolchain/attributes/attributes_spec.rb
85
+ - spec/toolchain/attributes/base_helper.rb
86
+ - spec/toolchain/attributes/boolean_spec.rb
87
+ - spec/toolchain/attributes/configuration_spec.rb
88
+ - spec/toolchain/attributes/date_time_spec.rb
89
+ - spec/toolchain/attributes/hash_spec.rb
90
+ - spec/toolchain/attributes/include_attributes_spec.rb
91
+ - spec/toolchain/attributes/initializer_spec.rb
92
+ - spec/toolchain/validations/base_helper.rb
93
+ - spec/toolchain/validations/custom_validations_spec.rb
94
+ - spec/toolchain/validations/delegation_spec.rb
95
+ - spec/toolchain/validations/include_validations_spec.rb
96
+ - spec/toolchain/validations/inheritence_spec.rb
97
+ - spec/toolchain/validations/multiple_validations_spec.rb
98
+ - spec/toolchain/validations/nested_validations_spec.rb
99
+ - spec/toolchain/validations/validation_errors_spec.rb
100
+ - spec/toolchain/validations/validators/acceptance_spec.rb
101
+ - spec/toolchain/validations/validators/confirmation_spec.rb
102
+ - spec/toolchain/validations/validators/email_spec.rb
103
+ - spec/toolchain/validations/validators/exclusion_spec.rb
104
+ - spec/toolchain/validations/validators/format_spec.rb
105
+ - spec/toolchain/validations/validators/inclusion_spec.rb
106
+ - spec/toolchain/validations/validators/length_spec.rb
107
+ - spec/toolchain/validations/validators/presence_spec.rb
108
+ - toolchain.gemspec
109
+ homepage: https://github.com/machinery/toolchain
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.2.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Collection of Ruby light-weight modules that enhance plain Ruby classes with
133
+ zero runtime dependencies.
134
+ test_files:
135
+ - spec/spec_helper.rb
136
+ - spec/toolchain/attributes/attribute_spec.rb
137
+ - spec/toolchain/attributes/attributes_spec.rb
138
+ - spec/toolchain/attributes/base_helper.rb
139
+ - spec/toolchain/attributes/boolean_spec.rb
140
+ - spec/toolchain/attributes/configuration_spec.rb
141
+ - spec/toolchain/attributes/date_time_spec.rb
142
+ - spec/toolchain/attributes/hash_spec.rb
143
+ - spec/toolchain/attributes/include_attributes_spec.rb
144
+ - spec/toolchain/attributes/initializer_spec.rb
145
+ - spec/toolchain/validations/base_helper.rb
146
+ - spec/toolchain/validations/custom_validations_spec.rb
147
+ - spec/toolchain/validations/delegation_spec.rb
148
+ - spec/toolchain/validations/include_validations_spec.rb
149
+ - spec/toolchain/validations/inheritence_spec.rb
150
+ - spec/toolchain/validations/multiple_validations_spec.rb
151
+ - spec/toolchain/validations/nested_validations_spec.rb
152
+ - spec/toolchain/validations/validation_errors_spec.rb
153
+ - spec/toolchain/validations/validators/acceptance_spec.rb
154
+ - spec/toolchain/validations/validators/confirmation_spec.rb
155
+ - spec/toolchain/validations/validators/email_spec.rb
156
+ - spec/toolchain/validations/validators/exclusion_spec.rb
157
+ - spec/toolchain/validations/validators/format_spec.rb
158
+ - spec/toolchain/validations/validators/inclusion_spec.rb
159
+ - spec/toolchain/validations/validators/length_spec.rb
160
+ - spec/toolchain/validations/validators/presence_spec.rb
161
+ has_rdoc: