osheet 1.0.0.rc.2 → 1.0.0.rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osheet (1.0.0.rc.2)
4
+ osheet (1.0.0.rc.3)
5
5
  enumeration (~> 1.3)
6
6
 
7
7
  GEM
data/lib/osheet/format.rb CHANGED
@@ -20,7 +20,7 @@ module Osheet::Format
20
20
 
21
21
  class << self
22
22
  def new(type, *args)
23
- unless VALUES.include?(type)
23
+ unless VALUES.include?(type.to_sym)
24
24
  raise ArgumentError, "'#{type.inspect}' is not a valid format type"
25
25
  end
26
26
  self.const_get(type.to_s.capitalize).new(*args)
@@ -6,7 +6,7 @@ module Osheet::Format
6
6
  class Currency < Osheet::Format::Numeric
7
7
  def initialize(opts={})
8
8
  super({
9
- :symbol => :dollar,
9
+ :symbol => 'dollar',
10
10
  :decimal_places => 2,
11
11
  :comma_separator => true
12
12
  }.merge(opts))
@@ -8,8 +8,17 @@ module Osheet::Format
8
8
  include Enumeration
9
9
 
10
10
  attr_accessor :decimal_places, :comma_separator
11
- enum :symbol, [:none, :dollar, :euro]
12
- enum :negative_numbers, [:black, :black_parenth, :red, :red_parenth]
11
+ enum :symbol, {
12
+ :none => "none",
13
+ :dollar => "dollar",
14
+ :euro => "euro"
15
+ }
16
+ enum :negative_numbers, {
17
+ :black => "black",
18
+ :black_parenth => "black_parenth",
19
+ :red => "red",
20
+ :red_parenth => "red_parenth"
21
+ }
13
22
 
14
23
  def initialize(opts={})
15
24
  self.symbol = opts[:symbol] || :none
@@ -66,13 +75,13 @@ module Osheet::Format
66
75
 
67
76
  def negative_numbers_style
68
77
  case @negative_numbers
69
- when :black
78
+ when 'black'
70
79
  numeric_style
71
- when :red
80
+ when 'red'
72
81
  "#{numeric_style};[Red]#{numeric_style}"
73
- when :black_parenth
82
+ when 'black_parenth'
74
83
  "#{numeric_style}_);\(#{numeric_style}\)"
75
- when :red_parenth
84
+ when 'red_parenth'
76
85
  "#{numeric_style}_);[Red]\(#{numeric_style}\)"
77
86
  end
78
87
  end
@@ -99,9 +108,9 @@ module Osheet::Format
99
108
 
100
109
  def symbol_style
101
110
  case @symbol
102
- when :dollar
111
+ when 'dollar'
103
112
  "\"$\"#{symbol_suffix}"
104
- when :euro
113
+ when 'euro'
105
114
  "\"€\"#{symbol_suffix}"
106
115
  else
107
116
  ''
data/lib/osheet/style.rb CHANGED
@@ -17,13 +17,14 @@ module Osheet
17
17
  SETTINGS.each { |s| instance_variable_set("@#{s}", []) }
18
18
  end
19
19
 
20
- SETTINGS.each do |setting|
21
- define_method(setting) do |*args|
22
- instance_variable_get("@#{setting}").tap do |value|
23
- instance_variable_set("@#{setting}", value + args) if !args.empty?
24
- end
25
- end
26
- end
20
+ def align(*args); @align += args; end
21
+ def font(*args); @font += args; end
22
+ def bg(*args); @bg += args; end
23
+
24
+ def border_top(*args); @border_top += args; end
25
+ def border_right(*args); @border_right += args; end
26
+ def border_bottom(*args); @border_bottom += args; end
27
+ def border_left(*args); @border_left += args; end
27
28
 
28
29
  def border(*args)
29
30
  BORDERS.each { |border| send(border, *args) }
@@ -1,3 +1,3 @@
1
1
  module Osheet
2
- VERSION = "1.0.0.rc.2"
2
+ VERSION = "1.0.0.rc.3"
3
3
  end
@@ -27,9 +27,9 @@ module Osheet
27
27
 
28
28
  # setup the writer, element stack, and workbook_element
29
29
  writer.bind(self) if writer
30
- set_ivar(:writer, writer)
31
- set_ivar(:element_stack, Workbook::ElementStack.new)
32
- set_ivar(:workbook_element, WorkbookElement.new)
30
+ @_osheet_writer = writer
31
+ @_osheet_element_stack = Workbook::ElementStack.new
32
+ @_osheet_workbook_element = WorkbookElement.new
33
33
 
34
34
  # push the workbook element onto the element stack
35
35
  element_stack.push(workbook)
