code0-license 0.2.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58f84fcd4c3ba444e2b5c22ba55e7b995b61254815f08743ad18a2851cfe335f
4
- data.tar.gz: 945497d44a33b64539d98d39183eb2c5f83a36f4d03748be2c108f800bf775b3
3
+ metadata.gz: 40b0c32aa435aa020ec267d3946ea3701bc8e581004ccefe37abcf04e08cdfb8
4
+ data.tar.gz: 5219aacaae6db52ea1c885d250c89dd3cad6bc7430326d790eecf66f4c0943b6
5
5
  SHA512:
6
- metadata.gz: d3a0196b5a041a75638280cbc84ec8f80e612efd4207fac969748ecf7f1d6c7e83c3848b422f27b4ecc10dea22af940694226efe0f705a8dc268c0bf7b824315
7
- data.tar.gz: 425ae6074bf97210643a8fe21811f67471cc736fcc9d19a5af105f065de18c782991b9176ed00a306f15dd445627b4ae5d16c1d9d2d7c750d256d049acb8aff9
6
+ metadata.gz: 7353b46da78ca6d8ea3608120ef895c0148486c0700f6cf0ab4dcb36f8ef6d0833c9356a43372e1380c84645f2354e4446a8f61adad4f83613b9bebb13014e0b
7
+ data.tar.gz: caa6df4e58e9ae251ea43928feee55005acea1df32464a7d88382433d1a654ea99fbe72df59501454fd15f7959bd5637764b4c6ea15f7622d0bf7fb6bd59aad2
data/.rubocop.yml CHANGED
@@ -34,3 +34,6 @@ Layout/LineLength:
34
34
 
35
35
  RSpec/ExampleLength:
36
36
  Enabled: false
37
+
38
+ RSpec/MultipleMemoizedHelpers:
39
+ Enabled: false
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.2.2
1
+ ruby 3.4.7
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code0-license (0.2.0)
4
+ code0-license (0.4.0)
5
+ base64 (~> 0.3.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  ast (2.4.2)
11
+ base64 (0.3.0)
10
12
  diff-lcs (1.5.1)
11
13
  json (2.7.2)
12
14
  language_server-protocol (3.17.0.3)
data/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2023-2026 Code0 UG (haftungsbeschränkt)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ AI Usage Restriction: Notwithstanding the permissions granted above, this Software and its source code may not be used, in whole or in part, for the purpose of training, fine-tuning, or developing artificial intelligence (AI) models or machine learning algorithms without prior written consent from the Copyright Holder.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -32,11 +32,11 @@ Code0::License.encryption_key = private_key
32
32
  # create a license
33
33
  license = Code0::License.new(
34
34
  {
35
- 'licensee' => { 'company' => 'Code0' }, # content of licensee can be as you want, it just can't be empty
36
- 'start_date' => '2024-05-01', # when is the first date where this license is valid?
37
- 'end_date' => '2025-05-01', # until when is the license valid?
38
- 'restrictions' => {}, # content can be as you wish, can be used to semantically store some restrictions that are evaluated by your application
39
- 'options' => {}, # content can be as you wish, can be used to semantically provide some options of this license
35
+ licensee: { company: 'Code0' }, # content of licensee can be as you want, it just can't be empty
36
+ start_date: '2024-05-01', # when is the first date where this license is valid?
37
+ end_date: '2025-05-01', # until when is the license valid?
38
+ restrictions: {}, # content can be as you wish, can be used to semantically store some restrictions that are evaluated by your application
39
+ options: {}, # content can be as you wish, can be used to semantically provide some options of this license
40
40
  }
41
41
  )
42
42
 
@@ -59,10 +59,10 @@ Code0::License.encryption_key = public_key
59
59
  # load the license
60
60
  license = Code0::License.load(File.read('license.txt'))
61
61
 
62
- # exit if license is valid or outside of the valid time
62
+ # exit if license is not valid or outside of the valid time
63
63
  exit unless license.valid?
64
64
  exit unless license.in_active_time?
65
65
 
66
66
  # for example, exit if users exceed licensed amount
67
- exit if User.count > license.restrictions['user_count']
67
+ exit if license.restricted?(:user_count) && User.count > license.restrictions[:user_count]
68
68
  ```
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Code0
4
4
  class License
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.0"
6
6
  end
7
7
  end
data/lib/code0/license.rb CHANGED
@@ -47,6 +47,7 @@ module Code0
47
47
  ATTRIBUTES = %i[
48
48
  start_date
49
49
  end_date
50
+ grace_period_days
50
51
  licensee
51
52
  restrictions
52
53
  options
@@ -61,16 +62,17 @@ module Code0
61
62
  return false if !licensee || !licensee.is_a?(Hash) || licensee.empty?
62
63
  return false if !start_date || !start_date.is_a?(Date)
63
64
  return false if (!end_date || !end_date.is_a?(Date)) && !options[:allow_missing_end_date]
65
+ return false if grace_period_days.nil? || !grace_period_days.is_a?(Integer)
64
66
 
65
67
  true
66
68
  end
67
69
 
68
- def in_active_time?
70
+ def in_active_time?(allow_grace_period: true)
69
71
  return false if start_date > Date.today
70
72
  return true if !end_date && options[:allow_missing_end_date]
71
73
  return false if !end_date && !options[:allow_missing_end_date]
72
74
 
73
- end_date >= Date.today
75
+ end_date + (allow_grace_period ? grace_period_days : 0) >= Date.today
74
76
  end
75
77
 
76
78
  def restricted?(attribute)
@@ -92,6 +94,7 @@ module Code0
92
94
  send("#{property}=", value)
93
95
  end
94
96
 
97
+ send("grace_period_days=", data[:grace_period_days] || 0)
95
98
  send("licensee=", data[:licensee])
96
99
  send("restrictions=", data[:restrictions] || {})
97
100
  send("options=", data[:options] || {})
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code0-license
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklas van Schrick
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-05-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: base64
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.3.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.3.0
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: rake
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +93,6 @@ dependencies:
80
93
  - - "~>"
81
94
  - !ruby/object:Gem::Version
82
95
  version: '2.29'
83
- description:
84
96
  email:
85
97
  - mc.taucher2003@gmail.com
86
98
  executables: []
@@ -92,7 +104,7 @@ files:
92
104
  - ".tool-versions"
93
105
  - Gemfile
94
106
  - Gemfile.lock
95
- - LICENSE.txt
107
+ - LICENSE
96
108
  - README.md
97
109
  - Rakefile
98
110
  - keys/.keep
@@ -111,7 +123,6 @@ metadata:
111
123
  source_code_uri: https://github.com/code0-tech/code0-license
112
124
  changelog_uri: https://github.com/code0-tech/code0-license/releases
113
125
  rubygems_mfa_required: 'true'
114
- post_install_message:
115
126
  rdoc_options: []
116
127
  require_paths:
117
128
  - lib
@@ -126,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
137
  - !ruby/object:Gem::Version
127
138
  version: '0'
128
139
  requirements: []
129
- rubygems_version: 3.4.10
130
- signing_key:
140
+ rubygems_version: 3.6.9
131
141
  specification_version: 4
132
142
  summary: code0-license is used to validate software licenses
133
143
  test_files: []
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2024 Niklas van Schrick
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.