monetize 0.1.3 → 0.1.4

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: dd93257787048399aeb0fc8cdd18f217c85f31ba
4
- data.tar.gz: 380617d7c25dbf3b1ef6d70b882c576fd4d1ac45
3
+ metadata.gz: 29bbd459e6a5ca4859d29dfd06e765d0754c7cbf
4
+ data.tar.gz: 0d6c7d1c29653c72eccabbece1574c86f101a35a
5
5
  SHA512:
6
- metadata.gz: f8fc3d8958e360276e0c17835ec516bd43cbe9d87c87fa2c48b22218c87ceb09f43f5a123fba0e6a872618e043f5d6b3ca46d81b20d5b16e3c11200be2775d3a
7
- data.tar.gz: 33fda3ea4e350d6546512484a25233c9891a11a95e5353cf576dde49815225108918628a4990a5d5202293e88acf732ff4bfd2d7264f12fed54a548c6e882b4e
6
+ metadata.gz: ce48a27d786e25445ab82b19fde3147f372c81737416a136c9dcabe91e5a3f2193d51187cbc12be4595f2dea27f4a644a6be445ccb004cde7116e15fa7866271
7
+ data.tar.gz: e522dc3d0fcb618a677498d97828e0193d4a7fff5ec32766c6bd07df5600d6ded008b77f841d1b0b9d9cd4f5ab4bdf6e74ee1bb13829add041ce4efbb1ef5c78
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: pbKErt5rAW1iRYGMIAGGAAHfVRmiBzxfd
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ script: bundle exec rspec spec
7
+ notifications:
8
+ recipients:
9
+ - shane@emmons.io
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem "coveralls", :require => false
4
+
3
5
  gemspec
data/README.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Monetize
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/monetize.png)](http://badge.fury.io/rb/monetize)
4
+ [![Build Status](https://travis-ci.org/RubyMoney/monetize.png?branch=master)](https://travis-ci.org/RubyMoney/monetize)
5
+ [![Code Climate](https://codeclimate.com/github/RubyMoney/monetize.png)](https://codeclimate.com/github/RubyMoney/monetize)
6
+ [![Coverage Status](https://coveralls.io/repos/RubyMoney/monetize/badge.png)](https://coveralls.io/r/RubyMoney/monetize)
7
+ [![Dependency Status](https://gemnasium.com/RubyMoney/monetize.png)](https://gemnasium.com/RubyMoney/monetize)
8
+ [![License](http://img.shields.io/license/MIT.png?color=green)](http://opensource.org/licenses/MIT)
9
+
3
10
  A library for converting various objects into `Money` objects.
4
11
 
5
12
  ## Installation
@@ -19,7 +26,19 @@ Or install it yourself as:
19
26
  ## Usage
20
27
 
21
28
  ```ruby
22
- # Coming Soon
29
+ Monetize.parse("$100") == Money.new(100_00, "USD")
30
+ Monetize.parse("€100") == Money.new(100_00, "EUR")
31
+ Monetize.parse("£100") == Money.new(100_00, "GBP")
32
+
33
+ "100".to_money == Money.new(100_00, "USD")
34
+ ```
35
+
36
+ Optionally, enable the ability to assume the currency from a passed symbol.
37
+
38
+ ```ruby
39
+ Monetize.assume_from_symbol = true
40
+
41
+ "100".to_money == Money.new(100_00, "USD")
23
42
  ```
24
43
 
25
44
  ## Contributing
data/lib/monetize.rb CHANGED
@@ -4,10 +4,27 @@ require "money"
4
4
  require "monetize/version"
5
5
 
6
6
  module Monetize
7
+ # Determine if the currency can be assumed from a passed symbol.
8
+ #
9
+ # @return [Boolean] Defaults to false.
10
+ def self.assume_from_symbol
11
+ @assume_from_symbol
12
+ end
13
+
14
+ # Use this to enable the ability to assume the currency from a passed
15
+ # symbol.
16
+ #
17
+ # @param value [Boolean]
18
+ #
19
+ # @return nothing.
20
+ def self.assume_from_symbol= value
21
+ @assume_from_symbol = value
22
+ end
23
+
7
24
  def self.parse(input, currency = Money.default_currency)
8
25
  input = input.to_s.strip
9
26
 
10
- computed_currency = if Money.assume_from_symbol && input =~ /^(\$|€|£)/
27
+ computed_currency = if assume_from_symbol && input =~ /^(\$|€|£)/
11
28
  case input
12
29
  when /^\$/ then "USD"
13
30
  when /^€/ then "EUR"
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Monetize
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/monetize.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "money", "~> 6.0"
21
+ spec.add_development_dependency "money", "~> 6.1.0.beta1"
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec", "~> 3.0.0.beta1"
@@ -22,7 +22,7 @@ describe Monetize do
22
22
  describe 'currency assumption' do
23
23
  context 'opted in' do
24
24
  before do
25
- Money.assume_from_symbol = true
25
+ Monetize.assume_from_symbol = true
26
26
  end
27
27
 
28
28
  it "parses formatted inputs with the currency passed as a symbol" do
@@ -40,7 +40,7 @@ describe Monetize do
40
40
  end
41
41
  context 'opted out' do
42
42
  before do
43
- Money.assume_from_symbol = false
43
+ Monetize.assume_from_symbol = false
44
44
  end
45
45
  it "parses formatted inputs with the currency passed as a symbol but ignores the symbol" do
46
46
  expect(Monetize.parse("$5.95")).to eq Money.new(595, 'USD')
@@ -51,7 +51,7 @@ describe Monetize do
51
51
  end
52
52
  end
53
53
  it 'should opt out by default' do
54
- expect(Money.assume_from_symbol).to be false
54
+ expect(Monetize.assume_from_symbol).to be_falsy
55
55
  end
56
56
  end
57
57
 
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
+ require "coveralls"
3
+ Coveralls.wear!
2
4
 
3
5
  require "money"
4
6
 
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monetize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-29 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: 6.1.0.beta1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: 6.1.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 3.0.0.beta1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 3.0.0.beta1
69
69
  description: A library for converting various objects into `Money` objects.
@@ -73,7 +73,9 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
76
+ - ".coveralls.yml"
77
+ - ".gitignore"
78
+ - ".travis.yml"
77
79
  - Gemfile
78
80
  - LICENSE.txt
79
81
  - README.md
@@ -98,17 +100,17 @@ require_paths:
98
100
  - lib
99
101
  required_ruby_version: !ruby/object:Gem::Requirement
100
102
  requirements:
101
- - - '>='
103
+ - - ">="
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  requirements:
106
- - - '>='
108
+ - - ">="
107
109
  - !ruby/object:Gem::Version
108
110
  version: '0'
109
111
  requirements: []
110
112
  rubyforge_project:
111
- rubygems_version: 2.0.14
113
+ rubygems_version: 2.2.0
112
114
  signing_key:
113
115
  specification_version: 4
114
116
  summary: A library for converting various objects into `Money` objects.