easy_invoices 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1237c953b5e5dcaf5ec52540e91f75108721a3edf42e4f9164c62ed30b241261
4
- data.tar.gz: 1e00a916870b26d22bfdbd71f142b8049b9653ac2724994888966e2317a7bda6
3
+ metadata.gz: 3a6f355cd2ba71f396a7ad7a5a6d7da2267f2b0048bdbaf625b4a7d964ab0285
4
+ data.tar.gz: 6bfc88a05d28f2842725a4d9b47dd93a208dd56192168b9060b2cf5a10ce5106
5
5
  SHA512:
6
- metadata.gz: cc29eb7d56132decae0300830974f20547cf0279f8969eaa6f4d536c65a5604d43dc5798fd18fc7210d0a59cfee5d99590e2a60005494a07164620572a457b09
7
- data.tar.gz: 7cd65e6a48467048ad0597785b1476fbaca562257278ac901f677068ea059db819c9593bd36cc8c05a3807f3d1cf70a9ededc4dae2ed56faf8ec82a5602a581d
6
+ metadata.gz: 0f8e1003f1248d8ec1d6f44e933d4d36ee432643d2ba8a5cc778eb65c907f1e21e4170ea8b55285bec3654c147938b0c2058160df3914e81e97df1f9acf580c9
7
+ data.tar.gz: cb07c66bb2a2f7c7e1a999400fab9581a95a57ea640584c174e00defdc382b907e11d04079710647c583e216164ad49b9f4214fbe4560d9d54f679bb88e4411d
data/lib/easy_invoices.rb CHANGED
@@ -3,8 +3,10 @@ require "easy_invoices/version"
3
3
  require "easy_invoices/includer"
4
4
  require "easy_invoices/act"
5
5
  require "easy_invoices/invoice"
6
+ require "easy_invoices/configuration"
6
7
 
7
8
  module EasyInvoices
9
+
8
10
  class Error < StandardError; end
9
11
 
10
12
  BASE_SIGN_SIZE = 200
@@ -12,4 +14,20 @@ module EasyInvoices
12
14
  ActiveSupport.on_load(:active_record) do
13
15
  extend EasyInvoices::Includer
14
16
  end
17
+
18
+ class << self
19
+ attr_accessor :configuration
20
+ end
21
+
22
+ def self.configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def self.reset
27
+ @configuration = Configuration.new
28
+ end
29
+
30
+ def self.configure
31
+ yield(configuration)
32
+ end
15
33
  end
@@ -0,0 +1,10 @@
1
+ class EasyInvoices::Configuration
2
+
3
+ attr_accessor :act_dir, :invoice_dir
4
+
5
+ def initialize
6
+ @act_dir = nil
7
+ @invoice_dir = nil
8
+ end
9
+
10
+ end
@@ -7,6 +7,10 @@ class EasyInvoices::Generator
7
7
  self.new(invoice_params, file_name).process
8
8
  end
9
9
 
10
+ def self.storage_dir
11
+ EasyInvoices.configuration.send(:"#{self.name.demodulize.downcase}_dir") || self::DIR
12
+ end
13
+
10
14
  def initialize(invoice_params, file_name)
11
15
  @invoice_params = invoice_params
12
16
  @file_name = file_name.nil? ? "#{SecureRandom.hex}.pdf" : "#{file_name}.pdf"
@@ -29,7 +33,7 @@ class EasyInvoices::Generator
29
33
  end
30
34
 
31
35
  def target_dir
32
- Rails.root.join(*self.class::DIR)
36
+ Rails.root.join(*self.class.storage_dir)
33
37
  end
34
38
 
35
39
  def target_file
@@ -1,3 +1,3 @@
1
1
  module EasyInvoices
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_invoices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kairat Zhumaniyazov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-27 00:00:00.000000000 Z
11
+ date: 2020-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wicked_pdf
@@ -115,6 +115,7 @@ files:
115
115
  - lib/easy_invoices.rb
116
116
  - lib/easy_invoices/act.rb
117
117
  - lib/easy_invoices/base.rb
118
+ - lib/easy_invoices/configuration.rb
118
119
  - lib/easy_invoices/generator.rb
119
120
  - lib/easy_invoices/includer.rb
120
121
  - lib/easy_invoices/invoice.rb