<commit_before>
module Testdroid
	module Cloud
		class CloudResource
			def initialize(uri, client,  resource_name, params= {})
			 @uri, @client, @resource_name = uri, client, resource_name
			 set_up_properties_from( params )
			end
			def inspect # :nodoc:
				"<#{self.class} @uri=#{@uri}>"
			end
			def sub_items(*items)
				items.each do |item|
				  resource = twilify item
				  uri = "#{@uri}/#{item.gsub('_', '-') }"
				  resource_class = Testdroid::Cloud.const_get resource
				  new_class = resource_class.new(uri, @client)
				  instance_variable_set( "@#{item}", new_class )
				end
				self.class.instance_eval {attr_reader *items}
			end
			def method_missing(method, *args)
				super if @updated
				set_up_properties_from(@client.get(@uri,@resource_name))
				self.send method, *args
			end
			def set_up_properties_from(hash)
				eigenclass = class << self; self; end
				hash.each do |p,v|
				  property = detwilify p
				  unless ['uri', 'client', 'updated'].include? property
					eigenclass.send :define_method, property.to_sym, &lambda {v}
				  end
				end
				@updated = !hash.keys.empty?
			  end
			
			def refresh
				raise "Can't refresh a resource without a REST Client" unless @client
				@updated = false
				set_up_properties_from(@client.get(@uri))
				self
			end
			 
			 def twilify(something)
				if something.is_a? Hash
				  Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten]
				else
				  something.to_s.split('_').map do |s|
					[s[0,1].capitalize, s[1..-1]].join
				  end.join
				end
			  end
			 def detwilify(something)
				if something.is_a? Hash
					Hash[*something.to_a.map {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten]
				else
					something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
				end
			end
		end
	end
end
<commit_msg>fixed g_sub<commit_after>
module Testdroid
	module Cloud
		class CloudResource
			def initialize(uri, client,  resource_name, params= {})
			 @uri, @client, @resource_name = uri, client, resource_name
			 set_up_properties_from( params )
			end
			def inspect # :nodoc:
				"<#{self.class} @uri=#{@uri}>"
			end
			def sub_items(*items)
				items.each do |item|
				  resource = twilify item
				  uri = "#{@uri}/#{item.to_s.gsub('_', '-') }"
				  resource_class = Testdroid::Cloud.const_get resource
				  new_class = resource_class.new(uri, @client)
				  instance_variable_set( "@#{item}", new_class )
				end
				self.class.instance_eval {attr_reader *items}
			end
			def method_missing(method, *args)
				super if @updated
				set_up_properties_from(@client.get(@uri,@resource_name))
				self.send method, *args
			end
			def set_up_properties_from(hash)
				eigenclass = class << self; self; end
				hash.each do |p,v|
				  property = detwilify p
				  unless ['uri', 'client', 'updated'].include? property
					eigenclass.send :define_method, property.to_sym, &lambda {v}
				  end
				end
				@updated = !hash.keys.empty?
			  end
			
			def refresh
				raise "Can't refresh a resource without a REST Client" unless @client
				@updated = false
				set_up_properties_from(@client.get(@uri))
				self
			end
			 
			 def twilify(something)
				if something.is_a? Hash
				  Hash[*something.to_a.map {|a| [twilify(a[0]).to_sym, a[1]]}.flatten]
				else
				  something.to_s.split('_').map do |s|
					[s[0,1].capitalize, s[1..-1]].join
				  end.join
				end
			  end
			 def detwilify(something)
				if something.is_a? Hash
					Hash[*something.to_a.map {|pair| [detwilify(pair[0]).to_sym, pair[1]]}.flatten]
				else
					something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
				end
			end
		end
	end
end

{'fraction_non_alphanumeric': 0.14200054510765875, 'fraction_numerical': 0.004360861270100845, 'mean_word_length': 3.010928961748634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '1640471', 'n_tokens_mistral': 1660, 'n_tokens_neox': 1307, 'n_words': 289}