file-convert 0.0.1 → 0.1.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/README.md +2 -23
- data/lib/file_convert/configure.rb +1 -18
- data/lib/file_convert/conversion.rb +5 -5
- data/lib/file_convert/exception.rb +3 -3
- data/lib/file_convert/version.rb +2 -2
- metadata +37 -21
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# file-convert [](http://badge.fury.io/rb/file-convert) [](https://travis-ci.org/tolingo/file-convert)
|
2
|
+
[](https://codeclimate.com/repos/53f4984b6956807963019c1a/feed) [](https://codeclimate.com/repos/53f4984b6956807963019c1a/feed) [](https://gemnasium.com/tolingo/file-convert)
|
2
3
|
|
3
4
|
> Use google-api-ruby-client and Google Drive to convert files from one mime-type to another.
|
4
5
|
For available formats see [Google Drive API Export Formats](https://developers.google.com/drive/web/integrate-open#open_and_convert_google_docs_in_your_app).
|
@@ -13,8 +14,6 @@ gem 'file-convert'
|
|
13
14
|
|
14
15
|
## Config
|
15
16
|
|
16
|
-
### Via initializer
|
17
|
-
|
18
17
|
`FileConvert` exposes `.configure` which accepts a block and passes the config hash.
|
19
18
|
*Example*:
|
20
19
|
|
@@ -27,26 +26,6 @@ FileConvert.configure do |config|
|
|
27
26
|
end
|
28
27
|
```
|
29
28
|
|
30
|
-
### Via YAML
|
31
|
-
|
32
|
-
You need to add a YAML configuration file to `/config/file_convert.yml` that looks like `config/file_convert.sample.yml`.
|
33
|
-
|
34
|
-
In order to communicate with the Google API, `file_convert` requires a google developer email Address (`email`) and `pkcs12_file_path`.
|
35
|
-
|
36
|
-
Visit [Google Developers Console](console.developers.google.com) and check **Credentials**.
|
37
|
-
Here you can add a *new Client ID*. Select **Service Account** as application type.
|
38
|
-
|
39
|
-
You should now be able to download your *P12 key* and see your *developer email address*.
|
40
|
-
Place the *P12 key* somewhere accessible for your app and provide the location to the config. The sample config assumes your *P12 key* is located in `/config/file_convert_key.p12`.
|
41
|
-
|
42
|
-
Sample config as in `file_convert.samle.yml`:
|
43
|
-
```yaml
|
44
|
-
file_convert:
|
45
|
-
google_service_account:
|
46
|
-
email: '<strange-hash>@developer.gserviceaccount.com'
|
47
|
-
pkcs12_file_path: 'config/file_convert_key.p12'
|
48
|
-
```
|
49
|
-
|
50
29
|
## Examples
|
51
30
|
|
52
31
|
```ruby
|
@@ -1,28 +1,11 @@
|
|
1
1
|
module FileConvert
|
2
2
|
module Configure
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
DEFAULT_CONFIG_PATH = 'config/file_convert.yml'
|
6
|
-
|
7
|
-
def self.config_yaml_present?
|
8
|
-
::File.exist?(DEFAULT_CONFIG_PATH)
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.config_from_yaml
|
12
|
-
::File.open(DEFAULT_CONFIG_PATH) do |file|
|
13
|
-
YAML.load(file)['file_convert']
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
3
|
def self.config
|
18
4
|
@@config
|
19
5
|
end
|
20
6
|
|
21
|
-
###
|
22
|
-
# Loads config/file_convert.yml['file_convert'] into Config
|
23
|
-
# Or defaults to empty Hash if config file is not present
|
24
7
|
def self.init_config!
|
25
|
-
@@config
|
8
|
+
@@config ||= {}
|
26
9
|
end
|
27
10
|
|
28
11
|
def configure
|
@@ -51,20 +51,20 @@ module FileConvert
|
|
51
51
|
# @return [Google::APIClient::Result]
|
52
52
|
def fetch_file
|
53
53
|
@client.execute(uri: export_links[@mime_type]).tap do |result|
|
54
|
-
fail connection_error_exception unless result.status == 200
|
54
|
+
fail connection_error_exception(result) unless result.status == 200
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def data_error_exception
|
59
|
-
Exception::UploadedFileDataError.new
|
59
|
+
Exception::UploadedFileDataError.new @original_file_data
|
60
60
|
end
|
61
61
|
|
62
62
|
def missing_mime_type_exception
|
63
|
-
Exception::MissingConversionMimeType.new
|
63
|
+
Exception::MissingConversionMimeType.new @mime_type, export_links.keys
|
64
64
|
end
|
65
65
|
|
66
|
-
def connection_error_exception
|
67
|
-
Exception::DownloadConnectionError.new
|
66
|
+
def connection_error_exception(result)
|
67
|
+
Exception::DownloadConnectionError.new result
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -30,15 +30,15 @@ module FileConvert
|
|
30
30
|
end
|
31
31
|
|
32
32
|
class DownloadConnectionError < StandardError
|
33
|
-
def initialize(
|
33
|
+
def initialize(result)
|
34
34
|
super()
|
35
|
-
@
|
35
|
+
@result = result
|
36
36
|
end
|
37
37
|
|
38
38
|
def message
|
39
39
|
''"
|
40
40
|
An error occured connection to Google Drive.
|
41
|
-
|
41
|
+
Result of request was: #{@result}
|
42
42
|
"''
|
43
43
|
end
|
44
44
|
end
|
data/lib/file_convert/version.rb
CHANGED
metadata
CHANGED
@@ -1,98 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-convert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Roman Ernst
|
8
9
|
- Jan Raasch
|
10
|
+
- Christoph Hugo
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
14
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
17
|
name: google-api-client
|
16
18
|
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
17
20
|
requirements:
|
18
|
-
- -
|
21
|
+
- - ~>
|
19
22
|
- !ruby/object:Gem::Version
|
20
23
|
version: 0.7.0
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
24
28
|
requirements:
|
25
|
-
- -
|
29
|
+
- - ~>
|
26
30
|
- !ruby/object:Gem::Version
|
27
31
|
version: 0.7.0
|
28
32
|
- !ruby/object:Gem::Dependency
|
29
33
|
name: rspec
|
30
34
|
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
31
36
|
requirements:
|
32
|
-
- -
|
37
|
+
- - ~>
|
33
38
|
- !ruby/object:Gem::Version
|
34
39
|
version: 3.0.0
|
35
40
|
type: :development
|
36
41
|
prerelease: false
|
37
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
38
44
|
requirements:
|
39
|
-
- -
|
45
|
+
- - ~>
|
40
46
|
- !ruby/object:Gem::Version
|
41
47
|
version: 3.0.0
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: rubocop
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
45
52
|
requirements:
|
46
|
-
- -
|
53
|
+
- - ~>
|
47
54
|
- !ruby/object:Gem::Version
|
48
55
|
version: 0.25.0
|
49
56
|
type: :development
|
50
57
|
prerelease: false
|
51
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
52
60
|
requirements:
|
53
|
-
- -
|
61
|
+
- - ~>
|
54
62
|
- !ruby/object:Gem::Version
|
55
63
|
version: 0.25.0
|
56
64
|
- !ruby/object:Gem::Dependency
|
57
65
|
name: rake
|
58
66
|
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
59
68
|
requirements:
|
60
|
-
- -
|
69
|
+
- - ~>
|
61
70
|
- !ruby/object:Gem::Version
|
62
71
|
version: 10.3.2
|
63
72
|
type: :development
|
64
73
|
prerelease: false
|
65
74
|
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
66
76
|
requirements:
|
67
|
-
- -
|
77
|
+
- - ~>
|
68
78
|
- !ruby/object:Gem::Version
|
69
79
|
version: 10.3.2
|
70
80
|
- !ruby/object:Gem::Dependency
|
71
81
|
name: pry
|
72
82
|
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
73
84
|
requirements:
|
74
|
-
- -
|
85
|
+
- - ~>
|
75
86
|
- !ruby/object:Gem::Version
|
76
87
|
version: 0.10.1
|
77
88
|
type: :development
|
78
89
|
prerelease: false
|
79
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
80
92
|
requirements:
|
81
|
-
- -
|
93
|
+
- - ~>
|
82
94
|
- !ruby/object:Gem::Version
|
83
95
|
version: 0.10.1
|
84
96
|
- !ruby/object:Gem::Dependency
|
85
97
|
name: codeclimate-test-reporter
|
86
98
|
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
87
100
|
requirements:
|
88
|
-
- -
|
101
|
+
- - ~>
|
89
102
|
- !ruby/object:Gem::Version
|
90
103
|
version: 0.4.0
|
91
104
|
type: :development
|
92
105
|
prerelease: false
|
93
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
94
108
|
requirements:
|
95
|
-
- -
|
109
|
+
- - ~>
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: 0.4.0
|
98
112
|
description: Uses google-api-ruby-client and Google Drive to convert files from one
|
@@ -100,13 +114,13 @@ description: Uses google-api-ruby-client and Google Drive to convert files from
|
|
100
114
|
email:
|
101
115
|
- rernst@farbenmeer.net
|
102
116
|
- jan@janraasch.com
|
117
|
+
- christoph.hugo@gmail.com
|
103
118
|
executables: []
|
104
119
|
extensions: []
|
105
120
|
extra_rdoc_files: []
|
106
121
|
files:
|
107
|
-
- LICENSE
|
108
122
|
- README.md
|
109
|
-
-
|
123
|
+
- LICENSE
|
110
124
|
- lib/file_convert/client.rb
|
111
125
|
- lib/file_convert/configure.rb
|
112
126
|
- lib/file_convert/conversion.rb
|
@@ -114,28 +128,30 @@ files:
|
|
114
128
|
- lib/file_convert/file.rb
|
115
129
|
- lib/file_convert/upload.rb
|
116
130
|
- lib/file_convert/version.rb
|
131
|
+
- lib/file_convert.rb
|
117
132
|
homepage: https://github.com/tolingo/file-convert
|
118
133
|
licenses:
|
119
134
|
- MIT
|
120
|
-
metadata: {}
|
121
135
|
post_install_message:
|
122
136
|
rdoc_options: []
|
123
137
|
require_paths:
|
124
138
|
- lib
|
125
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
126
141
|
requirements:
|
127
|
-
- -
|
142
|
+
- - ! '>='
|
128
143
|
- !ruby/object:Gem::Version
|
129
144
|
version: 1.9.2
|
130
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
131
147
|
requirements:
|
132
|
-
- -
|
148
|
+
- - ! '>='
|
133
149
|
- !ruby/object:Gem::Version
|
134
150
|
version: '0'
|
135
151
|
requirements: []
|
136
152
|
rubyforge_project:
|
137
|
-
rubygems_version:
|
153
|
+
rubygems_version: 1.8.23
|
138
154
|
signing_key:
|
139
|
-
specification_version:
|
155
|
+
specification_version: 3
|
140
156
|
summary: Instrumentalize Google Drive to convert files
|
141
157
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4ab5545b631ce1b728c55f51238e30c3f55e3459
|
4
|
-
data.tar.gz: 6c0170fd117a7030326857e34124102dbe57fe37
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 94c4e4c7dfec2285946452d565195756dfd761e9ffd3d448d5bf098ac30c667e0bcf17dddf059620f7865687d9a10aa4f44cdc996b508105d7740023feeb20e9
|
7
|
-
data.tar.gz: 33172e266792bd45830551e68d0a6641a350363189b91697d298d9acb48ea37b928beaace5c37a98e33602cb39bfff7e9c00b25e5f920c9fb43b45e8a9270014
|