happy-helpers 0.1.0.pre.5 → 0.1.0.pre.6

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
data/.watchr ADDED
@@ -0,0 +1,15 @@
1
+ def run(cmd, msg = nil)
2
+ puts "=== %s" % msg if msg
3
+ puts "=== %s" % cmd
4
+ system cmd
5
+ puts "\n"
6
+ end
7
+
8
+ watch("spec/.*_spec\.rb") { |m| run("bundle exec rspec %s" % m[0]) }
9
+ watch("lib/happy-helpers/(.*)\.rb") { |m| run("bundle exec rspec spec/%s_spec.rb" % m[1]) }
10
+ watch('^spec/(spec_helper|factories)\.rb') { |f| run "bundle exec rake spec", "%s.rb has been modified" % f }
11
+
12
+ # Ctrl-\
13
+ Signal.trap('QUIT') { run("bundle exec rake spec") }
14
+ # Ctrl-C
15
+ Signal.trap('INT') { abort("\nQuitting.") }
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ # integrate rspec
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new('spec')
7
+ task :default => :spec
@@ -16,4 +16,10 @@ Gem::Specification.new do |gem|
16
16
  gem.version = HappyHelpers::VERSION
17
17
 
18
18
  gem.add_dependency 'tilt', '~> 1.3'
19
+ gem.add_dependency 'i18n'
20
+ gem.add_dependency 'money', '~> 5.0'
21
+
22
+ gem.add_development_dependency 'rspec'
23
+ gem.add_development_dependency 'rake'
24
+ gem.add_development_dependency 'watchr'
19
25
  end
@@ -1,11 +1,13 @@
1
1
  require 'happy-helpers/helpers/html'
2
2
  require 'happy-helpers/helpers/forms'
3
3
  require 'happy-helpers/helpers/i18n'
4
+ require 'happy-helpers/helpers/numbers'
4
5
 
5
6
  module HappyHelpers
6
7
  module Helpers
7
8
  include Html
8
9
  include I18n
9
10
  include Forms
11
+ include Numbers
10
12
  end
11
13
  end
@@ -0,0 +1,14 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'i18n'
3
+ require 'money'
4
+
5
+ module HappyHelpers
6
+ module Helpers
7
+ module Numbers
8
+ def currency(v, options = {})
9
+ money = v.respond_to?(:to_money) ? v.to_money : Money.new(v * 100)
10
+ money.format
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module HappyHelpers
2
- VERSION = "0.1.0.pre.5"
2
+ VERSION = "0.1.0.pre.6"
3
3
  end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require 'money'
4
+
5
+ Money.default_currency = 'EUR'
6
+
7
+ module HappyHelpers
8
+ module Helpers
9
+ describe Numbers do
10
+ describe "#currency" do
11
+ include Numbers
12
+
13
+ it "formats the given numerical value as a currency string" do
14
+ currency(1).should == "€1,00"
15
+ currency(1234.567).should == "€1.234,57"
16
+ end
17
+
18
+ it "also accept string values" do
19
+ currency("EUR 12,99").should == '€12,99'
20
+ end
21
+
22
+ it "knows how to deal with negative values" do
23
+ currency(-1234.56).should == '€-1.234,56'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ SPEC_DIR = File.dirname(__FILE__)
2
+ lib_path = File.expand_path("#{SPEC_DIR}/../lib")
3
+ $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
4
+
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+
8
+ require 'happy-helpers'
9
+
10
+ module SpecHelpers
11
+ end
12
+
13
+ RSpec.configure do |conf|
14
+ conf.include SpecHelpers
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happy-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.5
4
+ version: 0.1.0.pre.6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-31 00:00:00.000000000 Z
12
+ date: 2012-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
16
- requirement: &70251115759740 !ruby/object:Gem::Requirement
16
+ requirement: &70138109397620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,62 @@ dependencies:
21
21
  version: '1.3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70251115759740
24
+ version_requirements: *70138109397620
25
+ - !ruby/object:Gem::Dependency
26
+ name: i18n
27
+ requirement: &70138109396860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70138109396860
36
+ - !ruby/object:Gem::Dependency
37
+ name: money
38
+ requirement: &70138109395800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '5.0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70138109395800
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70138109393740 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70138109393740
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &70138109392960 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70138109392960
69
+ - !ruby/object:Gem::Dependency
70
+ name: watchr
71
+ requirement: &70138109391460 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70138109391460
25
80
  description: View helpers for your custom Rack app or framework.
26
81
  email:
27
82
  - hendrik@mans.de
@@ -30,19 +85,24 @@ extensions: []
30
85
  extra_rdoc_files: []
31
86
  files:
32
87
  - .gitignore
88
+ - .rspec
89
+ - .watchr
33
90
  - Gemfile
34
91
  - LICENSE
35
92
  - README.md
36
93
  - Rakefile
94
+ - happy-helpers.gemspec
37
95
  - lib/happy-helpers.rb
38
96
  - lib/happy-helpers/helpers.rb
39
97
  - lib/happy-helpers/helpers/forms.rb
40
98
  - lib/happy-helpers/helpers/html.rb
41
99
  - lib/happy-helpers/helpers/i18n.rb
100
+ - lib/happy-helpers/helpers/numbers.rb
42
101
  - lib/happy-helpers/templates.rb
43
102
  - lib/happy-helpers/utils/date_parameter_converter.rb
44
103
  - lib/happy-helpers/version.rb
45
- - niles.gemspec
104
+ - spec/helpers/numbers_spec.rb
105
+ - spec/spec_helper.rb
46
106
  homepage: https://github.com/hmans/happy-helpers
47
107
  licenses: []
48
108
  post_install_message:
@@ -67,5 +127,7 @@ rubygems_version: 1.8.11
67
127
  signing_key:
68
128
  specification_version: 3
69
129
  summary: View helpers for your custom Rack app or framework.
70
- test_files: []
130
+ test_files:
131
+ - spec/helpers/numbers_spec.rb
132
+ - spec/spec_helper.rb
71
133
  has_rdoc: