inline-css-html-converter 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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Gemfile +6 -0
- data/README.md +28 -0
- data/Rakefile +6 -0
- data/inline-css-html-converter.gemspec +25 -0
- data/lib/inline-css-html-converter.rb +6 -0
- data/lib/inline-css-html-converter/errors.rb +4 -0
- data/lib/inline-css-html-converter/version.rb +3 -0
- data/lib/inline-css-html-converter/worker.rb +41 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/worker_spec.rb +39 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7c3115819cbb4af2659534f5fc5af3a79928c07
|
4
|
+
data.tar.gz: 83e44c6d068662773eff8f2852d30fee9215d71d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0490da0934ecc545e99090f5c6fc43d42ae76c06b88961f173f5723c4bbf4bdb89dae32317c4d247f54adfd878c6f2fb8c5f63b9297926a79230f18fe83abf86
|
7
|
+
data.tar.gz: 0492414be6d086528e5c1bcc4f1936a6ea9d0ec9500d1433467e4681ebe8d45b06e154d8b21e4b5161d057f377e00cfdfb881c83964c8252c00ab4588e96479b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
Inline CSS HTML Converter
|
2
|
+
==
|
3
|
+
[](https://travis-ci.org/Garllon/inline-css-html-converter)
|
4
|
+
[](https://codeclimate.com/github/Garllon/inline-css-html-converter)
|
5
|
+
|
6
|
+
I use the MailChimpAPI
|
7
|
+
|
8
|
+
At the moment i use the APi Version 2.0.
|
9
|
+
[MailChimp 2.0](https://apidocs.mailchimp.com/api/2.0/helper/inline-css.php)
|
10
|
+
|
11
|
+
How it works
|
12
|
+
===
|
13
|
+
|
14
|
+
```
|
15
|
+
gem 'inline-css-html-converter',
|
16
|
+
git: 'https://github.com/Garllon/inline-css-html-converter.git'
|
17
|
+
|
18
|
+
require 'inline-css-html-converter'
|
19
|
+
```
|
20
|
+
|
21
|
+
|
22
|
+
```
|
23
|
+
InlineCssHtmlConverter::Worker.new(your_apikey, your_html).perform
|
24
|
+
```
|
25
|
+
|
26
|
+
In Progress
|
27
|
+
===
|
28
|
+
At the moment i work on a version, which works with MailChimp 3.0.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "inline-css-html-converter"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.author = 'Bennet Palluthe'
|
9
|
+
s.email = 'palluthe.bennet@gmail.com'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.add_dependency 'httparty'
|
17
|
+
s.add_development_dependency "rspec"
|
18
|
+
s.add_development_dependency "codeclimate-test-reporter"
|
19
|
+
s.add_development_dependency "simplecov"
|
20
|
+
|
21
|
+
s.rubygems_version = '1.8.24'
|
22
|
+
s.summary = 'convert css style to inline html'
|
23
|
+
s.description = "convert css style to inline html"
|
24
|
+
s.homepage = 'https://github.com/Garllon/inline-css-html-converter/blob/master/README.md'
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module InlineCssHtmlConverter
|
4
|
+
class Worker
|
5
|
+
API_VERSION = '2.0'
|
6
|
+
|
7
|
+
def initialize(apikey, html)
|
8
|
+
raise NoApiKeyGivenError if apikey.nil?
|
9
|
+
|
10
|
+
@apikey = apikey
|
11
|
+
@html = html
|
12
|
+
|
13
|
+
if apikey.split('-').length == 2
|
14
|
+
@host = "https://#{apikey.split('-')[1]}.api.mailchimp.com/#{API_VERSION}"
|
15
|
+
else
|
16
|
+
raise InvalidApiKeyError, 'Your MailChimp API key must contain a suffix subdomain (e.g. "-us8").'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def perform
|
21
|
+
result = HTTParty.post(call_url,
|
22
|
+
query: parameters,
|
23
|
+
verify: false,
|
24
|
+
headers: { 'Content-Type' => 'application/json' })
|
25
|
+
result['html']
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def call_url
|
31
|
+
@host + '/helper/inline-css.json'
|
32
|
+
end
|
33
|
+
|
34
|
+
def parameters
|
35
|
+
{
|
36
|
+
apikey: @apikey,
|
37
|
+
html: @html
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/worker_spec.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module InlineCssHtmlConverter
|
4
|
+
describe Worker do
|
5
|
+
let(:apikey) { '1-us1' }
|
6
|
+
let(:html) { '<html></html>' }
|
7
|
+
|
8
|
+
context '#initialize' do
|
9
|
+
it 'set apikey' do
|
10
|
+
worker = described_class.new(apikey, html)
|
11
|
+
expect(worker.instance_variable_get("@apikey")).to eq apikey
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'set html' do
|
15
|
+
worker = described_class.new(apikey, html)
|
16
|
+
expect(worker.instance_variable_get("@html")).to eq html
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'raise an error if no apikey is given' do
|
20
|
+
expect { described_class.new(nil, html) }
|
21
|
+
.to raise_error(NoApiKeyGivenError)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raise an error if the api key is invalid' do
|
25
|
+
expect { described_class.new('1', html) }
|
26
|
+
.to raise_error(InvalidApiKeyError)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context '#perform' do
|
31
|
+
it 'post a request' do
|
32
|
+
expect(HTTParty).to receive(:post).and_return({html: ''})
|
33
|
+
|
34
|
+
worker = described_class.new(apikey, html)
|
35
|
+
worker.perform
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inline-css-html-converter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bennet Palluthe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: codeclimate-test-reporter
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: convert css style to inline html
|
70
|
+
email: palluthe.bennet@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- ".rspec"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- inline-css-html-converter.gemspec
|
82
|
+
- lib/inline-css-html-converter.rb
|
83
|
+
- lib/inline-css-html-converter/errors.rb
|
84
|
+
- lib/inline-css-html-converter/version.rb
|
85
|
+
- lib/inline-css-html-converter/worker.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/worker_spec.rb
|
88
|
+
homepage: https://github.com/Garllon/inline-css-html-converter/blob/master/README.md
|
89
|
+
licenses: []
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.2'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: convert css style to inline html
|
111
|
+
test_files:
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- spec/worker_spec.rb
|