number_to_indian_currency 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6c8302a37ae441482d0bcdf4fe17dc6425a19a21
4
+ data.tar.gz: 6fe71765aff8cb67bbe537a189a73ce5977b8aae
5
+ SHA512:
6
+ metadata.gz: b1e9ab77c59e93bb9666d154a6e3031dea39c48f5911281728cb2d3af5d093acf6ac14fc6e839fa776e0f524d7c4c9eeedd31fcd9ec71696d6ab05be24d22ac2
7
+ data.tar.gz: 5d6d132dda67419417e60cb6680be96988b14507eaebbb2a6113fddf95eda0cffe2f320e0035f727b3746af1274779cbc39bf7d8607e0ba85cef3d00408c20fc
data/.gitignore CHANGED
@@ -1,3 +1,9 @@
1
- pkg/*
2
- *.gem
3
- .bundle
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in number_to_indian_currency.gemspec
4
4
  gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Sandip Ransing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ ## Number To Indian Currency Helper
2
+
3
+ Helper method which adds indian currency format to number
4
+
5
+ ### Installation
6
+
7
+ ### Rails 2.X
8
+ gem install number_to_indian_currency
9
+
10
+ ### Using Bundler
11
+
12
+ gem 'number_to_indian_currency'
13
+
14
+ ### Add following line to application layout
15
+ stylesheet_link_tag 'rupees'
16
+
17
+ ### Usage
18
+ number_to_indian_currency(2000, false) => "Rs.2,000"
19
+ number_to_indian_currency(2040.50, false) => "Rs.2,040.5"
20
+ number_to_indian_currency(1222040.54, false) => "Rs.12,22,040.54"
21
+ number_to_indian_currency(9921) => "<span class="WebRupee">Rs.</span> 9,921"
22
+
23
+ thats, all
24
+
25
+ any sugestions? **sandip at funonrails.com** or **sandip at joshsoftware.com** released under the MIT license
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "number_to_indian_currency"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ @font-face { font-family: "WebRupee"; font-style: normal; font-weight: normal; src: local("WebRupee"), url("http://cdn.webrupee.com/WebRupee.V2.0.ttf") format("truetype"), url("http://cdn.webrupee.com/WebRupee.V2.0.woff") format("woff"), url("http://cdn.webrupee.com/WebRupee.V2.0.svg") format("svg"); } .WebRupee { font-family: 'WebRupee'; }
@@ -1,7 +1,51 @@
1
+ require "number_to_indian_currency/version"
2
+
1
3
  module NumberToIndianCurrency
2
- def number_to_indian_currency(number, html=false)
3
- number = number.to_s.gsub(/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/, "\\1,")
4
- "Rs.#{number}"
5
- end
4
+ def self.initialize
5
+ return if @intialized
6
+ if defined?(ActionView)
7
+ ActionView::Base.send :include, CurrencyHelper
8
+ NumberToIndianCurrency.install
9
+ @intialized = true
10
+ else
11
+ puts "ActionView is not available."
12
+ end
13
+ end
14
+
15
+ def self.install
16
+ require 'fileutils'
17
+ orig = File.join(File.dirname(__FILE__), '../app/assets/stylesheets/.')
18
+ dest = 'lib/assets/stylesheets'
19
+ rupees_css = File.join(dest, 'rupees.css')
20
+ unless File.exists?(rupees_css) && FileUtils.identical?(File.join(orig, 'rupees.css'), rupees_css)
21
+ if File.exists?(rupees_css)
22
+ begin
23
+ puts "Removing..."
24
+ FileUtils.rm rupees_css
25
+ FileUtils.cp_r orig, dest
26
+ rescue Exception => e
27
+ puts e.message
28
+ end
29
+ else
30
+ begin
31
+ puts "Copying #{rupees_css}..."
32
+ FileUtils.cp_r orig, dest
33
+ rescue Exception => e
34
+ puts e.message
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ module CurrencyHelper
41
+ def number_to_indian_currency(number, options={})
42
+ web_rupee = options.fetch(:web_rupee, false)
43
+ text = options.fetch(:text, 'Rs.')
44
+ text = content_tag(:span, text, class: :WebRupee) if web_rupee
45
+ formatted_number = number.to_s.gsub(/(\d+?)(?=(\d\d)+(\d)(?!\d))(\.\d+)?/, "\\1,")
46
+ return [text, formatted_number].join
47
+ end
48
+ end
6
49
  end
7
- ActionView::Base.send :include, NumberToIndianCurrency
50
+
51
+ NumberToIndianCurrency.initialize
@@ -1,3 +1,3 @@
1
1
  module NumberToIndianCurrency
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,31 +1,33 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "number_to_indian_currency/version"
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'number_to_indian_currency/version'
4
5
 
5
- Gem::Specification.new do |s|
6
- s.name = "number_to_indian_currency"
7
- s.version = NumberToIndianCurrency::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Sandip Ransing"]
10
- s.email = ["sandip@funonrails.com"]
11
- s.homepage = ""
12
- s.summary = %q{Helper that coverts number to indian currency with rupees symbol with css}
13
- s.description = %q{
14
- Example Usage
15
- --------------------------------------------------------
16
- >> number_to_indian_currency(400)
17
- => "<span class="WebRupee">Rs.</span> 400"
18
- >> number_to_indian_currency(5921, false)
19
- => "Rs. 5,921" >> helper.number_to_indian_currency(9921)
20
- => "<span class="WebRupee">Rs.</span> 9,921"
21
- >> number_to_indian_currency(1222040.54, false)
22
- => "Rs.12,22,040.54"
23
- }
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "number_to_indian_currency"
8
+ spec.version = NumberToIndianCurrency::VERSION
9
+ spec.authors = ["Sandip Ransing"]
10
+ spec.email = ["sandip@funonrails.com"]
24
11
 
25
- s.rubyforge_project = "number_to_indian_currency"
12
+ spec.summary = %q{Helper that coverts number to indian currency with rupees symbol with css}
13
+ spec.description = "number_to_indian_currency helper converts given number to the indian currency format (also displays Rupees symbol)"
14
+ spec.homepage = "https://github.com/sandipransing/number_to_indian_currency"
15
+ spec.license = "MIT"
26
16
 
27
- s.files = `git ls-files`.split("\n")
28
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
- s.require_paths = ["lib"]
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "minitest"
31
33
  end
@@ -0,0 +1,5 @@
1
+ namespace :number_to_indian_currency do
2
+ desc 'Copies font CSS to public directory'
3
+ task :install do
4
+ end
5
+ end
metadata CHANGED
@@ -1,73 +1,101 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: number_to_indian_currency
3
- version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Sandip Ransing
14
8
  autorequire:
15
- bindir: bin
9
+ bindir: exe
16
10
  cert_chain: []
17
-
18
- date: 2011-03-18 00:00:00 +05:30
19
- default_executable:
20
- dependencies: []
21
-
22
- description: "\n Example Usage\n --------------------------------------------------------\n >> number_to_indian_currency(400)\n => \"<span class=\"WebRupee\">Rs.</span> 400\" \n >> number_to_indian_currency(5921, false)\n => \"Rs. 5,921\" >> helper.number_to_indian_currency(9921)\n => \"<span class=\"WebRupee\">Rs.</span> 9,921\"\n >> number_to_indian_currency(1222040.54, false) \n => \"Rs.12,22,040.54\"\n "
23
- email:
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: number_to_indian_currency helper converts given number to the indian
56
+ currency format (also displays Rupees symbol)
57
+ email:
24
58
  - sandip@funonrails.com
25
59
  executables: []
26
-
27
60
  extensions: []
28
-
29
61
  extra_rdoc_files: []
30
-
31
- files:
32
- - .gitignore
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
33
66
  - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
34
69
  - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/assets/stylesheets/rupees.css
35
73
  - lib/number_to_indian_currency.rb
36
74
  - lib/number_to_indian_currency/version.rb
37
75
  - number_to_indian_currency.gemspec
38
- has_rdoc: true
39
- homepage: ""
40
- licenses: []
41
-
76
+ - tasks/currency.rake
77
+ homepage: https://github.com/sandipransing/number_to_indian_currency
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
42
81
  post_install_message:
43
82
  rdoc_options: []
44
-
45
- require_paths:
83
+ require_paths:
46
84
  - lib
47
- required_ruby_version: !ruby/object:Gem::Requirement
48
- none: false
49
- requirements:
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
50
87
  - - ">="
51
- - !ruby/object:Gem::Version
52
- hash: 3
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
59
92
  - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
- version: "0"
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
65
95
  requirements: []
66
-
67
- rubyforge_project: number_to_indian_currency
68
- rubygems_version: 1.3.7
96
+ rubyforge_project:
97
+ rubygems_version: 2.4.5
69
98
  signing_key:
70
- specification_version: 3
99
+ specification_version: 4
71
100
  summary: Helper that coverts number to indian currency with rupees symbol with css
72
101
  test_files: []
73
-