Class: Ree::Licensing::Obfuscator
- Defined in:
- lib/ree/licensing/obfuscator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source_path:, target_path:, client_id:, expires_at:, clients_dir:, exclude_files: [], stdout: $stdout) ⇒ Obfuscator
constructor
A new instance of Obfuscator.
- #run ⇒ Object
Constructor Details
#initialize(source_path:, target_path:, client_id:, expires_at:, clients_dir:, exclude_files: [], stdout: $stdout) ⇒ Obfuscator
Returns a new instance of Obfuscator.
22 23 24 25 26 27 28 29 30 |
# File 'lib/ree/licensing/obfuscator.rb', line 22 def initialize(source_path:, target_path:, client_id:, expires_at:, clients_dir:, exclude_files: [], stdout: $stdout) @source_path = File.(source_path) @target_path = File.(target_path) @client_id = client_id @expires_at = expires_at @clients_dir = clients_dir @exclude_files = exclude_files @stdout = stdout end |
Class Method Details
.run(source_path:, target_path:, client_id:, expires_at:, clients_dir:, exclude_files: [], stdout: $stdout) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ree/licensing/obfuscator.rb', line 10 def self.run(source_path:, target_path:, client_id:, expires_at:, clients_dir:, exclude_files: [], stdout: $stdout) new( source_path: source_path, target_path: target_path, client_id: client_id, expires_at: expires_at, clients_dir: clients_dir, exclude_files: exclude_files, stdout: stdout ).run end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ree/licensing/obfuscator.rb', line 32 def run start_time = Time.now store = ClientStore.new(@clients_dir) client = store.find_client(@client_id) raise Ree::Error.new("Client #{@client_id} not found in clients.json") unless client copy_project remove_spec_dirs aes_data = Encryptor.generate_aes_key aes_key = aes_data[:key] iv = aes_data[:iv] aes_key_hex = aes_key.unpack1('H*') iv_hex = iv.unpack1('H*') encrypted_count = encrypt_ruby_files(aes_key, iv) result = LicenseGenerator.generate( client_id: @client_id, private_key_pem: client['private_key_pem'], public_key_pem: client['public_key_pem'], aes_key_hex: aes_key_hex, iv_hex: iv_hex, expires_at: @expires_at ) license_path = File.join(@target_path, 'license.json') File.write(license_path, JSON.pretty_generate(result[:license_file])) store.add_license(@client_id, result[:license_record]) elapsed = (Time.now - start_time).round(2) @stdout.puts "Obfuscation complete:" @stdout.puts " Files encrypted: #{encrypted_count}" @stdout.puts " License file: #{license_path}" @stdout.puts " Time: #{elapsed}s" { encrypted_count: encrypted_count, license_path: license_path } end |