acts_as_price 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Gemfile +4 -8
  2. data/README.rdoc +3 -1
  3. data/Rakefile +11 -16
  4. data/VERSION +1 -1
  5. data/acts_as_price.gemspec +56 -48
  6. data/lib/acts_as_price.rb +5 -1
  7. data/rdoc/ActiveRecord.html +154 -0
  8. data/rdoc/ActiveRecord/Acts.html +154 -0
  9. data/rdoc/ActiveRecord/Acts/Price.html +203 -0
  10. data/rdoc/ActiveRecord/Acts/Price/ClassMethods.html +251 -0
  11. data/rdoc/ActsAsPriceHelper.html +458 -0
  12. data/rdoc/README_rdoc.html +238 -0
  13. data/rdoc/created.rid +4 -1
  14. data/rdoc/images/brick.png +0 -0
  15. data/rdoc/images/brick_link.png +0 -0
  16. data/rdoc/images/bug.png +0 -0
  17. data/rdoc/images/bullet_black.png +0 -0
  18. data/rdoc/images/bullet_toggle_minus.png +0 -0
  19. data/rdoc/images/bullet_toggle_plus.png +0 -0
  20. data/rdoc/images/date.png +0 -0
  21. data/rdoc/images/find.png +0 -0
  22. data/rdoc/images/loadingAnimation.gif +0 -0
  23. data/rdoc/images/macFFBgHack.png +0 -0
  24. data/rdoc/images/package.png +0 -0
  25. data/rdoc/images/page_green.png +0 -0
  26. data/rdoc/images/page_white_text.png +0 -0
  27. data/rdoc/images/page_white_width.png +0 -0
  28. data/rdoc/images/plugin.png +0 -0
  29. data/rdoc/images/ruby.png +0 -0
  30. data/rdoc/images/tag_green.png +0 -0
  31. data/rdoc/images/wrench.png +0 -0
  32. data/rdoc/images/wrench_orange.png +0 -0
  33. data/rdoc/images/zoom.png +0 -0
  34. data/rdoc/index.html +74 -20
  35. data/rdoc/js/darkfish.js +116 -0
  36. data/rdoc/js/jquery.js +32 -0
  37. data/rdoc/js/quicksearch.js +114 -0
  38. data/rdoc/js/thickbox-compressed.js +10 -0
  39. data/rdoc/lib/acts_as_price_helper_rb.html +52 -0
  40. data/rdoc/lib/acts_as_price_rb.html +52 -0
  41. data/rdoc/rdoc.css +706 -0
  42. data/spec/advanced_tests/car_spec.rb +0 -19
  43. data/spec/advanced_tests/fueltype_spec.rb +0 -18
  44. data/spec/models/car.rb +3 -2
  45. data/spec/spec_helper.rb +23 -4
  46. metadata +93 -175
  47. data/Gemfile.lock +0 -166
