htmlcsstoimage-api 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: '048ac5012c53eb720767833ea51fa8f41884cc830cbb2b16a6efe61ddc61273c'
4
- data.tar.gz: 2c32f384c2ec979a06df6d419e1496413600f918e75cccc41017d4293a80d4ca
3
+ metadata.gz: d239b9b34098dda7392ae191f5aca7733600f7e97a06c72008951852c00e20fe
4
+ data.tar.gz: 446cbd2635aa331d8dac616f73d97d1ea285709e4bdbd7462dcec29f428d44e7
5
5
  SHA512:
6
- metadata.gz: b6ea23f1bc285eafa767f2f2f2ca4470815c32307f25320b1265343162b1d4cf187c5f1c475472750fe50ea935d9fdc0bde408b638a190e163bebce6286f9d75
7
- data.tar.gz: 4de98fdadc6afd13d1e17a0b13098b9faa30f8a3934a7e50d4bd9017ae3d00188ede6af8c545334a2d024ed695e68195318afd4b8911975169c2b8842582a41f
6
+ metadata.gz: fed426a2bd8e9252f9c221906d4f5b508462bf7799ac85812d4b56dd4e18a2e0970b41923e2c02c1f71b1533a35b97c9c2ed07066083a6d973c3e66ee28b31eb
7
+ data.tar.gz: 4e1fa8c2c13eb5d032bd3258b6dd1bff97739938414aaa315be211460632dddaec71f411323ac5f03c8a19ab6121eb1f5c8a6dcd6460083ed35a954f8a842b02
@@ -133,7 +133,7 @@
133
133
  <dt id="VERSION-constant" class="">VERSION =
134
134
 
135
135
  </dt>
136
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.0</span><span class='tstring_end'>&quot;</span></span></pre></dd>
136
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>0.1.1</span><span class='tstring_end'>&quot;</span></span></pre></dd>
137
137
 
138
138
  </dl>
139
139
 
@@ -197,6 +197,30 @@
197
197
  <p>Creates a signed URL for generating an image from a template This URL contains the template_values in it.</p>
198
198
  </div></span>
199
199
 
200
+ </li>
201
+
202
+
203
+ <li class="public ">
204
+ <span class="summary_signature">
205
+
206
+ <a href="#create_template-instance_method" title="#create_template (instance method)">#<strong>create_template</strong>(html, params = {}) &#x21d2; HTMLCSSToImage::ApiResponse </a>
207
+
208
+
209
+
210
+ </span>
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'>
221
+ <p>Creates an image template.</p>
222
+ </div></span>
223
+
200
224
  </li>
201
225
 
202
226
 
@@ -702,6 +726,7 @@
702
726
  <pre class="lines">
703
727
 
704
728
 
729
+ 86
705
730
  87
706
731
  88
707
732
  89
@@ -716,11 +741,10 @@
716
741
  98
717
742
  99
718
743
  100
719
- 101
720
- 102</pre>
744
+ 101</pre>
721
745
  </td>
722
746
  <td>
723
- <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 87</span>
747
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 86</span>
724
748
 
725
749
  <span class='kw'>def</span> <span class='id identifier rubyid_create_image_from_template'>create_image_from_template</span><span class='lparen'>(</span><span class='id identifier rubyid_template_id'>template_id</span><span class='comma'>,</span> <span class='id identifier rubyid_template_values'>template_values</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
726
750
  <span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#SIGNED_URL_TEMPLATE-constant" title="HTMLCSSToImage::SIGNED_URL_TEMPLATE (constant)">SIGNED_URL_TEMPLATE</a></span></span><span class='period'>.</span><span class='id identifier rubyid_partial_expand'>partial_expand</span><span class='lparen'>(</span><span class='lbrace'>{</span>
@@ -741,6 +765,257 @@
741
765
  </td>
742
766
  </tr>
743
767
  </table>
768
+ </div>
769
+
770
+ <div class="method_details ">
771
+ <h3 class="signature " id="create_template-instance_method">
772
+
773
+ #<strong>create_template</strong>(html, params = {}) &#x21d2; <tt><span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">HTMLCSSToImage::ApiResponse</a></span></tt>
774
+
775
+
776
+
777
+
778
+
779
+ </h3><div class="docstring">
780
+ <div class="discussion">
781
+
782
+ <p>Creates an image template</p>
783
+
784
+
785
+ </div>
786
+ </div>
787
+ <div class="tags">
788
+ <p class="tag_title">Parameters:</p>
789
+ <ul class="param">
790
+
791
+ <li>
792
+
793
+ <span class='name'>html</span>
794
+
795
+
796
+ <span class='type'>(<tt>String</tt>)</span>
797
+
798
+
799
+
800
+ &mdash;
801
+ <div class='inline'>
802
+ <p>This is the HTML you want to render. You can send an HTML snippet (`&lt;div&gt;Your content&lt;/div&gt;`) or an entire webpage.</p>
803
+ </div>
804
+
805
+ </li>
806
+
807
+ <li>
808
+
809
+ <span class='name'>params</span>
810
+
811
+
812
+ <span class='type'>(<tt>Hash</tt>)</span>
813
+
814
+
815
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
816
+
817
+
818
+ &mdash;
819
+ <div class='inline'>
820
+ <p>a customizable set of options</p>
821
+ </div>
822
+
823
+ </li>
824
+
825
+ </ul>
826
+
827
+
828
+
829
+
830
+
831
+
832
+ <p class="tag_title">Options Hash (<tt>params</tt>):</p>
833
+ <ul class="option">
834
+
835
+ <li>
836
+ <span class="name">:name</span>
837
+ <span class="type">(<tt>String</tt>)</span>
838
+ <span class="default">
839
+
840
+ </span>
841
+
842
+ &mdash; <div class='inline'>
843
+ <p>A short name to identify your template max length 64</p>
844
+ </div>
845
+
846
+ </li>
847
+
848
+ <li>
849
+ <span class="name">:description</span>
850
+ <span class="type">(<tt>String</tt>)</span>
851
+ <span class="default">
852
+
853
+ </span>
854
+
855
+ &mdash; <div class='inline'>
856
+ <p>Description to elaborate on the use of your template max length 1024</p>
857
+ </div>
858
+
859
+ </li>
860
+
861
+ <li>
862
+ <span class="name">:css</span>
863
+ <span class="type">(<tt>String</tt>)</span>
864
+ <span class="default">
865
+
866
+ </span>
867
+
868
+ &mdash; <div class='inline'>
869
+ <p>The CSS for your image.</p>
870
+ </div>
871
+
872
+ </li>
873
+
874
+ <li>
875
+ <span class="name">:google_fonts</span>
876
+ <span class="type">(<tt>String</tt>)</span>
877
+ <span class="default">
878
+
879
+ </span>
880
+
881
+ &mdash; <div class='inline'>
882
+ <p>[Google fonts](<a href="https://docs.htmlcsstoimage.com/guides/using-google-fonts">docs.htmlcsstoimage.com/guides/using-google-fonts</a>/) to be loaded. Example: `Roboto`. Multiple fonts can be loaded like this: `Roboto|Open Sans`</p>
883
+ </div>
884
+
885
+ </li>
886
+
887
+ <li>
888
+ <span class="name">:selector</span>
889
+ <span class="type">(<tt>String</tt>)</span>
890
+ <span class="default">
891
+
892
+ </span>
893
+
894
+ &mdash; <div class='inline'>
895
+ <p>A CSS selector for an element on the webpage. We&#39;ll crop the image to this specific element. For example: `section#complete-toolkit.container-lg`</p>
896
+ </div>
897
+
898
+ </li>
899
+
900
+ <li>
901
+ <span class="name">:ms_delay</span>
902
+ <span class="type">(<tt>Integer</tt>)</span>
903
+ <span class="default">
904
+
905
+ </span>
906
+
907
+ &mdash; <div class='inline'>
908
+ <p>The number of milliseconds the API should delay before generating the image. This is useful when waiting for JavaScript. We recommend starting with `500`. Large values slow down the initial render time.</p>
909
+ </div>
910
+
911
+ </li>
912
+
913
+ <li>
914
+ <span class="name">:device_scale</span>
915
+ <span class="type">(<tt>Double</tt>)</span>
916
+ <span class="default">
917
+
918
+ </span>
919
+
920
+ &mdash; <div class='inline'>
921
+ <p>This adjusts the pixel ratio for the screenshot. Minimum: `1`, Maximum: `3`.</p>
922
+ </div>
923
+
924
+ </li>
925
+
926
+ <li>
927
+ <span class="name">:render_when_ready</span>
928
+ <span class="type">(<tt>Boolean</tt>)</span>
929
+ <span class="default">
930
+
931
+ </span>
932
+
933
+ &mdash; <div class='inline'>
934
+ <p>Set to true to control when the image is generated. Call `ScreenshotReady()` from JavaScript to generate the image. [Learn more](<a href="https://docs.htmlcsstoimage.com/guides/render-when-ready">docs.htmlcsstoimage.com/guides/render-when-ready</a>/).</p>
935
+ </div>
936
+
937
+ </li>
938
+
939
+ <li>
940
+ <span class="name">:viewport_width</span>
941
+ <span class="type">(<tt>Integer</tt>)</span>
942
+ <span class="default">
943
+
944
+ </span>
945
+
946
+ &mdash; <div class='inline'>
947
+ <p>Set the width of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
948
+ </div>
949
+
950
+ </li>
951
+
952
+ <li>
953
+ <span class="name">:viewport_height</span>
954
+ <span class="type">(<tt>Integer</tt>)</span>
955
+ <span class="default">
956
+
957
+ </span>
958
+
959
+ &mdash; <div class='inline'>
960
+ <p>Set the height of Chrome&#39;s viewport. This will disable automatic cropping. Both height and width parameters must be set if using either.</p>
961
+ </div>
962
+
963
+ </li>
964
+
965
+ </ul>
966
+
967
+
968
+ <p class="tag_title">Returns:</p>
969
+ <ul class="return">
970
+
971
+ <li>
972
+
973
+
974
+ <span class='type'>(<tt><span class='object_link'><a href="HTMLCSSToImage/ApiResponse.html" title="HTMLCSSToImage::ApiResponse (class)">HTMLCSSToImage::ApiResponse</a></span></tt>)</span>
975
+
976
+
977
+
978
+ &mdash;
979
+ <div class='inline'>
980
+ <p>image URL available at `.url`.</p>
981
+ </div>
982
+
983
+ </li>
984
+
985
+ </ul>
986
+
987
+ <p class="tag_title">See Also:</p>
988
+ <ul class="see">
989
+
990
+ <li><a href="https://docs.htmlcsstoimage.com/getting-started/templates/" target="_parent" title="https://docs.htmlcsstoimage.com/getting-started/templates/">https://docs.htmlcsstoimage.com/getting-started/templates/</a></li>
991
+
992
+ </ul>
993
+
994
+ </div><table class="source_code">
995
+ <tr>
996
+ <td>
997
+ <pre class="lines">
998
+
999
+
1000
+ 147
1001
+ 148
1002
+ 149
1003
+ 150
1004
+ 151
1005
+ 152</pre>
1006
+ </td>
1007
+ <td>
1008
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 147</span>
1009
+
1010
+ <span class='kw'>def</span> <span class='id identifier rubyid_create_template'>create_template</span><span class='lparen'>(</span><span class='id identifier rubyid_html'>html</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1011
+ <span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>html:</span> <span class='id identifier rubyid_html'>html</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
1012
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span><span class='comma'>,</span> <span class='label'>body:</span> <span class='id identifier rubyid_body'>body</span> <span class='rbrace'>}</span>
1013
+
1014
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/v1/template</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
1015
+ <span class='kw'>end</span></pre>
1016
+ </td>
1017
+ </tr>
1018
+ </table>
744
1019
  </div>
745
1020
 
746
1021
  <div class="method_details ">
@@ -852,13 +1127,13 @@
852
1127
  <pre class="lines">
853
1128
 
854
1129
 
1130
+ 124
855
1131
  125
856
1132
  126
857
- 127
858
- 128</pre>
1133
+ 127</pre>
859
1134
  </td>
860
1135
  <td>
861
- <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 125</span>
1136
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 124</span>
862
1137
 
863
1138
  <span class='kw'>def</span> <span class='id identifier rubyid_templates'>templates</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
864
1139
  <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>basic_auth:</span> <span class='ivar'>@auth</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
@@ -1029,15 +1304,15 @@
1029
1304
  <pre class="lines">
1030
1305
 
1031
1306
 
1307
+ 114
1032
1308
  115
1033
1309
  116
1034
1310
  117
1035
1311
  118
1036
- 119
1037
- 120</pre>
1312
+ 119</pre>
1038
1313
  </td>
1039
1314
  <td>
1040
- <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 115</span>
1315
+ <pre class="code"><span class="info file"># File 'lib/htmlcsstoimage.rb', line 114</span>
1041
1316
 
1042
1317
  <span class='kw'>def</span> <span class='id identifier rubyid_url_to_image'>url_to_image</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1043
1318
  <span class='id identifier rubyid_body'>body</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='label'>url:</span> <span class='id identifier rubyid_url'>url</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
@@ -1055,7 +1330,7 @@
1055
1330
  </div>
1056
1331
 
1057
1332
  <div id="footer">
1058
- Generated on Fri Aug 7 11:01:21 2020 by
1333
+ Generated on Fri Aug 7 13:04:07 2020 by
1059
1334
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1060
1335
  0.9.25 (ruby-2.6.5).
1061
1336
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Fri Aug 7 11:01:21 2020 by
117
+ Generated on Fri Aug 7 13:04:07 2020 by
118
118
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.25 (ruby-2.6.5).
120
120
  </div>
@@ -112,7 +112,7 @@
112
112
  </div>
113
113
 
114
114
  <div id="footer">
115
- Generated on Fri Aug 7 11:01:21 2020 by
115
+ Generated on Fri Aug 7 13:04:07 2020 by
116
116
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
117
117
  0.9.25 (ruby-2.6.5).
118
118
  </div>
@@ -59,6 +59,8 @@
59
59
 
60
60
  <div id="content"><div id='filecontents'><h1 id="html-css-to-image-ruby">HTML/CSS to Image - Ruby</h1>
61
61
 
62
+ <p><img src="https://github.com/htmlcsstoimage/ruby-client/workflows/Test/badge.svg?branch=main" alt="Test"> <a href="https://badge.fury.io/rb/htmlcsstoimage-api"><img src="https://badge.fury.io/rb/htmlcsstoimage-api.svg" alt="Gem Version"></a></p>
63
+
62
64
  <p>Ruby client for the <a href="https://htmlcsstoimage.com">HTML/CSS to Image API</a>.</p>
63
65
 
64
66
  <p>Generate a png, jpg or webp images with Ruby. Renders exactly like Google Chrome.</p>
@@ -88,6 +90,8 @@
88
90
  </span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTMLCSSToImage.html" title="HTMLCSSToImage (class)">HTMLCSSToImage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user-id</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>api_key:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>api-key</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
89
91
  </code></pre>
90
92
 
93
+ <p><strong>Using Environment variables</strong></p>
94
+
91
95
  <p>Alternatively, you can set <code>ENV[&quot;HCTI_USER_ID&quot;]</code> and <code>ENV[&quot;HCTI_API_KEY&quot;]</code>. These will be loaded automatically.</p>
92
96
 
93
97
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTMLCSSToImage.html" title="HTMLCSSToImage (class)">HTMLCSSToImage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">new</a></span></span>
@@ -95,6 +99,8 @@
95
99
 
96
100
  <h3 id="create-an-image">Create an image</h3>
97
101
 
102
+ <p>Generate an image from HTML/CSS. Returns a URL to the image.</p>
103
+
98
104
  <pre class="code ruby"><code class="ruby">image = client.create_image(&quot;&lt;div&gt;Hello, world&lt;/div&gt;&quot;,
99
105
  css: &quot;div { background-color: red; font-family: Roboto; }&quot;,
100
106
  google_fonts: &quot;Roboto&quot;)
@@ -107,14 +113,40 @@ image.url
107
113
 
108
114
  <h3 id="delete-an-image">Delete an image</h3>
109
115
 
110
- <pre class="code Ruby"><code class="Ruby">client.delete_image(&quot;254b444c-dd82-4cc1-94ef-aa4b3a6870a6&quot;)
116
+ <p>Delete an existing image. Removes the image from HCTI servers and clears the CDN.</p>
117
+
118
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_delete_image'>delete_image</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>254b444c-dd82-4cc1-94ef-aa4b3a6870a6</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
111
119
  </code></pre>
112
120
 
113
121
  <h3 id="url-to-image">URL to image</h3>
114
122
 
123
+ <p>Generate a screenshot of any public URL.</p>
124
+
115
125
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_image'>image</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_url_to_image'>url_to_image</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://github.com</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>viewport_width:</span> <span class='int'>800</span><span class='comma'>,</span> <span class='label'>viewport_height:</span> <span class='int'>1200</span><span class='rparen'>)</span>
116
126
  </code></pre>
117
127
 
128
+ <h2 id="templates">Templates</h2>
129
+
130
+ <p>A template allows you to define HTML that includes variables to be substituted at the time of image creation. <a href="https://docs.htmlcsstoimage.com/getting-started/templates/">Learn more about templates</a>.</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_create_template'>create_template</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt;div&gt;{{title}}&lt;/div&gt;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
133
+ <span class='comment'># =&gt; #&lt;HTMLCSSToImage::ApiResponse template_id=&quot;t-56c64be5-5861-4148-acec-aaaca452027f&quot;, template_version=1596829374001&gt;
134
+ </span>
135
+ <span class='comment'># Get templates
136
+ </span><span class='id identifier rubyid_all_templates'>all_templates</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_templates'>templates</span>
137
+
138
+ <span class='comment'># Create a signed URL for a templated image
139
+ </span><span class='id identifier rubyid_image'>image</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_create_image_from_template'>create_image_from_template</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_template_id'>template_id</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>title:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hello, world!</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
140
+ <span class='comment'># =&gt; #&lt;HTMLCSSToImage::ApiResponse url=&quot;https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21&quot;&gt;
141
+ </span>
142
+ <span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span>
143
+ <span class='comment'># =&gt; &quot;https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21&quot;
144
+ </span></code></pre>
145
+
146
+ <h3 id="additional-methods">Additional methods</h3>
147
+
148
+ <p>See the <a href="https://htmlcsstoimage.github.io/ruby-client/HTMLCSSToImage.html">ruby-client docs for all of the available methods</a>.</p>
149
+
118
150
  <h2 id="available-parameters">Available parameters</h2>
119
151
 
120
152
  <p>For detailed information on all the available parameters, visit the docs: <a href="https://docs.htmlcsstoimage.com/getting-started/using-the-api/">https://docs.htmlcsstoimage.com/getting-started/using-the-api/</a></p>
@@ -125,7 +157,7 @@ image.url
125
157
 
126
158
  <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
127
159
 
128
- <p>To generate the Yard docs, run <code>yard doc</code> and commit the changes.</p>
160
+ <p>To generate the Yard docs, run <code>yard doc -o docs</code> and commit the changes.</p>
129
161
 
130
162
  <h2 id="support">Support</h2>
131
163
 
@@ -133,7 +165,7 @@ image.url
133
165
 
134
166
  <h2 id="contributing">Contributing</h2>
135
167
 
136
- <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org">https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org</a>) code of conduct.</p>
168
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/htmlcsstoimage/ruby-client">https://github.com/htmlcsstoimage/ruby-client</a>.</p>
137
169
 
138
170
  <h2 id="license">License</h2>
139
171
 
@@ -145,7 +177,7 @@ image.url
145
177
  </div></div>
146
178
 
147
179
  <div id="footer">
148
- Generated on Fri Aug 7 11:01:21 2020 by
180
+ Generated on Fri Aug 7 13:04:07 2020 by
149
181
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
150
182
  0.9.25 (ruby-2.6.5).
151
183
  </div>
@@ -59,6 +59,8 @@
59
59
 
60
60
  <div id="content"><div id='filecontents'><h1 id="html-css-to-image-ruby">HTML/CSS to Image - Ruby</h1>
61
61
 
62
+ <p><img src="https://github.com/htmlcsstoimage/ruby-client/workflows/Test/badge.svg?branch=main" alt="Test"> <a href="https://badge.fury.io/rb/htmlcsstoimage-api"><img src="https://badge.fury.io/rb/htmlcsstoimage-api.svg" alt="Gem Version"></a></p>
63
+
62
64
  <p>Ruby client for the <a href="https://htmlcsstoimage.com">HTML/CSS to Image API</a>.</p>
63
65
 
64
66
  <p>Generate a png, jpg or webp images with Ruby. Renders exactly like Google Chrome.</p>
@@ -88,6 +90,8 @@
88
90
  </span><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTMLCSSToImage.html" title="HTMLCSSToImage (class)">HTMLCSSToImage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>user_id:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>user-id</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>api_key:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>api-key</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
89
91
  </code></pre>
90
92
 
93
+ <p><strong>Using Environment variables</strong></p>
94
+
91
95
  <p>Alternatively, you can set <code>ENV[&quot;HCTI_USER_ID&quot;]</code> and <code>ENV[&quot;HCTI_API_KEY&quot;]</code>. These will be loaded automatically.</p>
92
96
 
93
97
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="HTMLCSSToImage.html" title="HTMLCSSToImage (class)">HTMLCSSToImage</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">new</a></span></span>
@@ -95,6 +99,8 @@
95
99
 
96
100
  <h3 id="create-an-image">Create an image</h3>
97
101
 
102
+ <p>Generate an image from HTML/CSS. Returns a URL to the image.</p>
103
+
98
104
  <pre class="code ruby"><code class="ruby">image = client.create_image(&quot;&lt;div&gt;Hello, world&lt;/div&gt;&quot;,
99
105
  css: &quot;div { background-color: red; font-family: Roboto; }&quot;,
100
106
  google_fonts: &quot;Roboto&quot;)
@@ -107,14 +113,40 @@ image.url
107
113
 
108
114
  <h3 id="delete-an-image">Delete an image</h3>
109
115
 
110
- <pre class="code Ruby"><code class="Ruby">client.delete_image(&quot;254b444c-dd82-4cc1-94ef-aa4b3a6870a6&quot;)
116
+ <p>Delete an existing image. Removes the image from HCTI servers and clears the CDN.</p>
117
+
118
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_delete_image'>delete_image</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>254b444c-dd82-4cc1-94ef-aa4b3a6870a6</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
111
119
  </code></pre>
112
120
 
113
121
  <h3 id="url-to-image">URL to image</h3>
114
122
 
123
+ <p>Generate a screenshot of any public URL.</p>
124
+
115
125
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_image'>image</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_url_to_image'>url_to_image</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>https://github.com</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>viewport_width:</span> <span class='int'>800</span><span class='comma'>,</span> <span class='label'>viewport_height:</span> <span class='int'>1200</span><span class='rparen'>)</span>
116
126
  </code></pre>
117
127
 
128
+ <h2 id="templates">Templates</h2>
129
+
130
+ <p>A template allows you to define HTML that includes variables to be substituted at the time of image creation. <a href="https://docs.htmlcsstoimage.com/getting-started/templates/">Learn more about templates</a>.</p>
131
+
132
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_create_template'>create_template</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>&lt;div&gt;{{title}}&lt;/div&gt;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
133
+ <span class='comment'># =&gt; #&lt;HTMLCSSToImage::ApiResponse template_id=&quot;t-56c64be5-5861-4148-acec-aaaca452027f&quot;, template_version=1596829374001&gt;
134
+ </span>
135
+ <span class='comment'># Get templates
136
+ </span><span class='id identifier rubyid_all_templates'>all_templates</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_templates'>templates</span>
137
+
138
+ <span class='comment'># Create a signed URL for a templated image
139
+ </span><span class='id identifier rubyid_image'>image</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_create_image_from_template'>create_image_from_template</span><span class='lparen'>(</span><span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_template_id'>template_id</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>title:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Hello, world!</span><span class='tstring_end'>&quot;</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
140
+ <span class='comment'># =&gt; #&lt;HTMLCSSToImage::ApiResponse url=&quot;https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21&quot;&gt;
141
+ </span>
142
+ <span class='id identifier rubyid_image'>image</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span>
143
+ <span class='comment'># =&gt; &quot;https://hcti.io/v1/image/t-56c64be5-5861-4148-acec-aaaca452027f/3aaa814dd998b302cc62b3550ddb35e8b9117c5ecea286da904eced0a3f44d9e?title=Hello%2C%20world%21&quot;
144
+ </span></code></pre>
145
+
146
+ <h3 id="additional-methods">Additional methods</h3>
147
+
148
+ <p>See the <a href="https://htmlcsstoimage.github.io/ruby-client/HTMLCSSToImage.html">ruby-client docs for all of the available methods</a>.</p>
149
+
118
150
  <h2 id="available-parameters">Available parameters</h2>
119
151
 
120
152
  <p>For detailed information on all the available parameters, visit the docs: <a href="https://docs.htmlcsstoimage.com/getting-started/using-the-api/">https://docs.htmlcsstoimage.com/getting-started/using-the-api/</a></p>
@@ -125,7 +157,7 @@ image.url
125
157
 
126
158
  <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
127
159
 
128
- <p>To generate the Yard docs, run <code>yard doc</code> and commit the changes.</p>
160
+ <p>To generate the Yard docs, run <code>yard doc -o docs</code> and commit the changes.</p>
129
161
 
130
162
  <h2 id="support">Support</h2>
131
163
 
@@ -133,7 +165,7 @@ image.url
133
165
 
134
166
  <h2 id="contributing">Contributing</h2>
135
167
 
136
- <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org">https://github.com/htmlcsstoimage/ruby-client/contributor-covenant.org</a>) code of conduct.</p>
168
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/htmlcsstoimage/ruby-client">https://github.com/htmlcsstoimage/ruby-client</a>.</p>
137
169
 
138
170
  <h2 id="license">License</h2>
139
171
 
@@ -145,7 +177,7 @@ image.url
145
177
  </div></div>
146
178
 
147
179
  <div id="footer">
148
- Generated on Fri Aug 7 11:01:21 2020 by
180
+ Generated on Fri Aug 7 13:04:07 2020 by
149
181
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
150
182
  0.9.25 (ruby-2.6.5).
151
183
  </div>
@@ -62,7 +62,7 @@
62
62
 
63
63
  <li class="odd ">
64
64
  <div class="item">
65
- <span class='object_link'><a href="HTMLCSSToImage.html#delete_image-instance_method" title="HTMLCSSToImage#delete_image (method)">#delete_image</a></span>
65
+ <span class='object_link'><a href="HTMLCSSToImage.html#create_template-instance_method" title="HTMLCSSToImage#create_template (method)">#create_template</a></span>
66
66
  <small>HTMLCSSToImage</small>
67
67
  </div>
68
68
  </li>
@@ -70,7 +70,7 @@
70
70
 
71
71
  <li class="even ">
72
72
  <div class="item">
73
- <span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">#initialize</a></span>
73
+ <span class='object_link'><a href="HTMLCSSToImage.html#delete_image-instance_method" title="HTMLCSSToImage#delete_image (method)">#delete_image</a></span>
74
74
  <small>HTMLCSSToImage</small>
75
75
  </div>
76
76
  </li>
@@ -78,13 +78,21 @@
78
78
 
79
79
  <li class="odd ">
80
80
  <div class="item">
81
- <span class='object_link'><a href="HTMLCSSToImage.html#templates-instance_method" title="HTMLCSSToImage#templates (method)">#templates</a></span>
81
+ <span class='object_link'><a href="HTMLCSSToImage.html#initialize-instance_method" title="HTMLCSSToImage#initialize (method)">#initialize</a></span>
82
82
  <small>HTMLCSSToImage</small>
83
83
  </div>
84
84
  </li>
85
85
 
86
86
 
87
87
  <li class="even ">
88
+ <div class="item">
89
+ <span class='object_link'><a href="HTMLCSSToImage.html#templates-instance_method" title="HTMLCSSToImage#templates (method)">#templates</a></span>
90
+ <small>HTMLCSSToImage</small>
91
+ </div>
92
+ </li>
93
+
94
+
95
+ <li class="odd ">
88
96
  <div class="item">
89
97
  <span class='object_link'><a href="HTMLCSSToImage.html#url_to_image-instance_method" title="HTMLCSSToImage#url_to_image (method)">#url_to_image</a></span>
90
98
  <small>HTMLCSSToImage</small>
@@ -100,7 +100,7 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Fri Aug 7 11:01:21 2020 by
103
+ Generated on Fri Aug 7 13:04:07 2020 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
105
  0.9.25 (ruby-2.6.5).
106
106
  </div>
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
 
26
26
  spec.add_dependency "httparty", "> 0.10"
27
+ spec.add_dependency "addressable", "> 2.5.0"
27
28
  spec.add_development_dependency "bundler", "> 2.0"
28
29
  spec.add_development_dependency "rake", "~> 13.0"
29
30
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,3 +1,3 @@
1
1
  class HTMLCSSToImage
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlcsstoimage-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Coutermarsh
8
8
  - Jeffrey Needles
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-08-07 00:00:00.000000000 Z
12
+ date: 2020-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: addressable
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">"
33
+ - !ruby/object:Gem::Version
34
+ version: 2.5.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">"
40
+ - !ruby/object:Gem::Version
41
+ version: 2.5.0
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: bundler
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +189,7 @@ homepage: https://docs.htmlcsstoimage.com/example-code/ruby
175
189
  licenses:
176
190
  - MIT
177
191
  metadata: {}
178
- post_install_message:
192
+ post_install_message:
179
193
  rdoc_options: []
180
194
  require_paths:
181
195
  - lib
@@ -191,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
205
  version: '0'
192
206
  requirements: []
193
207
  rubygems_version: 3.0.3
194
- signing_key:
208
+ signing_key:
195
209
  specification_version: 4
196
210
  summary: Ruby client for the HTML/CSS to Image API.
197
211
  test_files: []