crabgrass_media 0.0.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.
@@ -0,0 +1,106 @@
1
+ require 'test_helper'
2
+ require 'media'
3
+ require_relative 'sleepy_transmogrifier'
4
+
5
+ class TransmogrifierTest < Minitest::Test
6
+
7
+ def test_run_sleepy_transmog
8
+ progress_strings = [
9
+ 'starting up.',
10
+ 'getting ready to do some work.',
11
+ 'working hard.',
12
+ 'winding down.',
13
+ 'that was tough.',
14
+ 'all done now.'
15
+ ]
16
+ transmog = SleepyTransmogrifier.new
17
+ i = 0
18
+ status = transmog.run do |progress|
19
+ assert_equal progress_strings[i], progress
20
+ putc ':'; STDOUT.flush
21
+ i+=1
22
+ end
23
+ assert_equal :success, status
24
+ end
25
+
26
+ def test_transmog_not_found
27
+ input = file('lyra.png')
28
+ transmog = Media.transmogrifier input_file: input,
29
+ output_type: 'image/xcf'
30
+ assert_nil transmog
31
+ end
32
+
33
+ def test_graphicsmagick_transmog
34
+ input = file('lyra.png')
35
+ transmog = Media.transmogrifier(input_file: input, output_type: 'image/jpg', size: '100x100!')
36
+ assert transmog
37
+ status = transmog.run
38
+ assert_equal :success, status
39
+ assert File.exist?(transmog.output_file.to_s)
40
+
41
+ assert file_info_matches?(transmog.output_file, /JPEG/),
42
+ "output should be a jpg: #{file_info(transmog.output_file)}"
43
+ assert_equal ['100','100'], Media.dimensions(transmog.output_file),
44
+ "output should be resized: #{file_info(transmog.output_file)}"
45
+ end
46
+
47
+ def test_with_output_file
48
+ input = file('lyra.png')
49
+ Media::TempFile.open(nil,'image/jpg') do |dest_file|
50
+ filename = dest_file.to_s
51
+ transmog = Media.transmogrifier(input_file: input, output_file: dest_file)
52
+ assert transmog, 'should find transmog'
53
+ status = transmog.run
54
+ assert_equal :success, status
55
+ assert File.exist?(dest_file.to_s)
56
+ assert file_info_matches?(dest_file, /JPEG/), "output should be a jpg: #{file_info(transmog.output_file)}"
57
+ end
58
+ end
59
+
60
+ def test_libreoffice_transmog
61
+ input = file('msword.doc')
62
+ transmog = Media.transmogrifier(input_file: input, output_type: 'application/pdf')
63
+ assert transmog
64
+ status = transmog.run
65
+ assert_equal :success, status
66
+ assert File.exist?(transmog.output_file.to_s)
67
+
68
+ assert file_info_matches?(transmog.output_file, /PDF/), "output should be a pdf: #{file_info(transmog.output_file)}"
69
+ end
70
+
71
+ def test_doc_to_jpg_twostep_transmog
72
+ input = file('msword.doc')
73
+ transmog = Media.transmogrifier(input_file: input, output_type: 'application/pdf')
74
+ transmog.run
75
+
76
+ transmog = Media.transmogrifier(input_file: transmog.output_file, output_type: 'image/jpg')
77
+ status = transmog.run
78
+ assert_equal :success, status
79
+ assert File.exist?(transmog.output_file.to_s)
80
+
81
+ assert file_info_matches?(transmog.output_file, /JPEG/), "output should be a jpg: #{file_info(transmog.output_file)}"
82
+ end
83
+
84
+ def test_libremagick_transmog
85
+ input = file('msword.doc')
86
+ transmog = Media.transmogrifier(input_file: input, output_type: 'image/jpg')
87
+ assert transmog
88
+ status = transmog.run
89
+ assert_equal :success, status
90
+ assert File.exist?(transmog.output_file.to_s)
91
+
92
+ assert file_info_matches?(transmog.output_file, /JPEG/), "output should be a jpg: #{file_info(transmog.output_file)}"
93
+ end
94
+
95
+ def test_inkscape_transmog
96
+ input = file('anarchism.svg')
97
+ transmog = Media.transmogrifier(input_file: input, output_type: 'image/jpg')
98
+ assert transmog
99
+ status = transmog.run
100
+ assert_equal :success, status
101
+ assert File.exist?(transmog.output_file.to_s)
102
+
103
+ assert file_info_matches?(transmog.output_file, /JPEG/), "output should be a pdf: #{file_info(transmog.output_file)}"
104
+ end
105
+
106
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crabgrass_media
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Azul
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.7'
55
+ description: |2
56
+ Crabgrass::Media is the Media engine of Crabgrass.
57
+
58
+ Crabgrass is a web application designed for activist groups to be better able to collaborate online. Mostly, it is a glorified wiki with fine-grain control over access rights.
59
+
60
+ Crabgrass::Media is a rails engine to do media transformations.
61
+ email:
62
+ - azul@riseup.net
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - README.md
68
+ - Rakefile
69
+ - config/initializers/paths.rb
70
+ - lib/media.rb
71
+ - lib/media/mime_type.rb
72
+ - lib/media/temp_file.rb
73
+ - lib/media/transmogrifier.rb
74
+ - lib/media/transmogrifiers/graphicsmagick.rb
75
+ - lib/media/transmogrifiers/inkscape.rb
76
+ - lib/media/transmogrifiers/libremagick.rb
77
+ - lib/media/transmogrifiers/libreoffice.rb
78
+ - lib/media/version.rb
79
+ - lib/tasks/media_tasks.rake
80
+ - test/dummy/db/test.sqlite3
81
+ - test/dummy/log/test.log
82
+ - test/files/anarchism.svg
83
+ - test/files/corrupt.jpg
84
+ - test/files/lyra.png
85
+ - test/files/msword.doc
86
+ - test/sleepy_transmogrifier.rb
87
+ - test/support/file.rb
88
+ - test/tempfile_test.rb
89
+ - test/test_helper.rb
90
+ - test/transmogrifier_test.rb
91
+ homepage: https://github.com/riseuplabs/crabgrass-media
92
+ licenses:
93
+ - AGPL 3
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Media processing for the Crabgrass social wiki
115
+ test_files:
116
+ - test/sleepy_transmogrifier.rb
117
+ - test/tempfile_test.rb
118
+ - test/transmogrifier_test.rb
119
+ - test/files/anarchism.svg
120
+ - test/files/msword.doc
121
+ - test/files/corrupt.jpg
122
+ - test/files/lyra.png
123
+ - test/dummy/db/test.sqlite3
124
+ - test/dummy/log/test.log
125
+ - test/test_helper.rb
126
+ - test/support/file.rb