asposeslides 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c5ebc76c48fe2a0befcf287f4ab48bb14f0549
4
- data.tar.gz: 8c0ab797876521ecb9aa9e7304877d7cb686fa8f
3
+ metadata.gz: f52e417702c4ccaf1bd7c833eebafbccabab1201
4
+ data.tar.gz: e91f142a87d68227ba3900fae3f8d688cc2f00f6
5
5
  SHA512:
6
- metadata.gz: 2972ce2a28cd57bc15a94b0a7e71859b4c9310ee6b6a520ac460dfa448c9c54dc80a4cfdbcd0e00a39889763aab7f8fc1ed9215db29e297779ac532d0377e18b
7
- data.tar.gz: b89d42ebecafda50ac916771b3185f26a1d0f59a74a5259022277993cba5fbce8009181f9bbaba3dff59f3a965cd6586e5f4b37660d3866a0de0a97a48976851
6
+ metadata.gz: 7c771922708de44ada8f668b3563e7dde9b5bcf378dbb10ead7370a08418e017e546ded0283f4099c38a6be7725fdf6f5b74968a4604387cd814155fcf8e50bc
7
+ data.tar.gz: bd987278fea6049a67ed0f9fd06f117ac00df2b313ad72bc95d5d734c408cf7626a3c35a717676f680d2e7f6104e7d9d74c784558b5da91a7b7c2318bd84b34c
data/README.md CHANGED
@@ -24,8 +24,10 @@ Or install it yourself as:
24
24
  ```yaml
25
25
  development:
26
26
  jar_dir: /path/to/your/asposeslides/jars/directory
27
+ license_path: /path/to/your/asposeslides/license/path
27
28
  test:
28
29
  jar_dir: /path/to/your/asposeslides/jars/directory
30
+ license_path: /path/to/your/asposeslides/license/path
29
31
  ```
30
32
  * Next you need to initialize the aspose library. Aspose is a paid library and therefor you need to buy the appropriate license and provide the path to the licensed java library to initialize the gem.
31
33
  * Create a file called aspose.rb under the initializer app/config/initializers folder. Put the following lines in the file
data/config/aspose.yml CHANGED
@@ -1 +1,2 @@
1
1
  jar_dir: ../asposeslides/jars
2
+ license_path: /path/to/your/asposeslides/license/path
@@ -1,3 +1,3 @@
1
1
  module Asposeslides
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/asposeslides.rb CHANGED
@@ -10,21 +10,52 @@ module Asposeslides
10
10
  end
11
11
 
12
12
  def initialize_aspose
13
- dir = Asposeslides.aspose_slides_config ? Asposeslides.aspose_slides_config['jar_dir'] : nil
13
+ aspose_jars_dir = Asposeslides.aspose_slides_config ? Asposeslides.aspose_slides_config['jar_dir'] : nil
14
+ aspose_license_path = Asposeslides.aspose_slides_config ? Asposeslides.aspose_slides_config['license_path'] : nil
14
15
 
15
- if dir && File.exist?(dir)
16
- jardir = File.join(dir, '**', '*.jar')
16
+ load_aspose_jars(aspose_jars_dir)
17
+ load_aspose_license(aspose_license_path)
18
+ end
19
+
20
+ def load_aspose_license(aspose_license_path)
21
+ if aspose_license_path && File.exist?(aspose_license_path)
22
+ set_license(File.join(aspose_license_path))
17
23
  else
18
24
  logger = Logger.new(STDOUT)
19
25
  logger.level = Logger::WARN
20
- logger.warn('Using the non licensed aspose slides jar. Please specify path to your licensed aspose slides jar directory in config/aspose.yml file!')
21
- jardir = File.join(File.dirname(File.dirname(__FILE__)),'jars', '**', '*.jar')
26
+ logger.warn('Using the non licensed aspose slides jar. Please specify path to your aspose license directory in config/aspose.yml file!')
27
+ end
28
+ end
29
+
30
+ def load_aspose_jars(aspose_jars_dir)
31
+ if aspose_jars_dir && File.exist?(aspose_jars_dir)
32
+ jardir = File.join(aspose_jars_dir, '**', '*.jar')
33
+ else
34
+ jardir = File.join(File.dirname(File.dirname(__FILE__)), 'jars', '**', '*.jar')
22
35
  end
23
36
  Rjb::load(classpath = Dir.glob(jardir).join(':'), jvmargs=['-Djava.awt.headless=true'])
24
37
  end
25
38
 
39
+ def input_file(file)
40
+ Rjb::import('java.io.FileInputStream').new(file)
41
+ end
42
+
43
+ def set_license(aspose_license_file)
44
+ begin
45
+ fstream = input_file(aspose_license_file)
46
+ license = Rjb::import('com.aspose.slides.License').new()
47
+ license.setLicense(fstream)
48
+ rescue Exception => ex
49
+ logger = Logger.new(STDOUT)
50
+ logger.level = Logger::ERROR
51
+ logger.error("Could not load the license file : #{ex}")
52
+ fstream.close() if fstream
53
+ end
54
+
55
+ end
26
56
 
27
57
  def self.configure_aspose_slides config
28
58
  Asposeslides.aspose_slides_config = config
29
59
  end
60
+
30
61
  end
@@ -9,4 +9,9 @@ describe 'Asposeslides Initialization' do
9
9
  expect(Rjb::import('com.aspose.slides.Presentation').new).not_to be_nil
10
10
  end
11
11
 
12
+ it 'should create a input file object' do
13
+ file = File.join(File.dirname(File.dirname(__FILE__)), 'spec', 'data', 'image001.jpg')
14
+ expect(Rjb::import('java.io.FileInputStream').new(file).java_methods).to eq(input_file(file).java_methods)
15
+ end
16
+
12
17
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asposeslides
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sanjeev Mishra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - lib/asposeslides/version.rb
87
87
  - spec/asposeslides_spec.rb
88
88
  - spec/data/dest_template.pptx
89
+ - spec/data/image001.jpg
89
90
  - spec/data/src_template1.pptx
90
91
  - spec/data/src_template2.pptx
91
92
  - spec/powerpoint_spec.rb
@@ -117,6 +118,7 @@ summary: A Ruby gem to work with aspose libraries
117
118
  test_files:
118
119
  - spec/asposeslides_spec.rb
119
120
  - spec/data/dest_template.pptx
121
+ - spec/data/image001.jpg
120
122
  - spec/data/src_template1.pptx
121
123
  - spec/data/src_template2.pptx
122
124
  - spec/powerpoint_spec.rb