fail_fast 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -1,2 +1,4 @@
1
+ 0.1.1
2
+ - added command : fail('message')
1
3
  0.1.0
2
4
  - initial version
data/README.markdown CHANGED
@@ -1,27 +1,62 @@
1
1
  # fail_fast : don't start your application if some preconditions are not met.
2
2
 
3
+ ## How to install :
4
+
5
+ gem install fail_fast
6
+
3
7
  ## How to use :
4
8
 
5
9
  Early in your project boot sequence insert code like
6
10
 
7
11
  require 'fail_fast'
8
12
  FailFast('database.yml').check do
9
- has_active_record_db_for Rails.env
13
+ has_active_record_db_for Rails.env
10
14
  end
11
15
 
12
16
  FailFast('database.mongo.yml').check do
13
- has_mongoDB_for Rails.env
17
+ has_mongoDB_for Rails.env
14
18
  end
15
19
 
16
20
  FailFast('path_to/config.yml', prefix=Rails.env).check do
17
- has\_values_for 'author/fname', 'author/lname'
18
- has\_url_for 'bug_tracker/url', :reachable => true
19
- has\_email_for 'newsletter/to_address'
21
+ has_values_for 'author/fname', 'author/lname'
22
+ has_email_for 'newsletter/to_address'
23
+ has_url_for 'bug_tracker/url', :reachable => true
20
24
 
21
25
  directory_exists_for '/tmp'
22
26
  file_exists_for 'public/nda.pdf'
27
+
28
+ fail "I don't work on Sunday" if 0 == Time.now.wday
23
29
  end
24
30
 
31
+ If it fails, you'll get a report like this :
32
+
33
+ +------------------------------------------------------------------------------------------
34
+ | FAIL_FAST error : "./spec/fixtures/simple.yml"
35
+ | key prefix = nil
36
+ +------------------------------------------------------------------------------------------
37
+ | error key value
38
+ +------------------------------------------------------------------------------------------
39
+ | * missing_value first_keyNOT
40
+ | * missing_value last_keyNOT
41
+ | * missing_value number_sixNOT
42
+ | * missing_value testNOT/mongoDB/database
43
+ | * value_does_not_match last_key dernier
44
+ | * not_an_email test/host localhost
45
+ | * not_a_url test/host localhost
46
+ | * url_not_reachable test/url_not_reachable http://xxx.zzz
47
+ | * directory_not_found /foobarbaz
48
+ | * directory_not_found test/a_file ./spec/fixtures/simple.yml
49
+ | * file_not_found /tmp/foo/bar/??nOTaFile
50
+ | * file_not_found test/a_directory ./spec/fixtures
51
+ | * mongoDB_server_not_found 10.0.0.123
52
+ | * mongoDB_server_not_found test/mongoDB localhost
53
+ | * mongoDB_db_not_found not_a_known_db
54
+ | * mongoDB_db_not_found test/unknown_mongoDB_db unknown_mongoDB_db
55
+ | * active_record_db_connection_error Unknown database 'some-db'
56
+ | * active_record_db_connection_error db_connection Unknown database 'a_db'
57
+ | * fail a custom failure message
58
+ +------------------------------------------------------------------------------------------
59
+
25
60
 
26
61
  ## Info :
27
62
 
@@ -49,10 +84,10 @@ You can also add custom rules, not related to any config files :
49
84
 
50
85
  ### _free/direct_ commands (not linked to the yaml file contents) :
51
86
 
52
- directory_exists '/tmp'
53
- file_exists '/Users/me/.bash_profile'
54
- has_mongoDB 'localhost', 'db_app_1'
55
- has_active_record_db :host => 'dbserv', :adapter => 'mysql', :database => 'db'
87
+ directory_exists '/tmp'
88
+ file_exists '/Users/me/.bash_profile'
89
+ has_mongoDB 'localhost', 'db_app_1'
90
+ has_active_record_db :host => 'dbserv', :adapter => 'mysql', :database => 'db'
56
91
 
57
92
 
58
93
  ### _keyed_ commands (linked to a value found in a yaml file) :
@@ -61,8 +96,8 @@ You can also add custom rules, not related to any config files :
61
96
 
62
97
  *presence :*
63
98
 
64
- has_value_for :application_name
65
- has_values_for 'author/fname', 'author/lname'
99
+ has_value_for :application_name
100
+ has_values_for 'author/fname', 'author/lname'
66
101
 
67
102
  *contents <-> a regexp or pattern :*
68
103
 
@@ -72,20 +107,20 @@ You can also add custom rules, not related to any config files :
72
107
 
73
108
  Test the file system :
74
109
 
75
- directory_exists_for 'public/assets'
76
- file_exists_for 'public/500_custom.html'
110
+ directory_exists_for 'assets-upload_dir'
111
+ file_exists_for 'assets-nda_pdf_file'
77
112
 
78
113
  Test external services :
79
114
 
80
- # is a webserver up ?
81
- has_url_for 'bug_tracker/url', :reachable => true
82
- has_url_for 'bug_tracker/url', :reachable => true, :may_add_trailing_slash => true
115
+ # is a webserver up ?
116
+ has_url_for 'bug_tracker/url', :reachable => true
117
+ has_url_for 'bug_tracker/url', :reachable => true, :may_add_trailing_slash => true
83
118
 
84
119
 
85
- # can we connect to a mongoDB db/server :
86
- has_mongoDB_for 'test/mongoDB'
87
- has_mongoDB_for 'test/unknown_mongoDB_db', :check_database => false
120
+ # can we connect to a mongoDB db/server :
121
+ has_mongoDB_for 'test/mongoDB'
122
+ has_mongoDB_for 'test/unknown_mongoDB_db', :check_database => false
88
123
 
