lease 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +19 -16
- data/app/uploaders/lease/document_uploader.rb +12 -31
- data/lib/lease/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a86858ad2b1be09213786c6cc31a387d9fd221f235c94a4764ab985928c1c63a
|
4
|
+
data.tar.gz: bc95fa3227d60b838810a8454a2e6c83607e7b73061ccc9d7b33beb75059b309
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb7f44f7dbc8ad2e79ad09ecb4a1e17b441cf7aac24918bb77e99f47f1e1a92d0ae78d241b3f79134b8e9c13f4d4353d79d63ba19d17a051936d457ce393f9e0
|
7
|
+
data.tar.gz: 667cf07b65a1f501d956227c2cab3bd99f653a29298377dc253f925629612de583fe430dd959baeba721bb79c57254c7d181695a0fa635ea2753674df74dc213
|
data/README.md
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
Simplify the lease pdf/html management. Specially designed for a real estate self-storage project.
|
4
4
|
|
5
5
|
## Usage
|
6
|
-
1.
|
6
|
+
1. Add the gem to your gemfile.
|
7
|
+
`gem lease, '>= 0.1.1'`
|
8
|
+
2. `rails g lease:install`
|
7
9
|
`rake db:migrate`
|
8
|
-
|
9
|
-
2. On any model you want to treat as a "signer" of an envelope/template, add `lease_signable`:
|
10
|
+
3. On any model you want to treat as a "signer" of an envelope/template, add `lease_signable`:
|
10
11
|
```ruby
|
11
12
|
class User < ApplicationRecord
|
12
13
|
|
@@ -14,7 +15,7 @@ class User < ApplicationRecord
|
|
14
15
|
|
15
16
|
end
|
16
17
|
```
|
17
|
-
|
18
|
+
4. On any model you want treat as a leasing property, add `lease_envelopable`:
|
18
19
|
```ruby
|
19
20
|
class Occupancy < ApplicationRecord
|
20
21
|
|
@@ -22,27 +23,29 @@ class Occupancy < ApplicationRecord
|
|
22
23
|
|
23
24
|
end
|
24
25
|
```
|
25
|
-
|
26
|
+
5. You can now call some methods like:
|
26
27
|
```ruby
|
27
|
-
user = User.new(full_name:'Jason Smolar')
|
28
|
-
occupancy = Occupancy.new
|
28
|
+
user = User.new(full_name:'Jason Smolar') # the signable model
|
29
|
+
occupancy = Occupancy.new # the leasable model
|
29
30
|
template = Lease::Template.create(state: 'CA', template: File.open('/tmp/ca_lease_template.html'))
|
30
31
|
envelope = user.create_envelope(template: template, envelopable: occupancy)
|
31
|
-
|
32
|
-
|
32
|
+
|
33
|
+
# hash of variables to be interpolated into html file. Pass html id to hash key.
|
34
|
+
vars = {
|
35
|
+
rental_price: '$12', # there's an html DOM in the template with the id 'rental_price'
|
33
36
|
...
|
34
37
|
}
|
35
38
|
if user.has_unsigned_lease?
|
36
39
|
envelope = user.envelopes.unsigned.first
|
37
|
-
envelope.unsigned_html(vars)
|
40
|
+
envelope.unsigned_html(vars) # returns html without tenant sign
|
38
41
|
envelope.with_unsigned_pdf(vars) do |pdf_file|
|
39
|
-
pdf_file.read
|
42
|
+
pdf_file.read # pdf_file will be closed after this block
|
40
43
|
end
|
41
|
-
envelope.unsigned?
|
42
|
-
|
43
|
-
envelope.sign(vars)
|
44
|
-
envelope.signed_pdf
|
45
|
-
envelope.signed?
|
44
|
+
envelope.unsigned? # true
|
45
|
+
|
46
|
+
envelope.sign(vars) # Generate and returns the signed pdf. PDF is stored in
|
47
|
+
envelope.signed_pdf # Carrierwave::Storage::File
|
48
|
+
envelope.signed? # true
|
46
49
|
end
|
47
50
|
```
|
48
51
|
## Development
|
@@ -1,13 +1,16 @@
|
|
1
1
|
module Lease
|
2
|
-
class DocumentUploader <
|
2
|
+
class DocumentUploader < CarrierWave::Uploader::Base
|
3
3
|
|
4
4
|
# Include RMagick or MiniMagick support:
|
5
5
|
# include CarrierWave::RMagick
|
6
6
|
# include CarrierWave::MiniMagick
|
7
7
|
|
8
8
|
# Choose what kind of storage to use for this uploader:
|
9
|
-
|
10
|
-
|
9
|
+
if Rails.application.config.enable_s3
|
10
|
+
storage :fog
|
11
|
+
else
|
12
|
+
storage :file
|
13
|
+
end
|
11
14
|
|
12
15
|
# Override the directory where uploaded files will be stored.
|
13
16
|
# This is a sensible default for uploaders that are meant to be mounted:
|
@@ -15,37 +18,15 @@ module Lease
|
|
15
18
|
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
16
19
|
end
|
17
20
|
|
18
|
-
# Provide a default URL as a default if there hasn't been a file uploaded:
|
19
|
-
# def default_url(*args)
|
20
|
-
# # For Rails 3.1+ asset pipeline compatibility:
|
21
|
-
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
22
|
-
#
|
23
|
-
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
24
|
-
# end
|
25
|
-
|
26
|
-
# Process files as they are uploaded:
|
27
|
-
# process scale: [200, 300]
|
28
|
-
#
|
29
|
-
# def scale(width, height)
|
30
|
-
# # do something
|
31
|
-
# end
|
32
|
-
|
33
|
-
# Create different versions of your uploaded files:
|
34
|
-
# version :thumb do
|
35
|
-
# process resize_to_fit: [50, 50]
|
36
|
-
# end
|
37
|
-
|
38
21
|
# Add a white list of extensions which are allowed to be uploaded.
|
39
22
|
# For images you might use something like this:
|
40
|
-
def
|
41
|
-
%w
|
23
|
+
def extension_white_list
|
24
|
+
%w[html htm pdf]
|
42
25
|
end
|
43
26
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
# end
|
49
|
-
|
27
|
+
def self.mime_type_white_list
|
28
|
+
types = ['text/html', 'application/pdf']
|
29
|
+
types.join(', ')
|
30
|
+
end
|
50
31
|
end
|
51
32
|
end
|
data/lib/lease/version.rb
CHANGED