@@ -0,0 +1,238 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: README.rdoc [ActsAsPrice]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file">
24
+ <div id="metadata">
25
+ <div id="home-metadata">
26
+ <div id="home-section" class="section">
27
+ <h3 class="section-header">
28
+ <a href="./index.html">Home</a>
29
+ <a href="./index.html#classes">Classes</a>
30
+ <a href="./index.html#methods">Methods</a>
31
+ </h3>
32
+ </div>
33
+ </div>
34
+
35
+ <div id="project-metadata">
36
+
37
+
38
+ <div id="fileindex-section" class="section project-section">
39
+ <h3 class="section-header">Files</h3>
40
+ <ul>
41
+
42
+ <li class="file"><a href="./README_rdoc.html">README.rdoc</a></li>
43
+
44
+ </ul>
45
+ </div>
46
+
47
+
48
+ <div id="classindex-section" class="section project-section">
49
+ <h3 class="section-header">Class Index
50
+ <span class="search-toggle"><img src="./images/find.png"
51
+ height="16" width="16" alt="[+]"
52
+ title="show/hide quicksearch" /></span></h3>
53
+ <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
54
+ <fieldset>
55
+ <legend>Quicksearch</legend>
56
+ <input type="text" name="quicksearch" value=""
57
+ class="quicksearch-field" />
58
+ </fieldset>
59
+ </form>
60
+
61
+ <ul class="link-list">
62
+
63
+ <li><a href="./ActiveRecord.html">ActiveRecord</a></li>
64
+
65
+ <li><a href="./ActiveRecord/Acts.html">ActiveRecord::Acts</a></li>
66
+
67
+ <li><a href="./ActiveRecord/Acts/Price.html">ActiveRecord::Acts::Price</a></li>
68
+
69
+ <li><a href="./ActiveRecord/Acts/Price/ClassMethods.html">ActiveRecord::Acts::Price::ClassMethods</a></li>
70
+
71
+ <li><a href="./ActsAsPriceHelper.html">ActsAsPriceHelper</a></li>
72
+
73
+ </ul>
74
+ <div id="no-class-search-results" style="display: none;">No matching classes.</div>
75
+ </div>
76
+
77
+
78
+ </div>
79
+ </div>
80
+
81
+ <div id="documentation">
82
+ <h1>INSTALLATION</h1>
83
+ <p>
84
+ Plugin: rails plugin install git@github.com:jeroeningen/acts_as_price.git
85
+ </p>
86
+ <p>
87
+ Gem: If you&#8217;re on Ruby 1.8, please use version 0.2.3 of the Gem. If
88
+ you&#8217;re on Ruby 1.9 please use version 0.2.4 of the Gem.
89
+ </p>
90
+ <h1>USAGE</h1>
91
+ <p>
92
+ Create a column in the table of your database which you want to acts as a
93
+ price.
94
+ </p>
95
+ <p>
96
+ NOTE THAT THE COLUMN MUST BE OF THE TYPE INTEGER.
97
+ </p>
98
+ <p>
99
+ In your model add the following:
100
+ </p>
101
+ <ul>
102
+ <li><p>
103
+ acts_as_price column_name, {:validates => true, :comma_seperated => true,
104
+ :currency => currency}
105
+ </p>
106
+ </li>
107
+ </ul>
108
+ <p>
109
+ column_name is the name of your database column e.g. price or
110
+ price_per_liter.
111
+ </p>
112
+ <p>
113
+ validates is optional and add validation to the column
114
+ </p>
115
+ <p>
116
+ comma_seperated is optional and return the price comma seperated instead of
117
+ dot seperated
118
+ </p>
119
+ <p>
120
+ currency is optional and adds a prefix for the currency to the price.
121
+ </p>
122
+ <p>
123
+ This plugin creates the following getters and setters:
124
+ </p>
125
+ <ul>
126
+ <li><p>
127
+ &#8216;price_in_cents&#8217; and &#8217;<column_name>_in_cents&#8217; # and
128
+ returns the price in cents
129
+ </p>
130
+ </li>
131
+ <li><p>
132
+ &#8216;price&#8217; and &#8217;<column_name>&#8217; # and returns the price
133
+ </p>
134
+ </li>
135
+ </ul>
136
+ <h1>EXAMPLES</h1>
137
+ <pre>
138
+ class Car &lt; ActiveRecord::Base
139
+ acts_as_price :price, :comma_seperated =&gt; true, :currency =&gt; &quot;EUR&quot;
140
+ end
141
+ </pre>
142
+ <p>
143
+ car = Car.new :price => 12999
144
+ </p>
145
+ <p>
146
+ car.price -> EUR. 12999,00
147
+ </p>
148
+ <p>
149
+ car.price_in_cents -> 1299900
150
+ </p>
151
+ <pre>
152
+ class Fueltype &lt; ActiveRecord::Base
153
+ acts_as_price :price_per_liter, :validates =&gt; true
154
+ end
155
+
156
+ </pre>
157
+ <p>
158
+ fuel = Fueltype.new :price_per_liter => 1.12
159
+ </p>
160
+ <p>
161
+ fuel.price -> 1.12
162
+ </p>
163
+ <p>
164
+ fuel.price_in_cents -> 112
165
+ </p>
166
+ <p>
167
+ fuel.price_per_liter -> 1.12
168
+ </p>
169
+ <p>
170
+ fuel.price_per_liter_in_cents -> 1.12
171
+ </p>
172
+ <h1>RSPEC INTERGRATION</h1>
173
+ <p>
174
+ Acts As Price comes with a helper method to automatically test the plugin
175
+ using Rspec.
176
+ </p>
177
+ <p>
178
+ To use this method please add the following to your spec_helper.rb file:
179
+ </p>
180
+ <ul>
181
+ <li><p>
182
+ config.include(<a href="ActsAsPriceHelper.html">ActsAsPriceHelper</a>)
183
+ </p>
184
+ </li>
185
+ <li><p>
186
+ and if you using the gem, please also add: require
187
+ &#8216;acts_as_price_helper&#8216;
188
+ </p>
189
+ </li>
190
+ </ul>
191
+ <p>
192
+ Now you may add the following code to your spec-files for your models:
193
+ </p>
194
+ <pre>
195
+ context &quot;given an valid model&quot; do
196
+ it &quot;should acts as price&quot; do
197
+ test_acts_as_price_methods &lt;column_name&gt;, &lt;fixture or stub&gt;
198
+ end
199
+ end
200
+ </pre>
201
+ <h1>TESTING</h1>
202
+ <p>
203
+ To test the plugin use the command &#8216;rspec spec/**&#8217; inside the
204
+ dir &#8217;~/vendor/plugins/acts_as_price&#8217;
205
+ </p>
206
+ <h1>KNOWN BUGS</h1>
207
+ <p>
208
+ The command &#8216;rake test&#8217; is not running properly at the moment.
209
+ </p>
210
+ <p>
211
+ When creating a text_field, by default Rails gets the &#8216;raw&#8217;
212
+ value from the database, so you probably get the wrong value in your
213
+ text_field. To prevent this please do the following:
214
+ </p>
215
+ <pre>
216
+ f.textfield :price, :value =&gt; @object.price
217
+ </pre>
218
+ <h1>NOTES</h1>
219
+ <p>
220
+ This plugin comes with Rspec tests. However this plugin assumes that you
221
+ have a database configuration, it actually don&#8217;t use the database for
222
+ the Rspec tests.
223
+ </p>
224
+ <h1>FEEDBACK AND BUGS REPORTS</h1>
225
+ <p>
226
+ For feedback and bug reports contact: jeroeningen@gmail.com
227
+ </p>
228
+
229
+ </div>
230
+
231
+ <div id="validator-badges">
232
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
233
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
234
+ Rdoc Generator</a> 1.1.6</small>.</p>
235
+ </div>
236
+ </body>
237
+ </html>
238
+
data/rdoc/created.rid CHANGED
@@ -1 +1,4 @@
1
- Sun, 01 May 2011 08:58:34 -0700
1
+ Fri, 03 Jun 2011 11:42:51 +0200
2
+ README.rdoc Fri, 03 Jun 2011 11:42:47 +0200
3
+ lib/acts_as_price_helper.rb Fri, 03 Jun 2011 11:09:05 +0200
4
+ lib/acts_as_price.rb Fri, 03 Jun 2011 11:13:08 +0200
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/rdoc/index.html CHANGED
@@ -1,24 +1,78 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html
3
- PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
5
4
 
