<commit_before>#
# Copyright 2012, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'sinatra'
require 'json'
require 'rest_client'
require 'builder/xchar'

class Tayu < Sinatra::Base

    class << self
        attr_accessor :puppetdb_server
        attr_accessor :puppetdb_port
        attr_accessor :allowed_tags
        attr_accessor :username
    end

    ## convert to string and then to XML escaped text.
    def xml_escape(input)
        return input.to_s.to_xs
    end

    ## retrieve all nodes from puppetdb and return then as an array
    def get_nodes
	q = '["=", ["node", "active"], true]'

	if ! q.is_a? String then
		q=JSON[q]
		end
	params = {:query => q}
	puts q
	puts params

        response_nodelist = RestClient.get"http://#{Tayu.puppetdb_server}:#{Tayu.puppetdb_port}/nodes",  { :accept => :json, :params => params }
        return JSON.parse(response_nodelist)
    end 
<commit_msg>Removed some code that was left for debugging purposes.<commit_after>#
# Copyright 2012, <NAME>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'sinatra'
require 'json'
require 'rest_client'
require 'builder/xchar'

class Tayu < Sinatra::Base

    class << self
        attr_accessor :puppetdb_server
        attr_accessor :puppetdb_port
        attr_accessor :allowed_tags
        attr_accessor :username
    end

    ## convert to string and then to XML escaped text.
    def xml_escape(input)
        return input.to_s.to_xs
    end

    ## retrieve all nodes from puppetdb and return then as an array
    def get_nodes
	q = '["=", ["node", "active"], true]'

	if ! q.is_a? String then
		q=JSON[q]
		end
	params = {:query => q}

        response_nodelist = RestClient.get"http://#{Tayu.puppetdb_server}:#{Tayu.puppetdb_port}/nodes",  { :accept => :json, :params => params }
        return JSON.parse(response_nodelist)
    end 

{'fraction_non_alphanumeric': 0.09268975166142007, 'fraction_numerical': 0.005596362364463099, 'mean_word_length': 3.454828660436137, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '5846078', 'n_tokens_mistral': 885, 'n_tokens_neox': 852, 'n_words': 318}