fattura24 1.0.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/CHANGELOG.md +2 -0
- data/Gemfile +8 -0
- data/LICENSE +21 -0
- data/README.md +186 -0
- data/Rakefile +16 -0
- data/docs/Fattura24.html +197 -0
- data/docs/Fattura24/Api.html +497 -0
- data/docs/Fattura24/Api/Response.html +371 -0
- data/docs/Fattura24/Configuration.html +176 -0
- data/docs/Fattura24/DocumentType.html +133 -0
- data/docs/Fattura24/Error.html +104 -0
- data/docs/Fattura24/InvalidParams.html +104 -0
- data/docs/Fattura24/MissingApiKey.html +157 -0
- data/docs/Fattura24/MissingInput.html +104 -0
- data/docs/Fattura24/NotSerializable.html +104 -0
- data/docs/Fattura24/Utils.html +232 -0
- data/docs/README_md.html +273 -0
- data/docs/created.rid +10 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +619 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +283 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +216 -0
- data/fattura24.gemspec +54 -0
- data/lib/fattura24.rb +28 -0
- data/lib/fattura24/api/client.rb +160 -0
- data/lib/fattura24/api/response.rb +70 -0
- data/lib/fattura24/configuration.rb +14 -0
- data/lib/fattura24/document_type.rb +15 -0
- data/lib/fattura24/errors.rb +20 -0
- data/lib/fattura24/utils.rb +38 -0
- data/lib/fattura24/version.rb +5 -0
- metadata +267 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/docs/images/add.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/docs/images/bug.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/docs/index.html
ADDED
@@ -0,0 +1,283 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
<body id="top" role="document" class="file">
|
26
|
+
<nav role="navigation">
|
27
|
+
<div id="project-navigation">
|
28
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
29
|
+
<h2>
|
30
|
+
<a href="./index.html" rel="home">Home</a>
|
31
|
+
</h2>
|
32
|
+
|
33
|
+
<div id="table-of-contents-navigation">
|
34
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
35
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
36
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<div id="project-metadata">
|
59
|
+
<div id="fileindex-section" class="nav-section">
|
60
|
+
<h3>Pages</h3>
|
61
|
+
|
62
|
+
<ul class="link-list">
|
63
|
+
|
64
|
+
<li><a href="./README_md.html">README</a>
|
65
|
+
|
66
|
+
</ul>
|
67
|
+
</div>
|
68
|
+
|
69
|
+
<div id="classindex-section" class="nav-section">
|
70
|
+
<h3>Class and Module Index</h3>
|
71
|
+
|
72
|
+
<ul class="link-list">
|
73
|
+
|
74
|
+
<li><a href="./Fattura24.html">Fattura24</a>
|
75
|
+
|
76
|
+
<li><a href="./Fattura24/Api.html">Fattura24::Api</a>
|
77
|
+
|
78
|
+
<li><a href="./Fattura24/Api/Response.html">Fattura24::Api::Response</a>
|
79
|
+
|
80
|
+
<li><a href="./Fattura24/Configuration.html">Fattura24::Configuration</a>
|
81
|
+
|
82
|
+
<li><a href="./Fattura24/DocumentType.html">Fattura24::DocumentType</a>
|
83
|
+
|
84
|
+
<li><a href="./Fattura24/Error.html">Fattura24::Error</a>
|
85
|
+
|
86
|
+
<li><a href="./Fattura24/InvalidParams.html">Fattura24::InvalidParams</a>
|
87
|
+
|
88
|
+
<li><a href="./Fattura24/MissingApiKey.html">Fattura24::MissingApiKey</a>
|
89
|
+
|
90
|
+
<li><a href="./Fattura24/MissingInput.html">Fattura24::MissingInput</a>
|
91
|
+
|
92
|
+
<li><a href="./Fattura24/NotSerializable.html">Fattura24::NotSerializable</a>
|
93
|
+
|
94
|
+
<li><a href="./Fattura24/Utils.html">Fattura24::Utils</a>
|
95
|
+
|
96
|
+
</ul>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
</div>
|
100
|
+
</nav>
|
101
|
+
|
102
|
+
<main role="main">
|
103
|
+
|
104
|
+
|
105
|
+
<h1 id="label-Fattura24"><a href="Fattura24.html"><code>Fattura24</code></a><span><a href="#label-Fattura24">¶</a> <a href="#top">↑</a></span></h1>
|
106
|
+
|
107
|
+
<p><a href="https://travis-ci.org/snada/fattura24"><img src="https://travis-ci.org/snada/fattura24.svg?branch=master"></a> <a href="https://codeclimate.com/github/snada/fattura24/maintainability"><img src="https://api.codeclimate.com/v1/badges/8db0d6f2c8e567f09319/maintainability"></a> <a href="https://codeclimate.com/github/snada/fattura24/test_coverage"><img src="https://api.codeclimate.com/v1/badges/8db0d6f2c8e567f09319/test_coverage"></a></p>
|
108
|
+
|
109
|
+
<p>Simple, lightweight and with minimal dependencies ruby 2 wrapper for the <a href="https://www.fattura24.com/">Fattura24</a> apis.</p>
|
110
|
+
|
111
|
+
<p>Tested and developed on rubies 2.4+.</p>
|
112
|
+
|
113
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
114
|
+
|
115
|
+
<p>Add this line to your application's Gemfile:</p>
|
116
|
+
|
117
|
+
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-string">'fattura24'</span>
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
<p>And then execute:</p>
|
121
|
+
|
122
|
+
<pre>$ bundle</pre>
|
123
|
+
|
124
|
+
<p>Or install it yourself as:</p>
|
125
|
+
|
126
|
+
<pre>$ gem install fattura24</pre>
|
127
|
+
|
128
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
129
|
+
|
130
|
+
<p>First, configure the module by adding your api key.</p>
|
131
|
+
|
132
|
+
<pre class="ruby"><span class="ruby-constant">Fattura24</span>.<span class="ruby-identifier">configure</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">configuration</span><span class="ruby-operator">|</span>
|
133
|
+
<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">api_key</span> = <span class="ruby-string">'your_secret_key'</span>
|
134
|
+
<span class="ruby-keyword">end</span>
|
135
|
+
</pre>
|
136
|
+
|
137
|
+
<p>Once set, you can call the api methods to get the responses you need.</p>
|
138
|
+
|
139
|
+
<pre class="ruby"><span class="ruby-comment"># This method checks if your key is valid</span>
|
140
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">test_key</span>
|
141
|
+
|
142
|
+
<span class="ruby-comment"># Check for possible network errors, returns true on ok (200) responses</span>
|
143
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">success?</span>
|
144
|
+
|
145
|
+
<span class="ruby-comment"># Call .to_h to get a hash version of the xml response</span>
|
146
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">to_h</span>[<span class="ruby-value">:returnCode</span>]
|
147
|
+
|
148
|
+
<span class="ruby-comment"># If you need more info, check the raw Net::HTTP response object</span>
|
149
|
+
<span class="ruby-identifier">raw_response</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">http_response</span>
|
150
|
+
</pre>
|
151
|
+
|
152
|
+
<h3 id="label-Api+calls">Api calls<span><a href="#label-Api+calls">¶</a> <a href="#top">↑</a></span></h3>
|
153
|
+
|
154
|
+
<p>You can take inspiration on the params to provide to your calls by visiting the <a href="https://www.fattura24.com/api-documentazione/">official documentation</a>. Generally speaking, this library will translate the structure of your hash to an equivalent xml document camelizing all of your keys.</p>
|
155
|
+
|
156
|
+
<h4 id="label-TestKey-2C+GetTemplate-2C+GetPdc-2C+GetNumerator">TestKey, GetTemplate, GetPdc, GetNumerator<span><a href="#label-TestKey-2C+GetTemplate-2C+GetPdc-2C+GetNumerator">¶</a> <a href="#top">↑</a></span></h4>
|
157
|
+
|
158
|
+
<p>All of these calls don't require any argument. Simply call them and inspect their response:</p>
|
159
|
+
|
160
|
+
<pre class="ruby"><span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">test_key</span>
|
161
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_template</span>
|
162
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_pdc</span>
|
163
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_numerator</span>
|
164
|
+
|
165
|
+
<span class="ruby-identifier">puts</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">to_h</span>
|
166
|
+
</pre>
|
167
|
+
|
168
|
+
<h4 id="label-SaveCustomer">SaveCustomer<span><a href="#label-SaveCustomer">¶</a> <a href="#top">↑</a></span></h4>
|
169
|
+
|
170
|
+
<pre class="ruby"><span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">save_customer</span>(
|
171
|
+
<span class="ruby-value">customer_name:</span> <span class="ruby-string">'John Doe'</span>,
|
172
|
+
<span class="ruby-value">customer_address:</span> <span class="ruby-string">'100 Yonge Street'</span>,
|
173
|
+
<span class="ruby-value">customer_city:</span> <span class="ruby-string">'Toronto'</span>,
|
174
|
+
<span class="ruby-value">customer_country:</span> <span class="ruby-string">'CA'</span>,
|
175
|
+
<span class="ruby-value">customer_fiscal_code:</span> <span class="ruby-string">'Set this for persons'</span>,
|
176
|
+
<span class="ruby-value">customer_vat_code:</span> <span class="ruby-string">'vat'</span>,
|
177
|
+
<span class="ruby-value">customer_email:</span> <span class="ruby-string">'some@email.com'</span>,
|
178
|
+
<span class="ruby-value">fe_customer_pec:</span> <span class="ruby-string">'a@pec.com'</span>
|
179
|
+
)
|
180
|
+
</pre>
|
181
|
+
|
182
|
+
<h4 id="label-SaveDocument">SaveDocument<span><a href="#label-SaveDocument">¶</a> <a href="#top">↑</a></span></h4>
|
183
|
+
|
184
|
+
<pre class="ruby"><span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">save_document</span>(
|
185
|
+
<span class="ruby-value">document_type:</span> <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">DocumentType</span><span class="ruby-operator">::</span><span class="ruby-constant">ELECTRONIC_INVOICE</span>,
|
186
|
+
<span class="ruby-value">customer_name:</span> <span class="ruby-string">'John Doe'</span>,
|
187
|
+
<span class="ruby-value">customer_fiscal_code:</span> <span class="ruby-string">'NDASFN89A27L219Y'</span>,
|
188
|
+
<span class="ruby-value">customer_address:</span> <span class="ruby-string">'100 Yonge Street'</span>,
|
189
|
+
<span class="ruby-value">customer_city:</span> <span class="ruby-string">'Toronto'</span>,
|
190
|
+
<span class="ruby-value">customer_country:</span> <span class="ruby-string">'CA'</span>,
|
191
|
+
<span class="ruby-value">payments:</span> [
|
192
|
+
{
|
193
|
+
<span class="ruby-value">date:</span> <span class="ruby-string">'2020-04-27'</span>,
|
194
|
+
<span class="ruby-value">amount:</span> <span class="ruby-string">'100'</span>,
|
195
|
+
<span class="ruby-value">paid:</span> <span class="ruby-string">'true'</span>
|
196
|
+
}
|
197
|
+
],
|
198
|
+
<span class="ruby-value">rows:</span> [
|
199
|
+
{
|
200
|
+
<span class="ruby-value">code:</span> <span class="ruby-string">'001'</span>,
|
201
|
+
<span class="ruby-value">description:</span> <span class="ruby-string">'Element description'</span>,
|
202
|
+
<span class="ruby-value">qty:</span> <span class="ruby-string">'1'</span>,
|
203
|
+
<span class="ruby-value">price:</span> <span class="ruby-string">'100'</span>
|
204
|
+
}
|
205
|
+
],
|
206
|
+
<span class="ruby-value">id_template:</span> <span class="ruby-string">'65'</span>,
|
207
|
+
<span class="ruby-value">send_email:</span> <span class="ruby-string">'true'</span>,
|
208
|
+
<span class="ruby-value">object:</span> <span class="ruby-string">'test'</span>,
|
209
|
+
<span class="ruby-value">total:</span> <span class="ruby-value">100</span>,
|
210
|
+
<span class="ruby-value">total_without_tax:</span> <span class="ruby-value">100</span>,
|
211
|
+
<span class="ruby-value">vat_amount:</span> <span class="ruby-value">0</span>
|
212
|
+
)
|
213
|
+
</pre>
|
214
|
+
|
215
|
+
<h4 id="label-GetFile">GetFile<span><a href="#label-GetFile">¶</a> <a href="#top">↑</a></span></h4>
|
216
|
+
|
217
|
+
<pre class="ruby"><span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_file</span>(<span class="ruby-string">'1234567'</span>)
|
218
|
+
|
219
|
+
<span class="ruby-comment"># true if response content is actually a file</span>
|
220
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">r</span>.<span class="ruby-identifier">pdf?</span>
|
221
|
+
<span class="ruby-constant">File</span>.<span class="ruby-identifier">write</span>(<span class="ruby-string">'invoice.pdf'</span>, <span class="ruby-identifier">r</span>.<span class="ruby-identifier">to_s</span>)
|
222
|
+
<span class="ruby-keyword">end</span>
|
223
|
+
</pre>
|
224
|
+
|
225
|
+
<h4 id="label-GetProduct">GetProduct<span><a href="#label-GetProduct">¶</a> <a href="#top">↑</a></span></h4>
|
226
|
+
|
227
|
+
<pre class="ruby"><span class="ruby-comment"># gets all products</span>
|
228
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_product</span>
|
229
|
+
|
230
|
+
<span class="ruby-comment"># filters by code</span>
|
231
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_product</span>(<span class="ruby-value">code:</span> <span class="ruby-string">'some_code'</span>)
|
232
|
+
|
233
|
+
<span class="ruby-comment"># filters by category</span>
|
234
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_product</span>(<span class="ruby-value">category:</span> <span class="ruby-string">'some_category'</span>)
|
235
|
+
|
236
|
+
<span class="ruby-comment"># combines both</span>
|
237
|
+
<span class="ruby-identifier">r</span> = <span class="ruby-constant">Fattura24</span><span class="ruby-operator">::</span><span class="ruby-constant">Api</span>.<span class="ruby-identifier">get_product</span>({
|
238
|
+
<span class="ruby-value">code:</span> <span class="ruby-string">'some_code'</span>,
|
239
|
+
<span class="ruby-value">category:</span> <span class="ruby-string">'some_category'</span>
|
240
|
+
})
|
241
|
+
</pre>
|
242
|
+
|
243
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
244
|
+
|
245
|
+
<p>After checking out the repo, run <code>bundle</code> to install dependencies. You can run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
|
246
|
+
|
247
|
+
<p>To install this gem onto your local machine, run <code>bundle exec rake install</code>.</p>
|
248
|
+
|
249
|
+
<p>To run tests and linting, simply run <code>bundle exec rake</code>.</p>
|
250
|
+
|
251
|
+
<p>When you edit something, include appropriate docs and rebuild them by running <code>bundle exec rake rdoc</code>.</p>
|
252
|
+
|
253
|
+
<p>If you have docker installed, you can test against all of the supported ruby versions by running:</p>
|
254
|
+
|
255
|
+
<pre>$ make build</pre>
|
256
|
+
|
257
|
+
<p>That will build the required docker images, and then you can run tests with:</p>
|
258
|
+
|
259
|
+
<pre>$ make</pre>
|
260
|
+
|
261
|
+
<h3 id="label-Release+of+a+new+version">Release of a new version<span><a href="#label-Release+of+a+new+version">¶</a> <a href="#top">↑</a></span></h3>
|
262
|
+
|
263
|
+
<p>To release a new version, update the version number in <code>lib/fattura24/version.rb</code>. Make sure version tests are still satisfied. 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>
|
264
|
+
|
265
|
+
<h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">¶</a> <a href="#top">↑</a></span></h2>
|
266
|
+
|
267
|
+
<p>Everyone is welcome to contribute. This project tries to follow the git-flow branching model. Open a branch named <code>feature/<name></code> and make a PR against <code>develop</code>.</p>
|
268
|
+
|
269
|
+
<p>Please, make sure you include appropriate unit tests to the codebase (also check coverage) and that your code satisfies rubocop checks.</p>
|
270
|
+
|
271
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
272
|
+
|
273
|
+
<p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
|
274
|
+
</main>
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<footer id="validator-badges" role="contentinfo">
|
279
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
280
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.1.
|
281
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
282
|
+
</footer>
|
283
|
+
|
data/docs/js/darkfish.js
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Darkfish Page Functions
|
4
|
+
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
+
*
|
6
|
+
* Author: Michael Granger <mgranger@laika.com>
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* Provide console simulation for firebug-less environments */
|
11
|
+
/*
|
12
|
+
if (!("console" in window) || !("firebug" in console)) {
|
13
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
14
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
15
|
+
|
16
|
+
window.console = {};
|
17
|
+
for (var i = 0; i < names.length; ++i)
|
18
|
+
window.console[names[i]] = function() {};
|
19
|
+
};
|
20
|
+
*/
|
21
|
+
|
22
|
+
|
23
|
+
function showSource( e ) {
|
24
|
+
var target = e.target;
|
25
|
+
while (!target.classList.contains('method-detail')) {
|
26
|
+
target = target.parentNode;
|
27
|
+
}
|
28
|
+
if (typeof target !== "undefined" && target !== null) {
|
29
|
+
target = target.querySelector('.method-source-code');
|
30
|
+
}
|
31
|
+
if (typeof target !== "undefined" && target !== null) {
|
32
|
+
target.classList.toggle('active-menu')
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
function hookSourceViews() {
|
37
|
+
document.querySelectorAll('.method-heading').forEach(function (codeObject) {
|
38
|
+
codeObject.addEventListener('click', showSource);
|
39
|
+
});
|
40
|
+
};
|
41
|
+
|
42
|
+
function hookSearch() {
|
43
|
+
var input = document.querySelector('#search-field');
|
44
|
+
var result = document.querySelector('#search-results');
|
45
|
+
result.classList.remove("initially-hidden");
|
46
|
+
|
47
|
+
var search_section = document.querySelector('#search-section');
|
48
|
+
search_section.classList.remove("initially-hidden");
|
49
|
+
|
50
|
+
var search = new Search(search_data, input, result);
|
51
|
+
|
52
|
+
search.renderItem = function(result) {
|
53
|
+
var li = document.createElement('li');
|
54
|
+
var html = '';
|
55
|
+
|
56
|
+
// TODO add relative path to <script> per-page
|
57
|
+
html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
|
58
|
+
if (result.params)
|
59
|
+
html += '<span class="params">' + result.params + '</span>';
|
60
|
+
html += '</a>';
|
61
|
+
|
62
|
+
|
63
|
+
if (result.namespace)
|
64
|
+
html += '<p class="search-namespace">' + this.hlt(result.namespace);
|
65
|
+
|
66
|
+
if (result.snippet)
|
67
|
+
html += '<div class="search-snippet">' + result.snippet + '</div>';
|
68
|
+
|
69
|
+
li.innerHTML = html;
|
70
|
+
|
71
|
+
return li;
|
72
|
+
}
|
73
|
+
|
74
|
+
search.select = function(result) {
|
75
|
+
window.location.href = result.firstChild.firstChild.href;
|
76
|
+
}
|
77
|
+
|
78
|
+
search.scrollIntoView = search.scrollInWindow;
|
79
|
+
};
|
80
|
+
|
81
|
+
document.addEventListener('DOMContentLoaded', function() {
|
82
|
+
hookSourceViews();
|
83
|
+
hookSearch();
|
84
|
+
});
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/*
|
2
|
+
* Navigation allows movement using the arrow keys through the search results.
|
3
|
+
*
|
4
|
+
* When using this library you will need to set scrollIntoView to the
|
5
|
+
* appropriate function for your layout. Use scrollInWindow if the container
|
6
|
+
* is not scrollable and scrollInElement if the container is a separate
|
7
|
+
* scrolling region.
|
8
|
+
*/
|
9
|
+
Navigation = new function() {
|
10
|
+
this.initNavigation = function() {
|
11
|
+
var _this = this;
|
12
|
+
|
13
|
+
document.addEventListener('keydown', function(e) {
|
14
|
+
_this.onkeydown(e);
|
15
|
+
});
|
16
|
+
|
17
|
+
this.navigationActive = true;
|
18
|
+
}
|
19
|
+
|
20
|
+
this.setNavigationActive = function(state) {
|
21
|
+
this.navigationActive = state;
|
22
|
+
}
|
23
|
+
|
24
|
+
this.onkeydown = function(e) {
|
25
|
+
if (!this.navigationActive) return;
|
26
|
+
switch(e.keyCode) {
|
27
|
+
case 37: //Event.KEY_LEFT:
|
28
|
+
if (this.moveLeft()) e.preventDefault();
|
29
|
+
break;
|
30
|
+
case 38: //Event.KEY_UP:
|
31
|
+
if (e.keyCode == 38 || e.ctrlKey) {
|
32
|
+
if (this.moveUp()) e.preventDefault();
|
33
|
+
}
|
34
|
+
break;
|
35
|
+
case 39: //Event.KEY_RIGHT:
|
36
|
+
if (this.moveRight()) e.preventDefault();
|
37
|
+
break;
|
38
|
+
case 40: //Event.KEY_DOWN:
|
39
|
+
if (e.keyCode == 40 || e.ctrlKey) {
|
40
|
+
if (this.moveDown()) e.preventDefault();
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
case 13: //Event.KEY_RETURN:
|
44
|
+
if (this.current) e.preventDefault();
|
45
|
+
this.select(this.current);
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
if (e.ctrlKey && e.shiftKey) this.select(this.current);
|
49
|
+
}
|
50
|
+
|
51
|
+
this.moveRight = function() {
|
52
|
+
}
|
53
|
+
|
54
|
+
this.moveLeft = function() {
|
55
|
+
}
|
56
|
+
|
57
|
+
this.move = function(isDown) {
|
58
|
+
}
|
59
|
+
|
60
|
+
this.moveUp = function() {
|
61
|
+
return this.move(false);
|
62
|
+
}
|
63
|
+
|
64
|
+
this.moveDown = function() {
|
65
|
+
return this.move(true);
|
66
|
+
}
|
67
|
+
|
68
|
+
/*
|
69
|
+
* Scrolls to the given element in the scrollable element view.
|
70
|
+
*/
|
71
|
+
this.scrollInElement = function(element, view) {
|
72
|
+
var offset, viewHeight, viewScroll, height;
|
73
|
+
offset = element.offsetTop;
|
74
|
+
height = element.offsetHeight;
|
75
|
+
viewHeight = view.offsetHeight;
|
76
|
+
viewScroll = view.scrollTop;
|
77
|
+
|
78
|
+
if (offset - viewScroll + height > viewHeight) {
|
79
|
+
view.scrollTop = offset - viewHeight + height;
|
80
|
+
}
|
81
|
+
if (offset < viewScroll) {
|
82
|
+
view.scrollTop = offset;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
/*
|
87
|
+
* Scrolls to the given element in the window. The second argument is
|
88
|
+
* ignored
|
89
|
+
*/
|
90
|
+
this.scrollInWindow = function(element, ignored) {
|
91
|
+
var offset, viewHeight, viewScroll, height;
|
92
|
+
offset = element.offsetTop;
|
93
|
+
height = element.offsetHeight;
|
94
|
+
viewHeight = window.innerHeight;
|
95
|
+
viewScroll = window.scrollY;
|
96
|
+
|
97
|
+
if (offset - viewScroll + height > viewHeight) {
|
98
|
+
window.scrollTo(window.scrollX, offset - viewHeight + height);
|
99
|
+
}
|
100
|
+
if (offset < viewScroll) {
|
101
|
+
window.scrollTo(window.scrollX, offset);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|