<commit_before>require 'osx/cocoa'
require 'mac-network'
require 'mac-network/service'

OSX.require_framework('SystemConfiguration')

class Mac::Network::Location
  attr_reader :sc_location_ref

  def self.all
    OSX::SCNetworkSetCopyAll(Mac::Network::sc_prefs).map {|l| create({:sc_location_ref => l}) }
  end

  def self.first
    all.first
  end

  def self.current
    self.new(OSX::SCNetworkSetCopyCurrent(Mac::Network::sc_prefs))
  end

  def self.exists?(location_name)
    all.each do |location|
      return true if location.name == location_name
    end
    return false
  end

  def self.find_by_name(location_name)
    all.select {|l| l.name == location_name }.first
  end

  def initialize(*args)
    options = {:sc_location_ref => nil, :name => nil}
    options.merge!(args.pop) unless args.empty?
    if options[:sc_location_ref].nil?<commit_msg>fix current location to use create<commit_after>require 'osx/cocoa'
require 'mac-network'
require 'mac-network/service'

OSX.require_framework('SystemConfiguration')

class Mac::Network::Location
  attr_reader :sc_location_ref

  def self.all
    OSX::SCNetworkSetCopyAll(Mac::Network::sc_prefs).map {|l| create({:sc_location_ref => l}) }
  end

  def self.first
    all.first
  end

  def self.current
    self.create(OSX::SCNetworkSetCopyCurrent(Mac::Network::sc_prefs))
  end

  def self.exists?(location_name)
    all.each do |location|
      return true if location.name == location_name
    end
    return false
  end

  def self.find_by_name(location_name)
    all.select {|l| l.name == location_name }.first
  end

  def initialize(*args)
    options = {:sc_location_ref => nil, :name => nil}
    options.merge!(args.pop) unless args.empty?
    if options[:sc_location_ref].nil?
{'fraction_non_alphanumeric': 0.12013729977116705, 'fraction_numerical': 0.0, 'mean_word_length': 4.174556213017752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4524458', 'n_tokens_mistral': 598, 'n_tokens_neox': 583, 'n_words': 124}