@@ -39,15 +39,15 @@ module Osheet
39
39
  end
40
40
 
41
41
  def writer
42
- get_ivar(:writer)
42
+ @_osheet_writer
43
43
  end
44
44
 
45
45
  def element_stack
46
- get_ivar(:element_stack)
46
+ @_osheet_element_stack
47
47
  end
48
48
 
49
49
  def workbook_element
50
- get_ivar(:workbook_element)
50
+ @_osheet_workbook_element
51
51
  end
52
52
  alias_method :workbook, :workbook_element
53
53
 
@@ -94,26 +94,6 @@ module Osheet
94
94
  define_method(meth) {|*args| writer.send(meth, *args) }
95
95
  end
96
96
 
97
- private
98
-
99
- OSHEET_IVAR_NS = "_osheet_"
100
-
101
- def get_ivar(name)
102
- instance_variable_get(ivar_name(name))
103
- end
104
-
105
- def set_ivar(name, value)
106
- instance_variable_set(ivar_name(name), value)
107
- end
108
-
109
- def push_ivar(name, value)
110
- get_ivar(name) << value
111
- end
112
-
113
- def ivar_name(name)
114
- "@#{OSHEET_IVAR_NS}#{name}"
115
- end
116
-
117
97
  end
118
98
 
119
99
 
data/osheet.gemspec CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
 
20
20
  s.add_development_dependency("assert", ["~> 0.3"])
21
-
22
21
  s.add_dependency("enumeration", ["~> 1.3"])
23
22
 
24
23
  end
@@ -26,9 +26,9 @@ module Osheet::Format
26
26
 
27
27
  should "set default values" do
28
28
  assert_equal 2, subject.decimal_places
29
- assert_equal :dollar, subject.symbol
29
+ assert_equal 'dollar', subject.symbol
30
30
  assert_equal true, subject.comma_separator
31
- assert_equal :black, subject.negative_numbers
31
+ assert_equal 'black', subject.negative_numbers
32
32
  end
33
33
 
34
34
  should "only allow Fixnum decimal places between 0 and 30" do
@@ -26,9 +26,9 @@ module Osheet::Format
26
26
 
27
27
  should "set default values" do
28
28
  assert_equal 2, subject.decimal_places
29
- assert_equal :dollar, subject.symbol
29
+ assert_equal 'dollar', subject.symbol
30
30
  assert_equal true, subject.comma_separator
31
- assert_equal :black, subject.negative_numbers
31
+ assert_equal 'black', subject.negative_numbers
32
32
  end
33
33
 
34
34
  should "only allow Fixnum decimal places between 0 and 30" do
@@ -20,7 +20,7 @@ module Osheet::Format
20
20
  should "set default values" do
21
21
  assert_equal 0, subject.decimal_places
22
22
  assert_equal false, subject.comma_separator
23
- assert_equal :black, subject.negative_numbers
23
+ assert_equal 'black', subject.negative_numbers
24
24
  end
25
25
 
26
26
  should "only allow Fixnum decimal places between 0 and 30" do
@@ -20,7 +20,7 @@ module Osheet::Format
20
20
  should "set default values" do
21
21
  assert_equal 2, subject.decimal_places
22
22
  assert_equal false, subject.comma_separator
23
- assert_equal :black, subject.negative_numbers
23
+ assert_equal 'black', subject.negative_numbers
24
24
  end
25
25
 
26
26
  should "only allow Fixnum decimal places between 0 and 30" do
@@ -20,7 +20,7 @@ module Osheet::Format
20
20
  should "set default values" do
21
21
  assert_equal 2, subject.decimal_places
22
22
  assert_equal false, subject.comma_separator
23
- assert_equal :black, subject.negative_numbers
23
+ assert_equal 'black', subject.negative_numbers
24
24
  end
25
25
 
26
26
  should "only allow Fixnum decimal places between 0 and 30" do
data/test/format_test.rb CHANGED
@@ -18,7 +18,7 @@ module Osheet
18
18
  assert_kind_of Format::Number, subject
19
19
  assert_equal 4, subject.decimal_places
20
20
  assert_equal true, subject.comma_separator
21
- assert_equal :black_parenth, subject.negative_numbers
21
+ assert_equal 'black_parenth', subject.negative_numbers
22
22
  end
23
23
 
24
24
  should "error for invalid format types" do
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osheet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15424049
4
+ hash: 15424051
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
10
  - rc
11
- - 2
12
- version: 1.0.0.rc.2
11
+ - 3
12
+ version: 1.0.0.rc.3
13
13
  platform: ruby
14
14
  authors:
15
15
  - Kelly Redding
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-03-20 00:00:00 Z
20
+ date: 2012-04-18 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  type: :development