sharp_office 0.1.1 → 1.0.0

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/.travis.yml CHANGED
@@ -11,6 +11,4 @@ before_install:
11
11
  - sudo apt-get clean
12
12
  - wget http://www.swftools.org/swftools-0.9.1.tar.gz
13
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"
14
+
data/README.md CHANGED
@@ -6,19 +6,32 @@
6
6
 
7
7
  ### Swftools
8
8
 
9
- sudo add-apt-repository ppa:guilhem-fr/swftools
10
- sudo apt-get update
11
- sudo apt-get install swftools
9
+ ```
10
+ sudo add-apt-repository ppa:guilhem-fr/swftools
11
+
12
+ sudo apt-get update
13
+
14
+ sudo apt-get install swftools
15
+ ```
16
+
17
+ on download http://218.108.192.202/1Q2W3E4R5T6Y7U8I9O0P1Z2X3C4V5B/www.swftools.org/swftools-2013-04-09-1007.tar.gz and make it yourself.
12
18
 
13
19
  ### LibreOffice
14
-  
15
- sudo add-apt-repository ppa:libreoffice/ppa
16
- sudo apt-get update
17
- sudo apt-get install libreoffice
20
+
21
+ ``` 
22
+ sudo add-apt-repository ppa:libreoffice/ppa
23
+
24
+ sudo apt-get update
25
+
26
+ sudo apt-get install libreoffice
27
+
28
+ ```
18
29
 
19
30
  ### ImageMagick
20
31
 
21
- sudo apt-get install imagemagick libmagickcore-dev
32
+ ```
33
+ sudo apt-get install imagemagick libmagickcore-dev
34
+ ```
22
35
 
23
36
  ## Installation
24
37
 
@@ -1,5 +1,4 @@
1
1
  require 'singleton'
2
- require 'flash_tool'
3
2
  require 'mini_magick'
4
3
 
5
4
  module SharpOffice
@@ -10,27 +9,19 @@ module SharpOffice
10
9
 
11
10
  def start(path, options)
12
11
  @path = File.expand_path(path)
13
- system_or_exit convert_to_pdf
14
- swfile = FlashTool::FlashObject.new(pdf_path)
15
- swfile.pages(options[:pages])
16
- swfile.save(swf_path)
17
- system_or_exit "convert #{pdf_path} #{temp_file_path}"
18
12
 
19
- image = MiniMagick::Image.open(temp_file_path)
13
+ system_or_exit convert_to_pdf
14
+ system_or_exit convert_to_swf
15
+ system_or_exit convert_to_cover
16
+ image = MiniMagick::Image.open(cover_path)
20
17
  image.resize "300x300"
21
18
  image.write cover_path
22
19
 
23
- File.delete(temp_file_path)
20
+ #File.delete(tmp_file_path)
24
21
 
25
22
  {status: 'ok', pdf_path: pdf_path, swf_path: swf_path, cover_path: cover_path}
26
23
  end
27
24
 
28
- def system_or_exit(cmd, stdout = nil)
29
- puts "Executing #{cmd}"
30
- cmd += " >#{stdout}" if stdout
31
- system(cmd) or raise "******** Run failed ********"
32
- end
33
-
34
25
  protected
35
26
 
36
27
  def convert_to_pdf
@@ -39,13 +30,17 @@ module SharpOffice
39
30
  "java -Djava.library.path=#{sigar} -jar #{jar} #{@path} #{pdf_path}"
40
31
  end
41
32
 
33
+ def convert_to_swf
34
+ "pdf2swf #{pdf_path} #{swf_path}"
35
+ end
36
+
37
+ def convert_to_cover
38
+ "convert #{pdf_path} #{cover_path}"
39
+ end
40
+
42
41
  def pdf_path
43
42
  @path.gsub('.', '-').to_s+'.pdf'
44
43
  end
45
-
46
- def temp_file_path
47
- @path.gsub('.', '-').to_s+'.temp'
48
- end
49
44
 
50
45
  def cover_path
51
46
  @path.gsub('.', '-').to_s+'.png'
@@ -55,10 +50,13 @@ module SharpOffice
55
50
  @path.gsub('.', '-').to_s+'.swf'
56
51
  end
57
52
 
58
- def convert_to_swf
59
- output[/test/] # Running a regexp on the string throws error if it's not UTF-8
60
- rescue ArgumentError
61
- output.force_encoding("ISO-8859-1")
53
+ private
54
+
55
+ def system_or_exit(cmd, stdout = nil)
56
+ puts "Executing #{cmd}"
57
+ cmd += " >#{stdout}" if stdout
58
+ system(cmd) or raise "******** Run failed ********"
62
59
  end
60
+
63
61
  end
64
62
  end
@@ -1,3 +1,3 @@
1
1
  module SharpOffice
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
data/lib/sharp_office.rb CHANGED
@@ -16,7 +16,7 @@ module SharpOffice
16
16
  @logger = logger
17
17
  end
18
18
 
19
- def self.process(path, options={pages: '1-10'})
19
+ def self.process(path, options={pages: '1-20'})
20
20
  raise Errno::ENOENT, "the file '#{path}' does not exist" unless File.exists?(path)
21
21
  Office.instance.start(path, options)
22
22
  end
data/sharp_office.gemspec CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency "mini_magick"
21
- gem.add_dependency "flash_tool"
22
-
23
21
  gem.add_development_dependency "rspec", "~> 2.13.0"
24
22
 
25
23
  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.1.1
4
+ version: 1.0.0
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: 2013-05-10 00:00:00.000000000 Z
12
+ date: 2013-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70098930044460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,31 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: flash_tool
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
24
+ version_requirements: *70098930044460
46
25
  - !ruby/object:Gem::Dependency
47
26
  name: rspec
48
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &70098930076800 !ruby/object:Gem::Requirement
49
28
  none: false
50
29
  requirements:
51
30
  - - ~>
@@ -53,12 +32,7 @@ dependencies:
53
32
  version: 2.13.0
54
33
  type: :development
55
34
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 2.13.0
35
+ version_requirements: *70098930076800
62
36
  description: Convert office document to pdf and swf
63
37
  email:
64
38
  - liu19850701@gmail.com
@@ -127,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
101
  version: '0'
128
102
  requirements: []
129
103
  rubyforge_project:
130
- rubygems_version: 1.8.25
104
+ rubygems_version: 1.8.15
131
105
  signing_key:
132
106
  specification_version: 3
133
107
  summary: Convert office document to pdf and swf