sanitizing_bigdecimal 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 603a4f689bc184050db16e47e1fc37d4d3445968
4
+ data.tar.gz: 1017ce4c3ae4955374914f71a3a7fb819f032226
5
+ SHA512:
6
+ metadata.gz: ae281f57bc7145c3c9992796bdcbe467132763f3377935d499a83c797af9eda290cd1f6ee06d38806eb12d0c8648f76d06115c8d19ce3c94731c16e3a9748ee2
7
+ data.tar.gz: a9b19bd16af41fda46301444f4c59a34c6d6f50643cc0aba8d767163b90676bf69fff3cbb5672b938be5bd5eeaf87492e231e1cab960ab0c3286393878c37ba1
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-2.0.0-p195@sanitizing_bigdecimal --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sanitizing_bigdecimal.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Josh Adams
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.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # SanitizingBigdecimal
2
+
3
+ Take user interface into BigDecimal without bugs
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sanitizing_bigdecimal'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sanitizing_bigdecimal
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ user_input = "$3,000.23"
23
+ SanitizingBigDecimal.new(user_input)
24
+ #=> #<BigDecimal:bd78f60,'0.300023E4',9(18)>
25
+ ```
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ require 'bigdecimal'
2
+
3
+ class SanitizingBigDecimal
4
+ VERSION = "0.0.1"
5
+
6
+ def self.get_bigdecimal(input)
7
+ BigDecimal(sanitize(input))
8
+ end
9
+
10
+ def self.sanitize(input)
11
+ input.gsub(/[^.0-9]/, '')
12
+ end
13
+ end
14
+
15
+ def SanitizingBigDecimal(input)
16
+ SanitizingBigDecimal.get_bigdecimal(input)
17
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sanitizing_bigdecimal'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sanitizing_bigdecimal"
8
+ spec.version = SanitizingBigDecimal::VERSION
9
+ spec.authors = ["Josh Adams", "Adam Gamble"]
10
+ spec.email = ["josh@isotope11.com", "adamgamble@gmail.com"]
11
+ spec.description = %q{Provides a nice way to get BigDecimals from user input without bugs.}
12
+ spec.summary = %q{This gem aims to solve various common problems around converting user input into BigDecimal.}
13
+ spec.homepage = "http://github.com/isotope11/sanitizing_bigdecimal"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,7 @@
1
+ #require 'coveralls'
2
+ #Coveralls.wear!
3
+
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+ require 'bundler'
7
+ Bundler.setup
@@ -0,0 +1,11 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe SanitizingBigDecimal do
4
+ it "works like normal for normal BigDecimal strings" do
5
+ expect(SanitizingBigDecimal("1")).to eq(BigDecimal("1"))
6
+ end
7
+
8
+ it "strips non-numeric characters (allows decimal point)" do
9
+ expect(SanitizingBigDecimal("$1,000.23")).to eq(BigDecimal("1000.23"))
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sanitizing_bigdecimal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Adams
8
+ - Adam Gamble
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-31 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.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
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
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Provides a nice way to get BigDecimals from user input without bugs.
57
+ email:
58
+ - josh@isotope11.com
59
+ - adamgamble@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
65
+ - .rvmrc
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - lib/sanitizing_bigdecimal.rb
71
+ - sanitizing_bigdecimal.gemspec
72
+ - spec/spec_helper.rb
73
+ - spec/unit/sanitizing_bigdecimal_spec.rb
74
+ homepage: http://github.com/isotope11/sanitizing_bigdecimal
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.0.3
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: This gem aims to solve various common problems around converting user input
98
+ into BigDecimal.
99
+ test_files:
100
+ - spec/spec_helper.rb
101
+ - spec/unit/sanitizing_bigdecimal_spec.rb