konjac 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ namespace :spec do
20
20
  end
21
21
 
22
22
  desc "Run all specs"
23
- task :all => [:excel, :power_point, :word]
23
+ task :all => ["spec", :excel, :power_point, :word]
24
24
  end
25
25
 
26
26
  desc "Run specs"
@@ -4,24 +4,52 @@ module Konjac
4
4
  # This is a basic class that contains all the methods that are universal
5
5
  # across OSes, file formats, applications, etc.
6
6
  class Generic
7
+ autoload :Item, "konjac/office/item"
8
+
7
9
  attr_reader :document, :index, :current
8
10
 
9
11
  def initialize(location = nil)
10
12
  @document = open(File.expand_path(location)) unless location.nil?
11
13
  @document = active_document
14
+ @item_opts = {
15
+ :application => @application,
16
+ :document => @document,
17
+ :delimiter => "\r"
18
+ }
19
+ @shape_opts = {
20
+ :application => @application,
21
+ :document => @document,
22
+ :delimiter => "\v"
23
+ }
12
24
  @index = 0
13
25
  @current = nil
14
26
  end
15
27
 
16
- # This only does the bare minimum, extracting arguments from
17
- # <tt>*args</tt>, so that subclass methods have their parameters parsed
28
+ def [](*args)
29
+ opts = parse_args(*args)
30
+ return shape_at(opts) if opts[:type] == :shape
31
+
32
+ Item.new @item_opts.merge(opts)
33
+ end
34
+ alias :item_at :[]
35
+
36
+ def []=(*args)
37
+ write args.pop, *args
38
+ end
39
+
40
+ def shape_at(*args)
41
+ last_item = args.last
42
+ last_item = { :type => :shape }.merge(last_item) if last_item.is_a?(Hash)
43
+ opts = parse_args(*args)
44
+ Item.new @shape_opts.merge(opts)
45
+ end
46
+
18
47
  def write(text, *args)
19
- parse_args *args
48
+ item_at(*args).write text
20
49
  end
21
50
 
22
51
  def read(*args)
23
- opts = parse_args(*args)
24
- clean find(opts), (opts.nil? ? nil : opts[:type])
52
+ item_at(*args).read
25
53
  end
26
54
 
27
55
  def tags
@@ -35,22 +63,12 @@ module Konjac
35
63
  def import
36
64
  tags.each do |tag|
37
65
  if tag.changed? && !tag.blank?
38
- write tag.added.join(delimiter(tag.type)), *tag.indices,
39
- :type => tag.type
40
- end
41
- end
42
- end
43
-
44
- # Provides the delimiters used for Word documents
45
- def delimiter(type)
46
- if type.nil?
47
- "\r"
48
- else
49
- case type
50
- when :shape
51
- "\v"
52
- else
53
- "\r"
66
+ if tag.type == :shape
67
+ added = tag.added.join(@shape_opts[:delimiter])
68
+ else
69
+ added = tag.added.join(@item_opts[:delimiter])
70
+ end
71
+ write added, *tag.indices, :type => tag.type
54
72
  end
55
73
  end
56
74
  end
@@ -63,14 +81,18 @@ module Konjac
63
81
  # Extract final argument if it's a hash
64
82
  parsed = args.last.is_a?(Hash) ? args.pop : {}
65
83
 
66
- # Create hash using @parse_order as keys and args as values, then merge
67
- # that with any pre-parsed hashes. Arguments specified via the hash have
68
- # priority
69
- parsed = Hash[@parse_order.zip(args)].merge(parsed)
84
+ if parsed[:type] == :shape
85
+ # Create hash using @parse_order as keys and args as values, then merge
86
+ # that with any pre-parsed hashes. Arguments specified via the hash have
87
+ # priority
88
+ parsed = Hash[@shape_opts[:ref_path].zip(args)].merge(parsed)
89
+ else
90
+ parsed = Hash[@item_opts[:ref_path].zip(args)].merge(parsed)
91
+ end
70
92
  end
71
93
 
72
- def clean(text, type = nil)
73
- text.gsub(@strippable, "").split delimiter(type)
94
+ def clean(text, opts)
95
+
74
96
  end
75
97
  end
76
98
  end
@@ -0,0 +1,49 @@
1
+ # coding: utf-8
2
+ module Konjac
3
+ module Office
4
+ class Generic
5
+ class Item
6
+ def initialize(opts = {})
7
+ @opts = opts
8
+
9
+ item = @opts[:document]
10
+ @opts[:ref_path].each do |node|
11
+ item = item.send(pluralize(node))[opts[node]]
12
+ end
13
+ @ref = item
14
+ end
15
+
16
+ def content
17
+ return @content unless @content.nil?
18
+
19
+ @content = @ref
20
+ @opts[:content_path].each do |node|
21
+ @content = @content.send(node)
22
+ end
23
+ @content
24
+ end
25
+
26
+ def read
27
+ clean content.send(@opts[:read])
28
+ end
29
+
30
+ def write(text)
31
+ content.send @opts[:write], text
32
+ end
33
+
34
+ private
35
+
36
+ # Definitely the most naive pluralization method ever, but there's no
37
+ # sense using an implementation as detailed as ActiveSupport's until a
38
+ # use case arises
39
+ def pluralize(text)
40
+ "#{text.to_s}s"
41
+ end
42
+
43
+ def clean(text)
44
+ text.gsub(@opts[:strippable], "").split(@opts[:delimiter])
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -7,8 +7,16 @@ module Konjac
7
7
  super "Microsoft Excel", path
8
8
  @strippable = //
9
9
  @delimiter = "\r"
10
- @parse_order = [:sheet, :row, :cell]
11
- find 1, 1, 1
10
+ @item_opts.merge!({
11
+ :ref_path => [:sheet, :row, :cell],
12
+ :content_path => [:formula],
13
+ :strippable => /[\r\n\a]+$/
14
+ })
15
+ @shape_opts.merge!({
16
+ :ref_path => [:sheet, :shape],
17
+ :content_path => [:text_frame, :characters, :content],
18
+ :strippable => /[\r\n\a]+$/
19
+ })
12
20
  end
13
21
 
14
22
  # Retrieves the active document and caches it
@@ -16,21 +24,6 @@ module Konjac
16
24
  @active_document ||= @application.active_workbook
17
25
  end
18
26
 
19
- def write(text, *args)
20
- opts = super(text, *args)
21
- if opts.map(&:last).all?(&:nil?)
22
- @current.formula.set text
23
- elsif opts[:type].nil? || opts[:type].empty?
24
- opts = parse_args(*args)
25
- @document.sheets[opts[:sheet]]
26
- .rows[opts[:row]]
27
- .cells[opts[:cell]].formula.set text
28
- else
29
- @document.sheets[opts[:sheet]]
30
- .shapes[opts[:row]].text_frame.characters.content.set text
31
- end
32
- end
33
-
34
27
  # Creates a dump of the spreadsheet's data in Tag form
35
28
  def data
36
29
  tags = []
@@ -58,25 +51,6 @@ module Konjac
58
51
  tags
59
52
  end
60
53
 
61
- # Finds the paragraph indicated by the provided index
62
- # TODO: Clean up the second unless statement
63
- def find(*args)
64
- unless args.empty? || args.nil?
65
- opts = parse_args(*args)
66
- if (opts[:type].nil? || opts[:type].empty?) && !opts.map(&:last).all?(&:nil?)
67
- @index = [opts[:sheet], opts[:row], opts[:cell]]
68
- @current = @document.sheets[opts[:sheet]]
69
- .rows[opts[:row]]
70
- .cells[opts[:cell]]
71
- elsif opts[:type] == :shape
72
- return @document.sheets[opts[:sheet]]
73
- .shapes[opts[:row]].text_frame.characters.content.get
74
- end
75
- end
76
-
77
- @current.formula.get
78
- end
79
-
80
54
  # Retrieves the number of cells in the document. Note that this method
81
55
  # fetches all row and column elements and can thus be very expensive for
82
56
  # large spreadsheets.
@@ -7,7 +7,12 @@ module Konjac
7
7
  super "Microsoft PowerPoint", path
8
8
  @strippable = //
9
9
  @parse_order = [:slide, :shape]
10
- find 1, 1
10
+ @item_opts.merge!({
11
+ :ref_path => [:slide, :shape],
12
+ :content_path => [:text_frame, :text_range, :content],
13
+ :strippable => //
14
+ })
15
+ @shape_opts = @item_opts
11
16
  end
12
17
 
13
18
  # Retrieves the active document and caches it
@@ -15,16 +20,6 @@ module Konjac
15
20
  @active_document ||= @application.active_presentation
16
21
  end
17
22
 
18
- def write(text, *args)
19
- if args.empty?
20
- @current.text_frame.text_range.content.set text
21
- else
22
- opts = parse_args(*args)
23
- @document.slides[opts[:slide]]
24
- .shapes[opts[:shape]].text_frame.text_range.content.set text
25
- end
26
- end
27
-
28
23
  # Creates a dump of the spreadsheet's data in Tag form
29
24
  def data
30
25
  tags = []
@@ -39,30 +34,12 @@ module Konjac
39
34
  tags
40
35
  end
41
36
 
42
- # Finds the paragraph indicated by the provided index
43
- def find(*args)
44
- unless args.empty? || args.nil?
45
- @indices = args
46
- opts = parse_args(*args)
47
- unless opts.map(&:last).all?(&:nil?)
48
- @current = @document.slides[opts[:slide]]
49
- .shapes[opts[:shape]]
50
- end
51
- end
52
-
53
- @current.text_frame.text_range.content.get
54
- end
55
-
56
37
  # Retrieves the number of cells in the document. Note that this method
57
38
  # fetches all row and column elements and can thus be very expensive for
58
39
  # large spreadsheets.
59
40
  def size
60
41
  end
61
42
  alias :length :size
62
-
63
- def delimiter(type = nil)
64
- "\r"
65
- end
66
43
  end
67
44
  end
68
45
  end
@@ -6,8 +6,16 @@ module Konjac
6
6
  module Mac
7
7
  class Shared < Generic
8
8
  def initialize(app_name, path = nil)
9
- @application = Appscript.app(app_name)
9
+ @application = Appscript.app(app_name)
10
10
  super path
11
+ @item_opts.merge!({
12
+ :read => :get,
13
+ :write => :set
14
+ })
15
+ @shape_opts.merge!({
16
+ :read => :get,
17
+ :write => :set
18
+ })
11
19
  end
12
20
 
13
21
  def open(path)
@@ -3,74 +3,83 @@ module Konjac
3
3
  module Office
4
4
  module Mac
5
5
  class Word < Shared
6
+ class WordItem < Item
7
+ def write(text)
8
+ para_start = @ref.text_object.start_of_content.get
9
+ para_end = @ref.text_object.end_of_content.get
10
+ range = @opts[:document].create_range(:start => para_start,
11
+ :end_ => para_end - 1)
12
+ range.select
13
+ @opts[:application].selection.type_text :text => text
14
+ end
15
+ end
16
+
6
17
  def initialize(path = nil)
7
18
  super "Microsoft Word", path
8
- @strippable = /[\r\n\a]+$/
9
19
  @index = 1
10
20
  @current = @document.paragraphs[@index]
11
- @parse_order = [:paragraph]
21
+ @item_opts.merge!({
22
+ :ref_path => [:paragraph],
23
+ :content_path => [:text_object, :content],
24
+ :delimiter => "\v",
25
+ :strippable => /[\r\n\a]+$/
26
+ })
27
+ @shape_opts.merge!({
28
+ :ref_path => [:shape],
29
+ :content_path => [:text_frame, :text_range, :content],
30
+ :strippable => /[\r\n\a]+$/
31
+ })
12
32
  end
13
33
 
14
- # Retrieves the active document and caches it
15
- def active_document
16
- @active_document ||= @application.active_document
17
- end
18
-
19
- def write(text, *args)
20
- opts = super(text, *args)
34
+ # This overrides the Base#[] method because we need to have a slightly
35
+ # modified version of the Item object to enable the selection of
36
+ # paragraph text before writing to it
37
+ def [](*args)
38
+ opts = parse_args(*args)
21
39
  if opts[:type].nil? || opts[:type].empty?
22
- select opts
23
- @application.selection.type_text :text => text
40
+ WordItem.new @item_opts.merge(opts)
24
41
  else
25
- @document.shapes[opts[:paragraph]].text_frame.text_range.content.set text
42
+ shape_at opts
26
43
  end
27
44
  end
45
+ alias :item_at :[]
46
+
47
+ # Retrieves the active document and caches it
48
+ def active_document
49
+ @active_document ||= @application.active_document
50
+ end
28
51
 
29
52
  # Creates a dump of the document's data in Tag form
30
53
  def data
31
- @index = 1
32
- @current = @document.paragraphs[@index]
33
-
54
+ i = 1
34
55
  tags = []
35
-
36
- # An open-ended loop is necessary because requesting a paragraphs
37
- # enumerator will retrieve all paragraphs from the document,
38
- # potentially consuming a large amount of memory and freezing Word
39
- loop do
40
- temp = Tag.new
41
- temp.indices = [@index]
42
- temp.removed = temp.added = read
43
- tags << temp unless temp.blank?
44
- break if succ.nil?
56
+ begin
57
+ loop do
58
+ temp = Tag.new
59
+ temp.indices = [i]
60
+ temp.removed = temp.added = item_at(i).read
61
+ tags << temp unless temp.blank?
62
+ i += 1
63
+ end
64
+ rescue Appscript::CommandError
45
65
  end
46
66
 
47
67
  # TODO: I should optimize this later like above, to prevent large
48
68
  # shapes from getting out of hand
49
- @document.shapes.get.each_with_index do |shape, index|
50
- temp = Tag.new
51
- temp.indices = [index + 1]
52
- temp.removed = temp.added =
53
- clean(shape.text_frame.text_range.content.get, :shape)
54
- temp.type = :shape
55
- tags << temp unless temp.blank?
56
- end
57
-
58
- tags
59
- end
60
-
61
- # Finds the paragraph indicated by the provided index
62
- def find(*args)
63
- unless args.empty? || args.nil?
64
- opts = parse_args(*args)
65
- if (opts[:type].nil? || opts[:type].empty?) && !opts[:paragraph].nil?
66
- @index = opts[:paragraph]
67
- @current = @document.paragraphs[opts[:paragraph]]
68
- elsif opts[:type] == :shape
69
- return @document.shapes[opts[:paragraph]].text_frame.text_range.content.get
69
+ i = 1
70
+ begin
71
+ loop do
72
+ temp = Tag.new
73
+ temp.indices = [i]
74
+ temp.removed = temp.added = shape_at(i).read
75
+ temp.type = :shape
76
+ tags << temp unless temp.blank?
77
+ i += 1
70
78
  end
79
+ rescue Appscript::CommandError, TypeError
71
80
  end
72
81
 
73
- @current.text_object.content.get
82
+ tags
74
83
  end
75
84
 
76
85
  # Retrieves the number of paragraphs in the document. Note that this
@@ -90,38 +99,6 @@ module Konjac
90
99
  nil
91
100
  end
92
101
  alias :next :succ
93
-
94
- # Provides the delimiters used for Word documents
95
- def delimiter(type)
96
- if type.nil?
97
- "\v"
98
- else
99
- case type
100
- when :shape
101
- "\r"
102
- else
103
- "\v"
104
- end
105
- end
106
- end
107
-
108
- # Selects the paragraph indicated by an indicated, or +nil+ to select
109
- # the current paragraph
110
- def select(*args)
111
- opts = parse_args(*args)
112
- find opts
113
- para_start = @current.text_object.start_of_content.get
114
- para_end = @current.text_object.end_of_content.get
115
- range = active_document.create_range(:start => para_start,
116
- :end_ => para_end)
117
-
118
- # Move in end of range by length of stripped content less end of table
119
- # mark
120
- strip_size = range.content.get[@strippable].gsub(/\a/, "").size
121
- range = active_document.create_range(:start => para_start,
122
- :end_ => para_end - strip_size)
123
- range.select
124
- end
125
102
  end
126
103
  end
127
104
  end
@@ -1,4 +1,4 @@
1
1
  module Konjac
2
2
  # The current version number of Konjac
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
@@ -42,7 +42,7 @@ describe "Excel", :excel do
42
42
  end
43
43
 
44
44
  it "should open the test document" do
45
- @book.read.should == ['=UPPER("Formula")']
45
+ @book.should_not be_nil
46
46
  end
47
47
 
48
48
  it "should return the same path" do
@@ -72,7 +72,6 @@ describe "Excel", :excel do
72
72
 
73
73
  it "should import all tags correctly" do
74
74
  @export_target.rewind
75
- @book.find 1, 1, 1
76
75
  index = 0
77
76
  lines = []
78
77
  File.open(@diff_path, "w") do |file|
@@ -41,7 +41,7 @@ describe "PowerPoint", :power_point do
41
41
  end
42
42
 
43
43
  it "should open the test document" do
44
- @deck.read.should == ["Title"]
44
+ @deck.should_not be_nil
45
45
  end
46
46
 
47
47
  it "should return the same path" do
@@ -70,7 +70,6 @@ describe "PowerPoint", :power_point do
70
70
 
71
71
  it "should import all tags correctly" do
72
72
  @export_target.rewind
73
- @deck.find 1, 1, 1
74
73
  index = 0
75
74
  lines = []
76
75
  File.open(@diff_path, "w") do |file|
@@ -70,7 +70,7 @@ describe "Word", :word do
70
70
  end
71
71
 
72
72
  it "should open the test document" do
73
- @doc.read.should == ["Normal paragraph"]
73
+ @doc.should_not be_nil
74
74
  end
75
75
 
76
76
  it "should return the same path" do
@@ -100,9 +100,8 @@ describe "Word", :word do
100
100
 
101
101
  it "should import all tags correctly" do
102
102
  @export_target.rewind
103
- @doc.find 1
104
- index = 0
105
103
  lines = []
104
+ index = 1
106
105
  File.open(@diff_path, "w") do |file|
107
106
  @export_target.each do |line|
108
107
  if line =~ /^\+/ && line !~ /^\+\+\+/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konjac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
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-02-12 00:00:00.000000000 Z
12
+ date: 2012-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amatch
16
- requirement: &70103350529580 !ruby/object:Gem::Requirement
16
+ requirement: &70324813508240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70103350529580
24
+ version_requirements: *70324813508240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: git
27
- requirement: &70103350528820 !ruby/object:Gem::Requirement
27
+ requirement: &70324813507600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70103350528820
35
+ version_requirements: *70324813507600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
38
- requirement: &70103350527780 !ruby/object:Gem::Requirement
38
+ requirement: &70324813506800 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70103350527780
46
+ version_requirements: *70324813506800
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n
49
- requirement: &70103350526520 !ruby/object:Gem::Requirement
49
+ requirement: &70324813505260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70103350526520
57
+ version_requirements: *70324813505260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: nokogiri
60
- requirement: &70103350525840 !ruby/object:Gem::Requirement
60
+ requirement: &70324813504560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70103350525840
68
+ version_requirements: *70324813504560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-appscript
71
- requirement: &70103350525260 !ruby/object:Gem::Requirement
71
+ requirement: &70324813503920 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70103350525260
79
+ version_requirements: *70324813503920
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: sdoc
82
- requirement: &70103350524360 !ruby/object:Gem::Requirement
82
+ requirement: &70324813503360 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70103350524360
90
+ version_requirements: *70324813503360
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: term-ansicolor
93
- requirement: &70103350522660 !ruby/object:Gem::Requirement
93
+ requirement: &70324813502040 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70103350522660
101
+ version_requirements: *70324813502040
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: trollop
104
- requirement: &70103350521760 !ruby/object:Gem::Requirement
104
+ requirement: &70324813500600 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70103350521760
112
+ version_requirements: *70324813500600
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: autotest
115
- requirement: &70103350520920 !ruby/object:Gem::Requirement
115
+ requirement: &70324813499600 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70103350520920
123
+ version_requirements: *70324813499600
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: autotest-fsevent
126
- requirement: &70103350519960 !ruby/object:Gem::Requirement
126
+ requirement: &70324813498700 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70103350519960
134
+ version_requirements: *70324813498700
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: autotest-growl
137
- requirement: &70103350519460 !ruby/object:Gem::Requirement
137
+ requirement: &70324813498080 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70103350519460
145
+ version_requirements: *70324813498080
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: bundler
148
- requirement: &70103350519040 !ruby/object:Gem::Requirement
148
+ requirement: &70324813497640 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70103350519040
156
+ version_requirements: *70324813497640
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rspec
159
- requirement: &70103350516560 !ruby/object:Gem::Requirement
159
+ requirement: &70324813497100 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *70103350516560
167
+ version_requirements: *70324813497100
168
168
  description: A Ruby command-line utility for translating files using a YAML wordlist
