tiny_sweeper 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b3312c9ca196aa0ccc80e866b5c972df40a55c7
4
- data.tar.gz: 3f784d995ee4dbbda4555888bfb239581602a31d
3
+ metadata.gz: bab53d4f83febe0e94f9f5c97f632b1c7a4f6074
4
+ data.tar.gz: 6cb5b37b25afdbaa6599567434aae424bc52a9f1
5
5
  SHA512:
6
- metadata.gz: 308e7c5b89350405f4ca03af67c8468f51a444aa3c96a4e9a9b4e6bede4ed70764b8ea07f0bd951dcfc11d125c6fffaf0e05d451cf080cff6abae7a6376b4ac7
7
- data.tar.gz: 804648e58f8c3b0d7a3cfaf8d186ada84033c13e026b0daf326b5660063237ceda8304111293af406f3870a3204f033487bac46c4b5160aac04ac7e1e97364b4
6
+ metadata.gz: a575f5ff0cba1a49c8a46af5b15159749cf53b2313cfeee4ff5bd793f020bba9eb00a6405d443a1181ab149e4725afd67457e61f93b7e34df8369dc64fda84e8
7
+ data.tar.gz: 20bd0f5be58572b3931aa4ddda86503a4e477d7960a37e5ae149c158a225172afeb037a985bf12fce857d61939a428416b77361860cb36997dab5d546056046c
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby 2.2.0
1
+ ruby-2.2.0
data/README.md CHANGED
@@ -5,7 +5,7 @@ TinySweeper keeps your objects tidy!
5
5
  It's a handy way to clean attributes on your Rails models, though it's independent of Rails, and can be used in any Ruby project. It gives you a light-weigt way to override your methods and declare how their inputs should be cleaned.
6
6
 
7
7
  [![Build Status](https://travis-ci.org/ContinuityControl/tiny_sweeper.png?branch=master)](https://travis-ci.org/ContinuityControl/tiny_sweeper)
8
- [![Code Climate](https://codeclimate.com/github/ContinuityControl/tiny_sweeper.png)](https://codeclimate.com/github/ContinuityControl/tiny_sweeper)
8
+ [![Code Climate](https://codeclimate.com/github/ContinuityControl/tiny_sweeper/badges/gpa.svg)](https://codeclimate.com/github/ContinuityControl/tiny_sweeper)
9
9
 
10
10
  ## How Do I Use It?
11
11
 
@@ -64,6 +64,10 @@ class Sundae
64
64
  end
65
65
  ```
66
66
 
67
+ #### Other Ways to Sweep
68
+
69
+ Rails models are clearly the natural use-case for this. So it would make sense to have an easy way to auto-clean up models in a table. We'll see.
70
+
67
71
  ## How Does It Work?
68
72
 
69
73
  You include the `TinySweeper` module in your class, and define some sweep-up rules on your class' attributes. It overrides your method, and defines a new method that cleans its input according to the sweep-up rule, and then calls the original method with the clean value.
data/lib/tiny_sweeper.rb CHANGED
@@ -23,7 +23,7 @@ module TinySweeper
23
23
  private
24
24
 
25
25
  def stop_if_attribute_does_not_exist!(field_name)
26
- unless instance_methods.include?(writer_method_name(field_name))
26
+ unless instance_methods(true).include?(writer_method_name(field_name))
27
27
  raise "There is no method named #{field_name.inspect} to sweep up!"
28
28
  end
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module TinySweeper
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -71,4 +71,19 @@ describe 'cleaning fields' do
71
71
  some_class.send(:sweep, :attribute, &:whatever)
72
72
  }.to raise_error("There is no method named :attribute to sweep up!")
73
73
  end
74
+
75
+ it "will let you sweep an inherited method" do
76
+ class BaseClass
77
+ attr_accessor :name
78
+ end
79
+ class SubClass < BaseClass
80
+ include TinySweeper
81
+ end
82
+
83
+ expect { SubClass.send(:sweep, :name, &:strip) }.to_not raise_error
84
+
85
+ child = SubClass.new
86
+ child.name = ' Monty '
87
+ expect(child.name).to eq('Monty')
88
+ end
74
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_sweeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Bernier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,3 +76,4 @@ summary: A tiny helper to clean your inputs
76
76
  test_files:
77
77
  - spec/spec_helper.rb
78
78
  - spec/tiny_sweeper_spec.rb
79
+ has_rdoc: