osheet 1.0.0.rc.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +17 -6
  2. data/Gemfile +3 -4
  3. data/LICENSE.txt +22 -0
  4. data/README.md +129 -0
  5. data/Rakefile +1 -7
  6. data/lib/osheet/cell.rb +0 -1
  7. data/lib/osheet/column.rb +3 -2
  8. data/lib/osheet/format.rb +9 -9
  9. data/lib/osheet/format/accounting.rb +0 -1
  10. data/lib/osheet/format/currency.rb +1 -1
  11. data/lib/osheet/format/custom.rb +0 -1
  12. data/lib/osheet/format/datetime.rb +0 -1
  13. data/lib/osheet/format/fraction.rb +0 -1
  14. data/lib/osheet/format/general.rb +2 -2
  15. data/lib/osheet/format/number.rb +0 -1
  16. data/lib/osheet/format/numeric.rb +2 -1
  17. data/lib/osheet/format/percentage.rb +2 -1
  18. data/lib/osheet/format/scientific.rb +2 -1
  19. data/lib/osheet/format/special.rb +0 -1
  20. data/lib/osheet/format/text.rb +0 -1
  21. data/lib/osheet/mixin.rb +1 -0
  22. data/lib/osheet/row.rb +0 -1
  23. data/lib/osheet/style.rb +1 -0
  24. data/lib/osheet/styled_element.rb +1 -0
  25. data/lib/osheet/version.rb +1 -1
  26. data/lib/osheet/workbook.rb +0 -4
  27. data/lib/osheet/workbook_element.rb +0 -10
  28. data/osheet.gemspec +18 -16
  29. data/test/helper.rb +6 -2
  30. data/test/{fixtures → support}/mixins.rb +0 -0
  31. data/test/{fixtures → support}/test_writer.rb +0 -0
  32. data/test/{cell_test.rb → unit/cell_tests.rb} +15 -12
  33. data/test/{column_test.rb → unit/column_tests.rb} +10 -9
  34. data/test/{format/accounting_test.rb → unit/format/accounting_tests.rb} +35 -26
  35. data/test/{format/currency_test.rb → unit/format/currency_tests.rb} +35 -26
  36. data/test/{format/custom_test.rb → unit/format/custom_tests.rb} +6 -5
  37. data/test/{format/datetime_test.rb → unit/format/datetime_tests.rb} +6 -5
  38. data/test/{format/fraction_test.rb → unit/format/fraction_tests.rb} +16 -16
  39. data/test/{format/general_test.rb → unit/format/general_tests.rb} +5 -5
  40. data/test/unit/format/number_tests.rb +96 -0
  41. data/test/{format/percentage_test.rb → unit/format/percentage_tests.rb} +32 -23
  42. data/test/{format/scientific_test.rb → unit/format/scientific_tests.rb} +31 -23
  43. data/test/{format/special_test.rb → unit/format/special_tests.rb} +11 -11
  44. data/test/{format/text_test.rb → unit/format/text_tests.rb} +4 -4
  45. data/test/{format_test.rb → unit/format_tests.rb} +8 -7
  46. data/test/{mixin_test.rb → unit/mixin_tests.rb} +11 -10
  47. data/test/{partial_test.rb → unit/partial_tests.rb} +13 -10
  48. data/test/{row_test.rb → unit/row_tests.rb} +11 -10
  49. data/test/{style_test.rb → unit/style_tests.rb} +13 -14
  50. data/test/{template_test.rb → unit/template_tests.rb} +15 -12
  51. data/test/{workbook_element_test.rb → unit/workbook_element_tests.rb} +48 -54
  52. data/test/{workbook_test.rb → unit/workbook_tests.rb} +34 -30
  53. data/test/{worksheet_test.rb → unit/worksheet_tests.rb} +13 -13
  54. metadata +70 -76
  55. data/Gemfile.lock +0 -27
  56. data/README.rdoc +0 -133
  57. data/test/format/number_test.rb +0 -91
  58. data/test/irb.rb +0 -9
data/Gemfile.lock DELETED
@@ -1,27 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- osheet (1.0.0.rc.4)
5
- enumeration (~> 1.3)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- ansi (1.4.2)
11
- assert (0.7.3)
12
- assert-view (~> 0.5)
13
- assert-view (0.5.0)
14
- ansi (~> 1.3)
15
- undies (~> 2.0)
16
- enumeration (1.3.1)
17
- rake (0.9.2.2)
18
- undies (2.2.1)
19
-
20
- PLATFORMS
21
- ruby
22
-
23
- DEPENDENCIES
24
- assert (~> 0.3)
25
- bundler (~> 1.1)
26
- osheet!
27
- rake (~> 0.9.2)
data/README.rdoc DELETED
@@ -1,133 +0,0 @@
1
- = Osheet
2
-
3
- == Description
4
-
5
- A DSL for specifying and generating spreadsheets using Ruby.
6
-
7
- == Installation
8
-
9
- $ gem install osheet
10
-
11
- == Basic Example
12
-
13
- This example uses the Xmlss writer provided by Osheet::Xmlss (https://github.com/kellyredding/osheet-xmlss).
14
-
15
- require 'osheet/xmlss'
16
-
17
- fields = ['Sex', 'Age', 'Height', 'Weight']
18
- data = {
19
- 'Tom' => ['M', 52, "6'2\"", '220 lbs.'],
20
- 'Dick' => ['M', 33, "6'5\"", '243 lbs.'],
21
- 'Sally' => ['F', 29, "5'3\"", '132 lbs.']
22
- }
23
-
24
- # this will dump the above data to a single-sheet workbook w/ no styles
25
- # - this example is using the Xmlss writer (https://github.com/kellyredding/xmlss)
26
-
27
- Osheet::Workbook.new(Osheet::XmlssWriter.new) {
28
- title "basic"
29
-
30
- template(:column, :data) { |field, index|
31
- width 80
32
- meta(
33
- :label => field.to_s,
34
- :index => index
35
- )
36
- }
37
-
38
- template(:row, :title) {
39
- cell {
40
- colspan columns.count
41
- data worksheet.name
42
- }
43
- }
44
-
45
- template(:row, :empty) {
46
- cell {
47
- colspan columns.count
48
- data ''
49
- }
50
- }
51
-
52
- template(:row, :header) {
53
- columns.each do |column|
54
- cell {
55
- data column.meta[:label]
56
- }
57
- end
58
- }
59
-
60
- template(:row, :data) { |name, stats|
61
- cell {
62
- data name
63
- }
64
- stats.each do |stat|
65
- cell {
66
- data stat
67
- }
68
- end
69
- }
70
-
71
- worksheet {
72
- name "Stats: #{fields.join(', ')}"
73
-
74
- column {
75
- width 200
76
- meta(
77
- :label => "Name"
78
- )
79
- }
80
- fields.each_with_index do |f, i|
81
- column :data, f, i
82
- end
83
-
84
- row :title
85
- row :empty
86
- row :header
87
-
88
- data.each do |name, stats|
89
- row :data, name, stats
90
- end
91
- }
92
- }.to_file('stats.xls')
93
-
94
- == API
95
-
96
- Check out the wiki: https://github.com/kelredd/osheet/wiki. It covers the full Osheet API.
97
-
98
- == Examples
99
-
100
- I've add a few examples to ./examples. Please refer first to the API then to these for examples on basic usage, using templates, formatting data, and styling data.
101
-
102
- == Links
103
-
104
- * *Osheet*
105
- - http://github.com/kelredd/osheet
106
-
107
- * *Wiki*
108
- - https://github.com/kelredd/osheet/wiki
109
-
110
- == License
111
-
112
- Copyright (c) 2010-Present, Kelly Redding (mailto:kelly@kellyredding.com)
113
-
114
- Permission is hereby granted, free of charge, to any person
115
- obtaining a copy of this software and associated documentation
116
- files (the "Software"), to deal in the Software without
117
- restriction, including without limitation the rights to use,
118
- copy, modify, merge, publish, distribute, sublicense, and/or sell
119
- copies of the Software, and to permit persons to whom the
120
- Software is furnished to do so, subject to the following
121
- conditions:
122
-
123
- The above copyright notice and this permission notice shall be
124
- included in all copies or substantial portions of the Software.
125
-
126
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
127
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
128
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
129
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
130
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
131
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
132
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
133
- OTHER DEALINGS IN THE SOFTWARE.
@@ -1,91 +0,0 @@
1
- require "assert"
2
- require 'osheet/format/number'
3
-
4
- module Osheet::Format
5
-
6
- class NumberTest < Assert::Context
7
- desc "Number format"
8
- before { @n = Number.new }
9
- subject { @n }
10
-
11
- should have_accessors :decimal_places, :comma_separator, :negative_numbers
12
-
13
- should "provide options for negative numbers" do
14
- assert_equal 4, Number.negative_numbers_set.size
15
- [:black, :black_parenth, :red, :red_parenth].each do |a|
16
- assert Number.negative_numbers_set.include?(a)
17
- end
18
- end
19
-
20
- should "set default values" do
21
- assert_equal 0, subject.decimal_places
22
- assert_equal false, subject.comma_separator
23
- assert_equal 'black', subject.negative_numbers
24
- end
25
-
26
- should "only allow Fixnum decimal places between 0 and 30" do
27
- assert_raises ArgumentError do
28
- Number.new({:decimal_places => -1})
29
- end
30
- assert_raises ArgumentError do
31
- Number.new({:decimal_places => 31})
32
- end
33
- assert_raises ArgumentError do
34
- Number.new({:decimal_places => 'poo'})
35
- end
36
- assert_nothing_raised do
37
- Number.new({:decimal_places => 1})
38
- end
39
- end
40
-
41
- should "generate decimal place style strings" do
42
- assert_equal "0", Number.new({:decimal_places => 0}).style
43
- (1..5).each do |n|
44
- assert_equal "0.#{'0'*n}", Number.new({:decimal_places => n}).style
45
- end
46
- end
47
-
48
- should "generate comma separator style strings" do
49
- assert_equal "0", Number.new({:comma_separator => false}).style
50
- assert_equal "#,##0", Number.new({:comma_separator => true}).style
51
- end
52
-
53
- should "generate parenth negative numbers style strings" do
54
- assert_equal "0", Number.new({:negative_numbers => :black}).style
55
- assert_equal "0_);\(0\)", Number.new({:negative_numbers => :black_parenth}).style
56
- end
57
-
58
- should "generate red negative numbers style strings" do
59
- assert_equal "0;[Red]0", Number.new({:negative_numbers => :red}).style
60
- assert_equal "0_);[Red]\(0\)", Number.new({:negative_numbers => :red_parenth}).style
61
- end
62
-
63
- should "generate complex style string" do
64
- assert_equal("0.00_);\(0.00\)", Number.new({
65
- :decimal_places => 2,
66
- :negative_numbers => :black_parenth,
67
- :comma_separator => false
68
- }).style)
69
- assert_equal("#,##0.0000_);[Red]\(#,##0.0000\)", Number.new({
70
- :decimal_places => 4,
71
- :negative_numbers => :red_parenth,
72
- :comma_separator => true
73
- }).style)
74
- end
75
-
76
- should "provide unique format keys" do
77
- assert_equal("number_none_2_nocomma_blackparenth", Number.new({
78
- :decimal_places => 2,
79
- :negative_numbers => :black_parenth,
80
- :comma_separator => false
81
- }).key)
82
- assert_equal("number_none_4_comma_redparenth", Number.new({
83
- :decimal_places => 4,
84
- :negative_numbers => :red_parenth,
85
- :comma_separator => true
86
- }).key)
87
- end
88
-
89
- end
90
-
91
- end
data/test/irb.rb DELETED
@@ -1,9 +0,0 @@
1
- require 'assert/setup'
2
-
3
- # this file is required in when the 'irb' rake test is run.
4
- # b/c 'assert' is required above, the test helper will be
5
- # required in.
6
-
7
- # put any IRB setup code here
8
-
9
- require 'osheet'