89
- # can we connect to a SQL db :
90
- has_active_record_db_for 'production/db_connection'
124
+ # can we connect to a SQL db :
125
+ has_active_record_db_for 'production/db_connection'
91
126
 
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/alainravet/fail_fast"
12
12
  gem.authors = ["Alain Ravet"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_development_dependency "activerecord"
14
15
  gem.add_development_dependency "mongo"
15
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/fail_fast.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fail_fast}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alain Ravet"]
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
33
33
  "lib/fail_fast/check_url.rb",
34
34
  "lib/fail_fast/check_value.rb",
35
35
  "lib/fail_fast/main.rb",
36
+ "lib/fail_fast/misc.rb",
36
37
  "lib/fail_fast/report.txt.erb",
37
38
  "show_all_errors.rb",
38
39
  "spec/file_is_empty_spec.rb",
@@ -46,6 +47,7 @@ Gem::Specification.new do |s|
46
47
  "spec/has_url_for_spec.rb",
47
48
  "spec/has_value_for_spec.rb",
48
49
  "spec/how_to_use_spec.rb",
50
+ "spec/misc_spec.rb",
49
51
  "spec/spec.opts",
50
52
  "spec/spec_helper.rb"
51
53
  ]
@@ -64,6 +66,7 @@ Gem::Specification.new do |s|
64
66
  "spec/has_url_for_spec.rb",
65
67
  "spec/has_value_for_spec.rb",
66
68
  "spec/how_to_use_spec.rb",
69
+ "spec/misc_spec.rb",
67
70
  "spec/spec_helper.rb"
68
71
  ]
69
72
 
@@ -73,13 +76,16 @@ Gem::Specification.new do |s|
73
76
 
74
77
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
78
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
79
+ s.add_development_dependency(%q<activerecord>, [">= 0"])
76
80
  s.add_development_dependency(%q<mongo>, [">= 0"])
77
81
  else
78
82
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
83
+ s.add_dependency(%q<activerecord>, [">= 0"])
79
84
  s.add_dependency(%q<mongo>, [">= 0"])
80
85
  end
81
86
  else
82
87
  s.add_dependency(%q<rspec>, [">= 1.2.9"])
88
+ s.add_dependency(%q<activerecord>, [">= 0"])
83
89
  s.add_dependency(%q<mongo>, [">= 0"])
84
90
  end
85
91
  end
@@ -0,0 +1,13 @@
1
+ class FailFast
2
+ module Misc
3
+
4
+ # Usage
5
+ # if 0 == Time.now.wday
6
+ # fail "I don't work on Sunday""
7
+ # end
8
+ def fail(message)
9
+ FailFast.errors << ErrorDetails.new(nil, :fail, message)
10
+ end
11
+ end
12
+ end
13
+ FailFast.send :include, FailFast::Misc
data/lib/fail_fast.rb CHANGED
@@ -6,6 +6,7 @@ require 'fail_fast/check_mongo_db'
6
6
  require 'fail_fast/check_active_record_db'
7
7
  require 'fail_fast/check_url'
8
8
  require 'fail_fast/check_email'
9
+ require 'fail_fast/misc'
9
10
 
10
11
 
11
12
  def FailFast(path, prefix=nil)
data/show_all_errors.rb CHANGED
@@ -60,4 +60,7 @@ FailFast(SPEC_DIR + '/fixtures/simple.yml').check do
60
60
  #test ActiveRecord
61
61
  has_active_record_db :host => 'localhost', :adapter => 'mysql', :database=> 'some-db'
62
62
  has_active_record_db_for 'db_connection'
63
+
64
+ #misc
65
+ fail 'a custom failure message'
63
66
  end
data/spec/misc_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Misc" do
4
+ it_should_raise_a_direct_error('message-123', :fail, 'when fail() is called') {
5
+ fail 'message-123'
6
+ }
7
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fail_fast
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alain Ravet
@@ -35,7 +35,7 @@ dependencies:
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: mongo
38
+ name: activerecord
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
@@ -48,6 +48,20 @@ dependencies:
48
48
  version: "0"
49
49
  type: :development
50
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: mongo
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
51
65
  description: raises an error if the yaml contents of a config file does not pass a test script.
52
66
  email: alainravet@gmail.com
53
67
  executables: []
@@ -74,6 +88,7 @@ files:
74
88
  - lib/fail_fast/check_url.rb
75
89
  - lib/fail_fast/check_value.rb
76
90
  - lib/fail_fast/main.rb
91
+ - lib/fail_fast/misc.rb
77
92
  - lib/fail_fast/report.txt.erb
78
93
  - show_all_errors.rb
79
94
  - spec/file_is_empty_spec.rb
@@ -87,6 +102,7 @@ files:
87
102
  - spec/has_url_for_spec.rb
88
103
  - spec/has_value_for_spec.rb
89
104
  - spec/how_to_use_spec.rb
105
+ - spec/misc_spec.rb
90
106
  - spec/spec.opts
91
107
  - spec/spec_helper.rb
92
108
  has_rdoc: true
@@ -133,4 +149,5 @@ test_files:
133
149
  - spec/has_url_for_spec.rb
134
150
  - spec/has_value_for_spec.rb
135
151
  - spec/how_to_use_spec.rb
152
+ - spec/misc_spec.rb
136
153
  - spec/spec_helper.rb