<commit_before>require 'httparty'
require 'json'
require 'cgi'
require 'uri'

module Devan
  class Client
    class HTTPClient
      include HTTParty
      headers 'User-Agent' => "Devan v#{VERSION} - Adobe CRX Client"
#      debug_output $stdout
    end

    attr_reader :url
    attr_reader :username
    attr_reader :password

    def initialize(url, username, password)
      @username = username
      @password = password

      set_url_and_path(url)
    end

    def activate(path)
      replicate(:cmd => 'Activate', :path => clean_path(path))
    end

    def deactive(path)
      replicate(:cmd => 'Deactivate', :path => clean_path(path))
    end

    def replicate(params)
      replicate_params = { :_charset => 'utf-8' }.merge!(params)
      !safe_response { http.post('/bin/replicate.json', :body => replicate_params) }.nil?
    end

    def delete(path)
      !safe_response { http.post(clean_path(path), :body => { ':operation' => 'delete' }) }.nil?
    end

    def fetch(path, depth=0)
      safe_response { http.get("#{path}.#{depth}.json") }
    end

    def store(path, properties={})
      !safe_response { http.post(path, :body => properties) }.nil?
    end

    protected

    def clean_path(path)
      path.gsub(@path, '')
    end

    def set_url_and_path(url)
      uri = URI.parse(url)
      @path = uri.path.dup
      uri.path = ''
      @url = uri.to_s
    end
<commit_msg>fixed store and better naming<commit_after>require 'httparty'
require 'json'
require 'cgi'
require 'uri'

module Devan
  class Client
    class HTTPClient
      include HTTParty
      headers 'User-Agent' => "Devan v#{VERSION} - Adobe CRX Client"
#      debug_output $stdout
    end

    attr_reader :url
    attr_reader :username
    attr_reader :password

    def initialize(url, username, password)
      @username = username
      @password = password

      set_url_and_path(url)
    end

    def activate(path)
      replicate(:cmd => 'Activate', :path => non_crx_path(path))
    end

    def deactive(path)
      replicate(:cmd => 'Deactivate', :path => non_crx_path(path))
    end

    def replicate(params)
      replicate_params = { :_charset => 'utf-8' }.merge!(params)
      !safe_response { http.post('/bin/replicate.json', :body => replicate_params) }.nil?
    end

    def delete(path)
      !safe_response { http.post(non_crx_path(path), :body => { ':operation' => 'delete' }) }.nil?
    end

    def fetch(path, depth=0)
      safe_response { http.get("#{path}.#{depth}.json") }
    end

    def store(path, properties={})
      !safe_response { http.post(non_crx_path(path), :body => properties) }.nil?
    end

    protected

    def non_crx_path(path)
      path.gsub(@path, '')
    end

    def set_url_and_path(url)
      uri = URI.parse(url)
      @path = uri.path.dup
      uri.path = ''
      @url = uri.to_s
    end

{'fraction_non_alphanumeric': 0.13211524947294448, 'fraction_numerical': 0.0014054813773717498, 'mean_word_length': 2.760898282694848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '1734260', 'n_tokens_mistral': 967, 'n_tokens_neox': 933, 'n_words': 218}