stupid_spaces 0.1.0

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
+ SHA256:
3
+ metadata.gz: 0b555aaffd030e0cbee78f3e44c7c4a7b55e61e5e9abe8604aeaa7c4eb709aaf
4
+ data.tar.gz: 774a4a31c46b9726d0059d754efa5cacac92114e95587b4003c42fd40fab5caf
5
+ SHA512:
6
+ metadata.gz: 8e89d60e78077f552e4642ec4a0ed84e614d451b29baacb5c29268a859825d9d26806979d9b64b65e6ba62f682584777eae4a95f764e53d2893959ca87e20ec2
7
+ data.tar.gz: a504bb993bbed4de261798548959e5ffe9d2add22545e1dfea7c82438549208277529bd7c179d403b89a83814fb61ee8c38dd85d907d46e066340dde80a61173
Binary file
Binary file
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in stupid_spaces.gemspec
6
+ gemspec
@@ -0,0 +1,80 @@
1
+ # StupidSpaces
2
+
3
+ You know, that kind of user, that kind of user ...
4
+
5
+ >"your app has a bug, if I put white spaces before and after the string,
6
+ it saves to the database with the spaces",
7
+
8
+ >"but why are you inserting those spaces if they aren't needed there?"
9
+
10
+ >"just to test if is a well built system",
11
+
12
+ >"don't you have anything more important to do?"
13
+
14
+ Then you call the user boss and say
15
+
16
+ >"hey, you know that user wants I strip all the leading and trailing spaces
17
+ from all the tables with string attributes just because he thinks it's
18
+ important", and the boss
19
+
20
+ >"I think he has a point there, please do it."
21
+
22
+ >"Grrr. Stupid spaces (or perhaps, stupid user)."
23
+
24
+ So, unless we want to use a lot of `before_save` callbacks, we can use this gem
25
+ here.
26
+
27
+ ## Installation
28
+
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem 'stupid_spaces'
33
+ ```
34
+
35
+ And then execute:
36
+
37
+ $ bundle
38
+
39
+ Or install it yourself as:
40
+
41
+ $ gem install stupid_spaces
42
+
43
+ ## Usage
44
+
45
+ Include the module inside the ActiveRecord model you want it to strip the
46
+ spaces:
47
+
48
+ ```ruby
49
+ class Person < ActiveRecord::Base
50
+ include StupidSpaces
51
+ end
52
+ ```
53
+
54
+ Ok, now **all** the string attributes of Person will be stripped. If you set a name like, say:
55
+
56
+ ```ruby
57
+ person = Person.first
58
+ person.name = ' Eustáquio Rangel '
59
+ puts person.name
60
+ => 'Eustáquio Rangel'
61
+ ```
62
+
63
+ Notice that only the *leading* and *trailing* spaces are removed, not the spaces inside the string.
64
+
65
+ ## Development
66
+
67
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
68
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
69
+ prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`. To
72
+ release a new version, update the version number in `version.rb`, and then run
73
+ `bundle exec rake release`, which will create a git tag for the version, push
74
+ git commits and tags, and push the `.gem` file to
75
+ [rubygems.org](https://rubygems.org).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at
80
+ https://github.com/taq/stupid_spaces.
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "stupid_spaces"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEVjCCAr6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAqMSgwJgYDVQQDDB9ldXN0
3
+ YXF1aW9yYW5nZWwvREM9Z21haWwvREM9Y29tMB4XDTE4MTExNDIwNTMxMVoXDTE5
4
+ MTExNDIwNTMxMVowKjEoMCYGA1UEAwwfZXVzdGFxdWlvcmFuZ2VsL0RDPWdtYWls
5
+ L0RDPWNvbTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAKKJMledxeWV
6
+ 5zzrIQ0NEfSOANd/P6MXg8j7nkO0huQDrk856B1/7I7oQkWy90xJJrBimaWuLGN8
7
+ gcWQMNCr2RIRvoMirlAdQOrKgRcvUludBfGYOLtxnPVXuuaMuyike9jY50ba2ROP
8
+ 04sTU3G18f7EF4+NTkqbN2lGedlyFtqX8+uGDAhiM7TV4agUU2p38043U1qudowR
9
+ 8VmXzGwSLMsrzqsH3fqT7ZsZG/GdZl2xEqP6TjmbsSEuxLidxS2xWMjGXd6/Coxb
10
+ 8O4zrwNPpO7ftFYdZJaUm9f1Hh6g2tVBY46boZSOFkuCQ2RQetj6mtVdGcGrDa5E
11
+ rveDSpl/hxgnUDA38NQRX2dsWijrgOC/Ha91p6Qu60lTR/2wHaZu66ioKjY7EWHY
12
+ dT0H76xOuS7VZHlx/eI0wpLHNtPoLnVCfYRkeHliRbjnvi1L/MGVlmVZg51Bnecd
13
+ RBxF63wq2lGfWKki/9dG7DWiFb2MT2ul0BNnYyQDgjPnhJ4L7K8C9QIDAQABo4GG
14
+ MIGDMAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBQxasHyljikW4ot
15
+ 0tdx9nyfWQF89zAkBgNVHREEHTAbgRlldXN0YXF1aW9yYW5nZWxAZ21haWwuY29t
16
+ MCQGA1UdEgQdMBuBGWV1c3RhcXVpb3JhbmdlbEBnbWFpbC5jb20wDQYJKoZIhvcN
17
+ AQELBQADggGBAFViFXyuU/Malv+g97NzSWYZPgz8cMNwJyMVO/MICcwGA89dijVD
18
+ mnZ7GeZNDL/i3HF6/ksPnBZ00y09i4IE9+MtqmytY2o+9IvPjVlgiv9F9xTfRAwb
19
+ XxQPI7dF0bYSwKlXqv28FuvZRe57uFZHcaVP43yWvb/IVACyIhWARhrowS8l+hG4
20
+ bAGIffl2UJuGzlAX5QlCdPtrgq3dEg4CuNOHVNdYrMJw4sFC0i+9P3JaHHtJgmb+
21
+ KvXHj7kxToggX8nNpwjQyCMgDWqxGJDBwjJy5C/9xgwZ8DH8FaXnpoWdeItJYoH7
22
+ Kp/lK9z+cWZ8Rix853xtXu/ZVJaHeOPqGIqDC6iZYbU/QtXGZAVKsjV7odQOKyZd
23
+ NUFwMoiTOEwHzNW6KJMPKfjXiE3axgsx5II/Rn70CiAuUbx1gpV6uJWPMCZ6Nxel
24
+ CFEOX0+zy4NfUYoiVqmaIXXlQX+hUOkeqYxgCEsGi5C6Ycf5eKlmLMTUBSfKyg8O
25
+ PM/xM6zipwKquQ==
26
+ -----END CERTIFICATE-----
@@ -0,0 +1,13 @@
1
+ require "stupid_spaces/version"
2
+
3
+ module StupidSpaces
4
+ def self.included(cls)
5
+ cls.columns_hash
6
+ .select { |_, col| col.type.match?(/string/) }
7
+ .map { |key, _| key }.each do |col|
8
+ define_method("#{col}=") do |value|
9
+ write_attribute(col, value.nil? ? nil : value.strip)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module StupidSpaces
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "stupid_spaces/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "stupid_spaces"
8
+ spec.version = StupidSpaces::VERSION
9
+ spec.authors = ["Eustaquio Rangel"]
10
+ spec.email = ["eustaquiorangel@gmail.com"]
11
+
12
+ spec.summary = %q{Remove leading and trailing spaces from ActiveRecord string attributes}
13
+ spec.description = %q{Remove leading and trailing spaces from ActiveRecord string attributes}
14
+ spec.homepage = 'http://github.com/taq/stupid_spaces'
15
+
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.16'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'minitest', '~> 5.0'
26
+ spec.add_development_dependency 'active_record', '~> 5.0'
27
+
28
+ spec.signing_key = '/home/taq/.gemcert/gem-private_key.pem'
29
+ spec.cert_chain = ['gem-public_cert.pem']
30
+ end
File without changes
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stupid_spaces
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eustaquio Rangel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEVjCCAr6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAqMSgwJgYDVQQDDB9ldXN0
14
+ YXF1aW9yYW5nZWwvREM9Z21haWwvREM9Y29tMB4XDTE4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v28FuvZRe57uFZHcaVP43yWvb/IVACyIhWARhrowS8l+hG4
31
+ bAGIffl2UJuGzlAX5QlCdPtrgq3dEg4CuNOHVNdYrMJw4sFC0i+9P3JaHHtJgmb+
32
+ KvXHj7kxToggX8nNpwjQyCMgDWqxGJDBwjJy5C/9xgwZ8DH8FaXnpoWdeItJYoH7
33
+ Kp/lK9z+cWZ8Rix853xtXu/ZVJaHeOPqGIqDC6iZYbU/QtXGZAVKsjV7odQOKyZd
34
+ NUFwMoiTOEwHzNW6KJMPKfjXiE3axgsx5II/Rn70CiAuUbx1gpV6uJWPMCZ6Nxel
35
+ CFEOX0+zy4NfUYoiVqmaIXXlQX+hUOkeqYxgCEsGi5C6Ycf5eKlmLMTUBSfKyg8O
36
+ PM/xM6zipwKquQ==
37
+ -----END CERTIFICATE-----
38
+ date: 2018-12-04 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: bundler
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.16'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.16'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: minitest
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '5.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '5.0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: active_record
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '5.0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.0'
96
+ description: Remove leading and trailing spaces from ActiveRecord string attributes
97
+ email:
98
+ - eustaquiorangel@gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".gitignore"
104
+ - ".travis.yml"
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - bin/console
109
+ - bin/setup
110
+ - gem-public_cert.pem
111
+ - lib/stupid_spaces.rb
112
+ - lib/stupid_spaces/version.rb
113
+ - stupid_spaces.gemspec
114
+ - stupid_spaces.sqlite3
115
+ homepage: http://github.com/taq/stupid_spaces
116
+ licenses: []
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.7.6
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Remove leading and trailing spaces from ActiveRecord string attributes
138
+ test_files: []
@@ -0,0 +1,2 @@
1
+ �DIؖϊ�����gD*��fLǥ3�q&��
2
+ n�U]D..���g54gG�lO�8F����z