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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3f2c2ce536808731ab265d729a99b377450321923bae4358393eb913163ad9d
4
- data.tar.gz: d9cccba084b9bc3c00683a46b87551c74895ba325d1c35d9b4befa4446fd8739
3
+ metadata.gz: a86858ad2b1be09213786c6cc31a387d9fd221f235c94a4764ab985928c1c63a
4
+ data.tar.gz: bc95fa3227d60b838810a8454a2e6c83607e7b73061ccc9d7b33beb75059b309
5
5
  SHA512:
6
- metadata.gz: da1539967d5f6ad2d4f389675e9cc34cf52308af15bd5ac248c31c4ea876b99d4132b9bd445e3fed42c204b4fab0602a6d49a1194009ad888154a782fedfb836
7
- data.tar.gz: a4571691e8a17c8b3c3fc82339aa424933414d4573087ac58300590fec7cf9305411067f253ae7db866323f455518ea8210185b953cb2e232f673172db84f467
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. `rails g lease:install`
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
- 3. On any model you want treat as a leasing property, add `lease_envelopable`:
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
- 4. You can now call some methods like:
26
+ 5. You can now call some methods like:
26
27
  ```ruby
27
- user = User.new(full_name:'Jason Smolar') # the signable model
28
- occupancy = Occupancy.new # the leasable model
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
- vars = { # hash of variables to be interpolated into html file. Pass html id to hash key.
32
- rental_price: '$12', # there should be a html DOM in the template file with the id 'rental_price'
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) # returns html without tenant sign
40
+ envelope.unsigned_html(vars) # returns html without tenant sign
38
41
  envelope.with_unsigned_pdf(vars) do |pdf_file|
39
- pdf_file.read # pdf_file is temporary use only and will be deleted after this block
42
+ pdf_file.read # pdf_file will be closed after this block
40
43
  end
41
- envelope.unsigned? # true
42
- # Generate and returns the signed pdf. PDF is stored in
43
- envelope.sign(vars)
44
- envelope.signed_pdf # Carrierwave::Storage::File
45
- envelope.signed? # true
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 < ::CarrierWave::Uploader::Base
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
- storage :file
10
- # storage :fog
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 extension_whitelist
41
- %w(pdf html)
23
+ def extension_white_list
24
+ %w[html htm pdf]
42
25
  end
43
26
 
44
- # Override the filename of the uploaded files:
45
- # Avoid using model.id or version_name here, see uploader/store.rb for details.
46
- # def filename
47
- # "something.jpg" if original_filename
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
@@ -1,3 +1,3 @@
1
1
  module Lease
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lease
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
  - Ninja Rails