6
- <!--
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
8
 
8
- ActsAsPrice
9
+ <title>ActsAsPrice</title>
10
+
11
+ <link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
14
+ <script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
15
+ <script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
16
+ <script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
9
17
 
10
- -->
11
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
- <head>
13
- <title>ActsAsPrice</title>
14
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
18
  </head>
16
- <frameset rows="20%, 80%">
17
- <frameset cols="25%,35%,45%">
18
- <frame src="fr_file_index.html" title="Files" name="Files" />
19
- <frame src="fr_class_index.html" name="Classes" />
20
- <frame src="fr_method_index.html" name="Methods" />
21
- </frameset>
22
- <frame src="files/README_rdoc.html" name="docwin" />
23
- </frameset>
24
- </html>
19
+ <body class="indexpage">
20
+
21
+
22
+ <h1>ActsAsPrice</h1>
23
+
24
+
25
+ <p>This is the API documentation for 'ActsAsPrice'.</p>
26
+
27
+
28
+
29
+
30
+ <h2>Files</h2>
31
+ <ul>
32
+
33
+ <li class="file"><a href="README_rdoc.html">README.rdoc</a></li>
34
+
35
+ </ul>
36
+
37
+
38
+ <h2 id="classes">Classes/Modules</h2>
39
+ <ul>
40
+
41
+ <li class="module"><a href="ActiveRecord.html">ActiveRecord</a></li>
42
+
43
+ <li class="module"><a href="ActiveRecord/Acts.html">ActiveRecord::Acts</a></li>
44
+
45
+ <li class="module"><a href="ActiveRecord/Acts/Price.html">ActiveRecord::Acts::Price</a></li>
46
+
47
+ <li class="module"><a href="ActiveRecord/Acts/Price/ClassMethods.html">ActiveRecord::Acts::Price::ClassMethods</a></li>
48
+
49
+ <li class="module"><a href="ActsAsPriceHelper.html">ActsAsPriceHelper</a></li>
50
+
51
+ </ul>
52
+
53
+ <h2 id="methods">Methods</h2>
54
+ <ul>
55
+
56
+ <li><a href="ActiveRecord/Acts/Price.html#method-c-included">::included &mdash; ActiveRecord::Acts::Price</a></li>
57
+
58
+ <li><a href="ActiveRecord/Acts/Price/ClassMethods.html#method-i-acts_as_price">#acts_as_price &mdash; ActiveRecord::Acts::Price::ClassMethods</a></li>
59
+
60
+ <li><a href="ActsAsPriceHelper.html#method-i-columns_in_cents">#columns_in_cents &mdash; ActsAsPriceHelper</a></li>
61
+
62
+ <li><a href="ActsAsPriceHelper.html#method-i-columns_in_doubles">#columns_in_doubles &mdash; ActsAsPriceHelper</a></li>
63
+
64
+ <li><a href="ActsAsPriceHelper.html#method-i-test_acts_as_price_methods">#test_acts_as_price_methods &mdash; ActsAsPriceHelper</a></li>
65
+
66
+ <li><a href="ActsAsPriceHelper.html#method-i-test_setter_in_cents">#test_setter_in_cents &mdash; ActsAsPriceHelper</a></li>
67
+
68
+ <li><a href="ActsAsPriceHelper.html#method-i-test_setter_in_doubles">#test_setter_in_doubles &mdash; ActsAsPriceHelper</a></li>
69
+
70
+ </ul>
71
+
72
+ <div id="validator-badges">
73
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
74
+ <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
75
+ Rdoc Generator</a> 1.1.6</small>.</p>
76
+ </div>
77
+ </body>
78
+ </html>
@@ -0,0 +1,116 @@
1
+ /**
2
+ *
3
+ * Darkfish Page Functions
4
+ * $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
5
+ *
6
+ * Author: Michael Granger <mgranger@laika.com>
7
+ *
8
+ */
9
+
10
+ /* Provide console simulation for firebug-less environments */
11
+ if (!("console" in window) || !("firebug" in console)) {
12
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
13
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
14
+
15
+ window.console = {};
16
+ for (var i = 0; i < names.length; ++i)
17
+ window.console[names[i]] = function() {};
18
+ };
19
+
20
+
21
+ /**
22
+ * Unwrap the first element that matches the given @expr@ from the targets and return them.
23
+ */
24
+ $.fn.unwrap = function( expr ) {
25
+ return this.each( function() {
26
+ $(this).parents( expr ).eq( 0 ).after( this ).remove();
27
+ });
28
+ };
29
+
30
+
31
+ function showSource( e ) {
32
+ var target = e.target;
33
+ var codeSections = $(target).
34
+ parents('.method-detail').
35
+ find('.method-source-code');
36
+
37
+ $(target).
38
+ parents('.method-detail').
39
+ find('.method-source-code').
40
+ slideToggle();
41
+ };
42
+
43
+ function hookSourceViews() {
44
+ $('.method-description,.method-heading').click( showSource );
45
+ };
46
+
47
+ function toggleDebuggingSection() {
48
+ $('.debugging-section').slideToggle();
49
+ };
50
+
51
+ function hookDebuggingToggle() {
52
+ $('#debugging-toggle img').click( toggleDebuggingSection );
53
+ };
54
+
55
+ function hookQuickSearch() {
56
+ $('.quicksearch-field').each( function() {
57
+ var searchElems = $(this).parents('.section').find( 'li' );
58
+ var toggle = $(this).parents('.section').find('h3 .search-toggle');
59
+ // console.debug( "Toggle is: %o", toggle );
60
+ var qsbox = $(this).parents('form').get( 0 );
61
+
62
+ $(this).quicksearch( this, searchElems, {
63
+ noSearchResultsIndicator: 'no-class-search-results',
64
+ focusOnLoad: false
65
+ });
66
+ $(toggle).click( function() {
67
+ // console.debug( "Toggling qsbox: %o", qsbox );
68
+ $(qsbox).toggle();
69
+ });
70
+ });
71
+ };
72
+
73
+ function highlightTarget( anchor ) {
74
+ console.debug( "Highlighting target '%s'.", anchor );
75
+
76
+ $("a[name=" + anchor + "]").each( function() {
77
+ if ( !$(this).parent().parent().hasClass('target-section') ) {
78
+ console.debug( "Wrapping the target-section" );
79
+ $('div.method-detail').unwrap( 'div.target-section' );
80
+ $(this).parent().wrap( '<div class="target-section"></div>' );
81
+ } else {
82
+ console.debug( "Already wrapped." );
83
+ }
84
+ });
85
+ };
86
+
87
+ function highlightLocationTarget() {
88
+ console.debug( "Location hash: %s", window.location.hash );
89
+ if ( ! window.location.hash || window.location.hash.length == 0 ) return;
90
+
91
+ var anchor = window.location.hash.substring(1);
92
+ console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" );
93
+
94
+ highlightTarget( anchor );
95
+ };
96
+
97
+ function highlightClickTarget( event ) {
98
+ console.debug( "Highlighting click target for event %o", event.target );
99
+ try {
100
+ var anchor = $(event.target).attr( 'href' ).substring(1);
101
+ console.debug( "Found target anchor: %s", anchor );
102
+ highlightTarget( anchor );
103
+ } catch ( err ) {
104
+ console.error( "Exception while highlighting: %o", err );
105
+ };
106
+ };
107
+
108
+
109
+ $(document).ready( function() {
110
+ hookSourceViews();
111
+ hookDebuggingToggle();
112
+ hookQuickSearch();
113
+ highlightLocationTarget();
114
+
115
+ $('ul.link-list a').bind( "click", highlightClickTarget );
116
+ });