stink_bomb 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb7ad358d7796194b94cb6a8eed905525e0bf75c
4
+ data.tar.gz: 9b8abc3e4b9af39c16e5a3a813d5c53fcd1ef830
5
+ SHA512:
6
+ metadata.gz: 62e8dce51d3f57e80cfdf245cbf0fd57f636e60a751ed0b21d20cbfa0cd25365e71495e137ebc3b476d1a5c661d9575831dbc749f90f69e3392a917784506080
7
+ data.tar.gz: 96b4766e455ef771909044bda0415e50809b18629905532f150826c3233ce843212b3c605a61e2ba0f4766db316e47813bb0444dfeb85cc576c4c68c456f4841
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --warnings
3
+ --require spec_helper
@@ -0,0 +1,16 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ TrailingComma:
5
+ EnforcedStyleForMultiline: comma
6
+
7
+ AccessModifierIndentation:
8
+ EnforcedStyle: outdent
9
+
10
+ CollectionMethods:
11
+ PreferredMethods:
12
+ collect: 'map'
13
+ collect!: 'map!'
14
+ inject: 'reduce'
15
+ find: 'detect'
16
+ find_all: 'select'
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.3
4
+ script:
5
+ - bundle exec travis lint --skip-completion-check
6
+ - bundle exec rspec
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stink_bomb.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'coveralls'
8
+ gem 'rake'
9
+ gem 'travis'
10
+ gem 'rubocop'
11
+ gem 'rspec'
12
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Holman Gao
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # StinkBomb
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/stink_bomb.svg)](http://badge.fury.io/rb/stink_bomb)
4
+ [![Build Status](https://travis-ci.org/ChalkSchools/stink-bomb.svg?branch=master)](https://travis-ci.org/ChalkSchools/stink-bomb)
5
+ [![Coverage Status](https://img.shields.io/coveralls/ChalkSchools/stink-bomb.svg)](https://coveralls.io/r/ChalkSchools/stink-bomb?branch=master)
6
+
7
+ Create a `StinkBomb` that will throw an error if your code is out of date.
8
+ Useful for when you have code that should be addressed in the near future,
9
+ and you want this code to fail CI when it gets too stinky.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'stink_bomb'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install stink_bomb
26
+
27
+ ## Usage
28
+
29
+ ```ruby
30
+ StinkBomb.create('January 20, 2001')
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/stink-bomb/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,9 @@
1
+ require 'time'
2
+ require 'stink_bomb/version'
3
+ require 'stink_bomb/bomb'
4
+
5
+ class StinkBomb
6
+ def self.create(datetime, message: nil)
7
+ StinkBomb::Bomb.new(datetime, message: message)
8
+ end
9
+ end
@@ -0,0 +1,31 @@
1
+ class StinkBomb
2
+ class Bomb
3
+ attr_accessor :datetime
4
+
5
+ def initialize(datetime, message: nil)
6
+ self.datetime = parse(datetime)
7
+ fail (message || fail_message) if !production? && past_datetime?
8
+ end
9
+
10
+ def parse(datetime)
11
+ datetime = DateTime.parse(datetime) if datetime.is_a?(String)
12
+ unless datetime.respond_to?(:to_datetime)
13
+ fail 'Parameter has to be a Time, Date, or a String'
14
+ end
15
+
16
+ datetime.to_datetime
17
+ end
18
+
19
+ def fail_message
20
+ "Your code stinks! It was supposed to be fixed by #{datetime}"
21
+ end
22
+
23
+ def production?
24
+ ENV['RAILS_ENV'] == 'production' || ENV['RACK_ENV'] == 'production'
25
+ end
26
+
27
+ def past_datetime?
28
+ Time.now.getlocal.to_datetime > datetime
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ class StinkBomb
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,43 @@
1
+ class StinkBomb
2
+ describe Bomb, '#initialize' do
3
+ it 'does nothing if tomorrow is given' do
4
+ expect do
5
+ Bomb.new(Date.today + 1)
6
+ end.not_to raise_error
7
+ end
8
+
9
+ it 'does nothing if now + epsilon is given' do
10
+ expect do
11
+ Bomb.new(Time.now.getlocal + 1)
12
+ end.not_to raise_error
13
+ end
14
+
15
+ it 'does not raise an error in production' do
16
+ expect(ENV).to receive(:[]).with('RAILS_ENV').and_return('production')
17
+
18
+ expect do
19
+ Bomb.new(Date.today - 1)
20
+ end.not_to raise_error
21
+ end
22
+
23
+ it 'raises a custom message when specified' do
24
+ yesterday = Date.today - 1
25
+ expect do
26
+ Bomb.new(yesterday, message: 'Smells like poo')
27
+ end.to raise_error(/Smells like poo/)
28
+ end
29
+
30
+ it 'raises an error if the given date is after today' do
31
+ yesterday = Date.today - 1
32
+ expect do
33
+ Bomb.new(yesterday)
34
+ end.to raise_error(/stinks! It was supposed to be fixed by #{yesterday}/)
35
+ end
36
+
37
+ it 'raises an error if the parameter is not a date or a string' do
38
+ expect do
39
+ Bomb.new(1)
40
+ end.to raise_error('Parameter has to be a Time, Date, or a String')
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,8 @@
1
+ describe StinkBomb do
2
+ describe '#create' do
3
+ it 'creates an instance of Bomb with the parameters' do
4
+ expect(StinkBomb::Bomb).to receive(:new).with('My date', message: nil)
5
+ StinkBomb.create('My date')
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require_relative '../lib/stink_bomb'
5
+
6
+ RSpec.configure do |config|
7
+ config.filter_run focus: true
8
+ config.run_all_when_everything_filtered = true
9
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'stink_bomb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'stink_bomb'
8
+ spec.version = StinkBomb::VERSION
9
+ spec.authors = ['Holman Gao']
10
+ spec.email = ['holman@golmansax.com']
11
+ spec.summary = 'Fail your CI when your code becomes stinky'
12
+ spec.homepage = 'https://github.com/ChalkSchools/stink-bomb'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
18
+ spec.require_paths = ['lib']
19
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stink_bomb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Holman Gao
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - holman@golmansax.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - .rspec
22
+ - .rubocop.yml
23
+ - .travis.yml
24
+ - Gemfile
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/stink_bomb.rb
29
+ - lib/stink_bomb/bomb.rb
30
+ - lib/stink_bomb/version.rb
31
+ - spec/lib/stink_bomb/bomb_spec.rb
32
+ - spec/lib/stink_bomb_spec.rb
33
+ - spec/spec_helper.rb
34
+ - stink_bomb.gemspec
35
+ homepage: https://github.com/ChalkSchools/stink-bomb
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.2.2
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: Fail your CI when your code becomes stinky
59
+ test_files:
60
+ - spec/lib/stink_bomb/bomb_spec.rb
61
+ - spec/lib/stink_bomb_spec.rb
62
+ - spec/spec_helper.rb
63
+ has_rdoc: