sharp_office 0.0.1 → 0.1.1

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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ script: bundle exec rspec spec
7
+ before_install:
8
+ - sudo apt-get update
9
+ - sudo apt-get install imagemagick libmagickcore-dev
10
+ - sudo apt-get install -y ffmpeg libavcodec-extra-53 openoffice.org openoffice.org-writer unoconv ghostscript gsfonts ufraw graphicsmagick libgraphicsmagick1-dev libfreetype6-dev libjpeg-dev libgif-dev libtiff-dev libdjvulibre-dev libwmf-dev libmagickcore-dev libmagickwand-dev libpng-dev xpdf libexpat-dev gettext zlib1g-dev build-essential libfaac-dev libmp3lame0 libx264-dev libvpx-dev libtheora-dev libvorbis-dev gpac dcraw ufraw
11
+ - sudo apt-get clean
12
+ - wget http://www.swftools.org/swftools-0.9.1.tar.gz
13
+ - sh -c "tar xzvf swftools-0.9.1.tar.gz && cd swftools-0.9.1 && ./configure && make && sudo make install"
14
+ - wget http://pecl.php.net/get/gmagick-1.1.0RC2.tgz
15
+ - tar -xzf gmagick-1.1.0RC2.tgz
16
+ - sh -c "cd gmagick-1.1.0RC2 && phpize && ./configure --with-gmagick=/usr/local && make && sudo make install"
data/README.md CHANGED
@@ -1,15 +1,25 @@
1
- # SharpOffice
1
+ ## SharpOffice
2
2
 
3
- Convert office document to pdf and swf
3
+ [![Build Status](https://travis-ci.org/SharpV/sharp_office.png?branch=master)](https://travis-ci.org/SharpV/sharp_office)
4
4
 
5
5
  ## Requirements
6
6
 
7
7
  ### Swftools
8
8
 
9
- ### OpenOffice
9
+ sudo add-apt-repository ppa:guilhem-fr/swftools
10
+ sudo apt-get update
11
+ sudo apt-get install swftools
12
+
13
+ ### LibreOffice
14
+  
15
+ sudo add-apt-repository ppa:libreoffice/ppa
16
+ sudo apt-get update
17
+ sudo apt-get install libreoffice
10
18
 
11
19
  ### ImageMagick
12
20
 
21
+ sudo apt-get install imagemagick libmagickcore-dev
22
+
13
23
  ## Installation
14
24
 
15
25
  Add this line to your application's Gemfile:
@@ -27,11 +37,14 @@ Or install it yourself as:
27
37
  ## Usage
28
38
 
29
39
  ``` ruby
30
- require 'rubygems'
31
40
  require 'sharp_office'
41
+
32
42
  SharpOffice.process('/Users/apple/Documents/test.doc')
33
43
  => {:status=>"ok", :pdf_path=>"/Users/apple/Documents/test-doc.pdf", :swf_path=>"/Users/apple/Documents/test-doc.swf", :cover_path=>"/Users/apple/Documents/test-doc.png"}
34
44
 
45
+ SharpOffice.process('/Users/apple/Documents/test.doc', {pages: '1-20'})
46
+ => {:status=>"ok", :pdf_path=>"/Users/apple/Documents/test-doc.pdf", :swf_path=>"/Users/apple/Documents/test-doc.swf", :cover_path=>"/Users/apple/Documents/test-doc.png"}
47
+
35
48
  ```
36
49
 
37
50
  ## Contributing
@@ -8,15 +8,16 @@ module SharpOffice
8
8
  attr_reader :path, :pdf_path, :swf_path
9
9
  include Singleton
10
10
 
11
- def start(path)
11
+ def start(path, options)
12
12
  @path = File.expand_path(path)
13
13
  system_or_exit convert_to_pdf
14
14
  swfile = FlashTool::FlashObject.new(pdf_path)
15
+ swfile.pages(options[:pages])
15
16
  swfile.save(swf_path)
16
17
  system_or_exit "convert #{pdf_path} #{temp_file_path}"
17
18
 
18
19
  image = MiniMagick::Image.open(temp_file_path)
19
- image.resize "100x100"
20
+ image.resize "300x300"
20
21
  image.write cover_path
21
22
 
22
23
  File.delete(temp_file_path)
@@ -1,3 +1,3 @@
1
1
  module SharpOffice
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/sharp_office.rb CHANGED
@@ -16,9 +16,9 @@ module SharpOffice
16
16
  @logger = logger
17
17
  end
18
18
 
19
- def self.process(path)
19
+ def self.process(path, options={pages: '1-10'})
20
20
  raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
21
- Office.instance.start(path)
21
+ Office.instance.start(path, options)
22
22
  end
23
23
 
24
24
  end
data/sharp_office.gemspec CHANGED
@@ -17,7 +17,9 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ gem.add_dependency "mini_magick"
21
+ gem.add_dependency "flash_tool"
22
+
20
23
  gem.add_development_dependency "rspec", "~> 2.13.0"
21
- gem.add_development_dependency "mini_magick"
22
- gem.add_development_dependency "flash_tool"
24
+
23
25
  end
@@ -12,34 +12,28 @@ describe SharpOffice do
12
12
  end
13
13
  it "should convert doc successfully" do
14
14
  @response = SharpOffice.process(File.expand_path("spec/fixture/test.doc"))
15
- @response[:status].should == 'ok'
16
- File.exist?(@response[:pdf_path]).should be_true
17
- File.exist?(@response[:swf_path]).should be_true
18
- File.exist?(@response[:cover_path]).should be_true
15
+ @response.should be_converted_successfully
19
16
  end
20
17
 
21
18
  it "should convert ppt successfully" do
22
19
  @response = SharpOffice.process(File.expand_path("spec/fixture/test.ppt"))
23
- @response[:status].should == 'ok'
24
- File.exist?(@response[:pdf_path]).should be_true
25
- File.exist?(@response[:swf_path]).should be_true
26
- File.exist?(@response[:cover_path]).should be_true
20
+ @response.should be_converted_successfully
21
+
27
22
  end
28
23
 
29
24
  it "should convert xls successfully" do
30
25
  @response = SharpOffice.process(File.expand_path("spec/fixture/test.xls"))
31
- @response[:status].should == 'ok'
32
- File.exist?(@response[:pdf_path]).should be_true
33
- File.exist?(@response[:swf_path]).should be_true
34
- File.exist?(@response[:cover_path]).should be_true
26
+ @response.should be_converted_successfully
35
27
  end
36
28
 
37
29
  it "should convert docx successfully" do
38
30
  @response = SharpOffice.process(File.expand_path("spec/fixture/test.docx"))
39
- @response[:status].should == 'ok'
40
- File.exist?(@response[:pdf_path]).should be_true
41
- File.exist?(@response[:swf_path]).should be_true
42
- File.exist?(@response[:cover_path]).should be_true
31
+ @response.should be_converted_successfully
32
+ end
33
+
34
+ it "should convert docx with params successfully" do
35
+ @response = SharpOffice.process(File.expand_path("spec/fixture/test.docx"), {pages: '1-20'})
36
+ @response.should be_converted_successfully
43
37
  end
44
38
  end
45
39
  end
data/spec/spec_helper.rb CHANGED
@@ -8,3 +8,8 @@ RSpec.configure do |config|
8
8
  config.run_all_when_everything_filtered = true
9
9
  end
10
10
 
11
+ RSpec::Matchers.define :be_converted_successfully do
12
+ match do |conversion_response|
13
+ conversion_response[:status] == 'ok' && File.exist?(conversion_response[:pdf_path]) && File.exist?(conversion_response[:swf_path]) && File.exist?(conversion_response[:cover_path])
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sharp_office
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-09 00:00:00.000000000 Z
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rspec
15
+ name: mini_magick
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.13.0
22
- type: :development
21
+ version: '0'
22
+ type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.13.0
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: mini_magick
31
+ name: flash_tool
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- type: :development
38
+ type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
@@ -44,21 +44,21 @@ dependencies:
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: flash_tool
47
+ name: rspec
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 2.13.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 2.13.0
62
62
  description: Convert office document to pdf and swf
63
63
  email:
64
64
  - liu19850701@gmail.com
@@ -67,6 +67,8 @@ extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
69
  - .gitignore
70
+ - .rspec
71
+ - .travis.yml
70
72
  - Gemfile
71
73
  - LICENSE.txt
72
74
  - README.md
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
127
  version: '0'
126
128
  requirements: []
127
129
  rubyforge_project:
128
- rubygems_version: 1.8.24
130
+ rubygems_version: 1.8.25
129
131
  signing_key:
130
132
  specification_version: 3
131
133
  summary: Convert office document to pdf and swf