169
169
  email:
170
170
  - bryan.mckelvey@gmail.com
@@ -192,6 +192,7 @@ files:
192
192
  - lib/konjac/language.rb
193
193
  - lib/konjac/office.rb
194
194
  - lib/konjac/office/generic.rb
195
+ - lib/konjac/office/item.rb
195
196
  - lib/konjac/office/mac.rb
196
197
  - lib/konjac/office/mac/excel.rb
197
198
  - lib/konjac/office/mac/power_point.rb
@@ -220,7 +221,6 @@ files:
220
221
  - spec/office/bin/sample.pptx
221
222
  - spec/office/bin/sample.xlsx
222
223
  - spec/office/excel_spec.rb
223
- - spec/office/generic_spec.rb
224
224
  - spec/office/power_point_spec.rb
225
225
  - spec/office/word_spec.rb
226
226
  - spec/office_spec.rb
@@ -259,7 +259,6 @@ test_files:
259
259
  - spec/office/bin/sample.pptx
260
260
  - spec/office/bin/sample.xlsx
261
261
  - spec/office/excel_spec.rb
262
- - spec/office/generic_spec.rb
263
262
  - spec/office/power_point_spec.rb
264
263
  - spec/office/word_spec.rb
265
264
  - spec/office_spec.rb
@@ -1,72 +0,0 @@
1
- # coding: utf-8
2
- require File.dirname(__FILE__) + "/../spec_helper"
3
-
4
- describe Office::Generic do
5
- before :each do
6
- # Nuke initializer
7
- class Office::Generic
8
- def initialize
9
- @parse_order = [:paragraph]
10
- end
11
- end
12
-
13
- @generic = Office::Generic.new
14
- end
15
-
16
- describe "argument parsing" do
17
- describe "the first time" do
18
- it "should handle no arguments" do
19
- @generic.send(:parse_args).should == nil
20
- end
21
-
22
- it "should handle one hash" do
23
- @generic.send(:parse_args, :paragraph => 1).should == { :paragraph => 1 }
24
- end
25
-
26
- it "should handle one argument" do
27
- @generic.send(:parse_args, 1).should == { :paragraph => 1 }
28
- end
29
-
30
- it "should give a hash precedence over another argument" do
31
- @generic.send(:parse_args, 1, :paragraph => 2).should == { :paragraph => 2 }
32
- end
33
-
34
- describe "document types with multiple levels" do
35
- before :each do
36
- @generic.instance_variable_set :@parse_order, [:sheet, :row, :cell]
37
- end
38
-
39
- it "should handle a hash with several values" do
40
- @generic.send(:parse_args, :sheet => 1, :row => 2, :cell => 3)
41
- .should == { :sheet => 1, :row => 2, :cell => 3 }
42
- end
43
-
44
- it "should handle several arguments" do
45
- @generic.send(:parse_args, 1, 2, 3).should == { :sheet => 1, :row => 2, :cell => 3 }
46
- end
47
- end
48
- end
49
-
50
- describe "multiple times" do
51
- before :each do
52
- @result = nil
53
- @multiple = 3
54
- end
55
-
56
- it "should correctly handle no arguments" do
57
- @multiple.times do
58
- @result = @generic.send(:parse_args)
59
- @result.should == nil
60
- end
61
- end
62
-
63
- it "should correctly handle a completed hash" do
64
- @generic.instance_variable_set :@parse_order, []
65
- @multiple.times do
66
- @result = @generic.send(:parse_args, :sheet => 1, :row => 2, :cell => 3)
67
- @result.should == { :sheet => 1, :row => 2, :cell => 3 }
68
- end
69
- end
70
- end
71
- end
72
- end