Module: FlossFunding
- Defined in:
- lib/floss_funding/silent.rb,
lib/floss_funding/poke.rb,
lib/floss_funding/check.rb,
lib/floss_funding/config.rb,
lib/floss_funding/version.rb,
lib/floss_funding/constants.rb,
lib/floss_funding/under_bar.rb,
lib/floss_funding.rb
Overview
Now declare some constants
Defined Under Namespace
Modules: Check, Config, Constants, Poke, Silent, UnderBar, Version Classes: Error
Constant Summary collapse
- FREE_AS_IN_BEER =
Unpaid activation option intended for open-source and not-for-profit use.
"Free-as-in-beer"
- BUSINESS_IS_NOT_GOOD_YET =
Unpaid activation option acknowledging commercial use without payment.
"Business-is-not-good-yet"
- NOT_FINANCIALLY_SUPPORTING =
Activation option to explicitly opt out of funding prompts for a namespace.
"Not-financially-supporting"
- START_MONTH =
First month index against which base words are validated.
Do not change once released as it would invalidate existing activation keys. Month.new(2025, 7).to_i
- BASE_WORDS_PATH =
Absolute path to the base words list used for paid activation validation.
File.("../../base.txt", __FILE__)
- EIGHT_BYTES =
Number of hex characters required for a paid activation key (64 = 256 bits).
64
- HEX_LICENSE_RULE =
Format for a paid activation key (64 hex chars).
/\A[0-9a-fA-F]{#{EIGHT_BYTES}}\z/
- FOOTER =
Footer text appended to messages shown to users when activation is missing
or invalid. Includes gem version and attribution. <<-FOOTER ===================================================================================== - Please buy FLOSS "peace-of-mind" activation keys to support open source developers. floss_funding v#{::FlossFunding::Version::VERSION} is made with ❤️ in 🇺🇸 & 🇮🇩 by Galtzo FLOSS (galtzo.com) FOOTER
Class Attribute Summary collapse
-
.mutex ⇒ Object
readonly
Provides access to the mutex for thread synchronization.
Class Method Summary collapse
-
.activated ⇒ Array<String>
New name: activated (preferred).
-
.activated=(value) ⇒ Object
New name: activated= (preferred).
-
.activation_occurrences ⇒ Array<String>
Thread-safe getter for all activation occurrences (each successful activation event).
-
.add_activated(library) ⇒ Object
Thread-safely adds a library to the activated list Ensures no duplicates are added.
-
.add_activation_occurrence(namespace) ⇒ Object
Record a single activation occurrence (may include duplicates per namespace).
-
.add_unactivated(library) ⇒ Object
Thread-safely adds a library to the unactivated list Ensures no duplicates are added.
-
.base_words(num_valid_words) ⇒ Array<String>
Reads the first N lines from the base words file to validate paid activation keys.
-
.configuration(library) ⇒ Hash
Thread-safe getter for a specific library’s configuration.
-
.configurations ⇒ Hash
Thread-safe accessor for the configurations hash Returns a duplicate to prevent external modification.
-
.env_var_name_for(library) ⇒ String?
Thread-safe getter for ENV var name used by a library.
-
.env_var_names ⇒ Hash{String=>String}
Thread-safe getter for all ENV var names.
-
.set_configuration(library, config) ⇒ Object
Thread-safe setter for a library’s configuration.
-
.set_env_var_name(library, env_var_name) ⇒ Object
Thread-safe setter for ENV var name used by a library.
-
.unactivated ⇒ Array<String>
New name: unactivated (preferred).
-
.unactivated=(value) ⇒ Object
New name: unactivated= (preferred).
Class Attribute Details
.mutex ⇒ Object (readonly)
Provides access to the mutex for thread synchronization
76 77 78 |
# File 'lib/floss_funding.rb', line 76 def mutex @mutex end |
Class Method Details
.activated ⇒ Array<String>
New name: activated (preferred)
80 81 82 |
# File 'lib/floss_funding.rb', line 80 def activated mutex.synchronize { @activated.dup } end |
.activated=(value) ⇒ Object
New name: activated= (preferred)
86 87 88 |
# File 'lib/floss_funding.rb', line 86 def activated=(value) mutex.synchronize { @activated = value } end |
.activation_occurrences ⇒ Array<String>
Thread-safe getter for all activation occurrences (each successful activation event)
171 172 173 |
# File 'lib/floss_funding.rb', line 171 def activation_occurrences mutex.synchronize { @activation_occurrences.dup } end |
.add_activated(library) ⇒ Object
Thread-safely adds a library to the activated list
Ensures no duplicates are added
105 106 107 |
# File 'lib/floss_funding.rb', line 105 def add_activated(library) mutex.synchronize { @activated << library unless @activated.include?(library) } end |
.add_activation_occurrence(namespace) ⇒ Object
Record a single activation occurrence (may include duplicates per namespace)
177 178 179 |
# File 'lib/floss_funding.rb', line 177 def add_activation_occurrence(namespace) mutex.synchronize { @activation_occurrences << namespace } end |
.add_unactivated(library) ⇒ Object
Thread-safely adds a library to the unactivated list
Ensures no duplicates are added
112 113 114 |
# File 'lib/floss_funding.rb', line 112 def add_unactivated(library) mutex.synchronize { @unactivated << library unless @unactivated.include?(library) } end |
.base_words(num_valid_words) ⇒ Array<String>
Reads the first N lines from the base words file to validate paid activation keys.
185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/floss_funding.rb', line 185 def base_words(num_valid_words) return [] if num_valid_words.nil? || num_valid_words.zero? File.open(::FlossFunding::BASE_WORDS_PATH, "r") do |file| lines = [] num_valid_words.times do line = file.gets break if line.nil? lines << line.chomp end lines end end |
.configuration(library) ⇒ Hash
Thread-safe getter for a specific library’s configuration
126 127 128 |
# File 'lib/floss_funding.rb', line 126 def configuration(library) mutex.synchronize { @configurations[library].dup } end |
.configurations ⇒ Hash
Thread-safe accessor for the configurations hash
Returns a duplicate to prevent external modification
119 120 121 |
# File 'lib/floss_funding.rb', line 119 def configurations mutex.synchronize { @configurations.dup } end |
.env_var_name_for(library) ⇒ String?
Thread-safe getter for ENV var name used by a library
159 160 161 |
# File 'lib/floss_funding.rb', line 159 def env_var_name_for(library) mutex.synchronize { @env_var_names[library] } end |
.env_var_names ⇒ Hash{String=>String}
Thread-safe getter for all ENV var names
165 166 167 |
# File 'lib/floss_funding.rb', line 165 def env_var_names mutex.synchronize { @env_var_names.dup } end |
.set_configuration(library, config) ⇒ Object
Thread-safe setter for a library’s configuration
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/floss_funding.rb', line 133 def set_configuration(library, config) mutex.synchronize do existing = @configurations[library] merged = {} # Ensure all known keys are arrays and merged keys = (existing.keys + config.keys).uniq keys.each do |k| merged[k] = [] merged[k].concat(Array(existing[k])) if existing.key?(k) merged[k].concat(Array(config[k])) if config.key?(k) merged[k] = merged[k].compact.flatten.uniq end @configurations[library] = merged end end |
.set_env_var_name(library, env_var_name) ⇒ Object
Thread-safe setter for ENV var name used by a library
152 153 154 |
# File 'lib/floss_funding.rb', line 152 def set_env_var_name(library, env_var_name) mutex.synchronize { @env_var_names[library] = env_var_name } end |
.unactivated ⇒ Array<String>
New name: unactivated (preferred)
92 93 94 |
# File 'lib/floss_funding.rb', line 92 def unactivated mutex.synchronize { @unactivated.dup } end |
.unactivated=(value) ⇒ Object
New name: unactivated= (preferred)
98 99 100 |
# File 'lib/floss_funding.rb', line 98 def unactivated=(value) mutex.synchronize { @unactivated = value } end |