digital_opera 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +10 -0
- data/lib/digital_opera.rb +7 -0
- data/lib/digital_opera/banker.rb +45 -0
- data/lib/digital_opera/object_extensions/nil_or_zero.rb +5 -0
- data/lib/digital_opera/presenter/base.rb +19 -0
- data/lib/digital_opera/token.rb +16 -0
- data/lib/digital_opera/version.rb +3 -0
- metadata +92 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
##
|
2
|
+
# DigitalOpera::Banker
|
3
|
+
# Author: JD Hendrickson
|
4
|
+
# Date: 08/30/2012
|
5
|
+
#
|
6
|
+
# Adds support for simple currency conversions allowing for easy setup to
|
7
|
+
# save all currencies in cents and return them as dollars.
|
8
|
+
#
|
9
|
+
module DigitalOpera
|
10
|
+
module Banker
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def currency_fields(*args)
|
15
|
+
args.each do |field_name|
|
16
|
+
getter = field_name.to_sym
|
17
|
+
setter = "#{field_name}=".to_sym
|
18
|
+
instance_getter = "#{field_name}_in_cents".to_sym
|
19
|
+
instance_setter = "#{field_name}_in_cents=".to_sym
|
20
|
+
|
21
|
+
# define the getter method
|
22
|
+
send :define_method, getter do
|
23
|
+
value = send(instance_getter)
|
24
|
+
banker_convert_currency(value, :to_dollars)
|
25
|
+
end
|
26
|
+
|
27
|
+
# define the setter method
|
28
|
+
send :define_method, setter do |value|
|
29
|
+
send instance_setter, banker_convert_currency(value, :to_cents)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Instance Methods --------------------------------------------------------
|
36
|
+
def banker_convert_currency(value, conversion)
|
37
|
+
case conversion.to_sym
|
38
|
+
when :to_cents
|
39
|
+
return (value.to_s.gsub(/,/, '').to_f * 100).to_i
|
40
|
+
when :to_dollars
|
41
|
+
return "%0.2f" % (value.to_f / 100)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# DigitalOpera::Presenter::Base
|
2
|
+
#
|
3
|
+
# @author: JD Hendrickson
|
4
|
+
# @date: 11/08/2013
|
5
|
+
#
|
6
|
+
module DigitalOpera
|
7
|
+
module Presenter
|
8
|
+
class Base < SimpleDelegator
|
9
|
+
def initialize(base, view_context=nil)
|
10
|
+
super(base)
|
11
|
+
@view_context = view_context || ActionController::Base.new.view_context
|
12
|
+
end
|
13
|
+
|
14
|
+
def _h
|
15
|
+
@view_context
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
##
|
2
|
+
# Class: Token
|
3
|
+
# Author: JD Hendrickson
|
4
|
+
# Date: 07/16/2011
|
5
|
+
#
|
6
|
+
# Generates random alpha-numeric strings of the specified key length.
|
7
|
+
# Default key length is 40 characters.
|
8
|
+
module DigitalOpera
|
9
|
+
class Token
|
10
|
+
def self.generate(key_len = 40)
|
11
|
+
alphanumerics = ('a'..'z').to_a.concat(('A'..'Z').to_a.concat(('0'..'9').to_a))
|
12
|
+
secret_key = alphanumerics.sort_by{rand}.join[0..key_len]
|
13
|
+
secret_key
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: digital_opera
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- JD Hendrickson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Tools and utilities for helping out in developing Ruby applications
|
47
|
+
email:
|
48
|
+
- jd@digitalopera.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/digital_opera/banker.rb
|
54
|
+
- lib/digital_opera/object_extensions/nil_or_zero.rb
|
55
|
+
- lib/digital_opera/presenter/base.rb
|
56
|
+
- lib/digital_opera/token.rb
|
57
|
+
- lib/digital_opera/version.rb
|
58
|
+
- lib/digital_opera.rb
|
59
|
+
- MIT-LICENSE
|
60
|
+
- Rakefile
|
61
|
+
- README.rdoc
|
62
|
+
homepage: http://www.digitalopera.com/
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
hash: -3351971250809790088
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
hash: -3351971250809790088
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.24
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: Tools and utilities for helping out in developing Ruby applications
|
92
|
+
test_files: []
|