<commit_before>#
# Author:: <NAME> <<EMAIL>>
#
# Copyright 2013-2014, <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.
#

class Chef
  class Resource::BerkshelfApi < Resource
    include Poise(container: true)
    actions(:install, :uninstall)

    attribute(:path, name_attribute: true)
    attribute(:version, kind_of: String, default: lazy { node['berkshelf-api']['version'] })
    attribute(:port, kind_of: [String, Integer], default: lazy { node['berkshelf-api']['port'] })
    attribute(:user, kind_of: String, default: lazy { node['berkshelf-api']['user'] })
    attribute(:group, kind_of: String, default: lazy { node['berkshelf-api']['group'] })
    attribute(:install_path, kind_of: String, default: lazy { node['berkshelf-api']['install_path'] })
    attribute(:log_path, kind_of: String, default: lazy { node['berkshelf-api']['log_path'] } )
    attribute(:log_verbosity, kind_of: String, equal_to: ['', '-d', '-v', '-q'], lazy { node['berkshelf-api']['log_verbosity'] })
    attribute(:git_repository, kind_of: [String, FalseClass], default: lazy { version.match(/^\d+(\.\d+(\.\d+)?)?$/) ? false : node['berkshelf-api']['git_repository'] })
    attribute(:config, option_collector: true)

    def config_path
      ::File.join(path, 'config.json')
    end

    def binary_path
      if git_repository
        ::File.join(install_path, 'vendor', 'bin', 'berks-api')
      else
        'berks-api'
      end
    end

    # Helpers to configure endpoints
    def opscode_endpoint(url = node['berkshelf-api']['opscode_url'], &block)
      berkshelf_api_opscode_endpoint url do
        url url
        instance_exec(&block) if block
      end
    end

    def chef_server_endpoint(url, client_name=nil, client_key=nil, &block)
      berkshelf_api_chef_server_endpoint url do
        url url
        client_name client_name
        client_key client_key<commit_msg>syntaxo<commit_after>#
# Author:: <NAME> <<EMAIL>>
#
# Copyright 2013-2014, <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.
#

class Chef
  class Resource::BerkshelfApi < Resource
    include Poise(container: true)
    actions(:install, :uninstall)

    attribute(:path, name_attribute: true)
    attribute(:version, kind_of: String, default: lazy { node['berkshelf-api']['version'] })
    attribute(:port, kind_of: [String, Integer], default: lazy { node['berkshelf-api']['port'] })
    attribute(:user, kind_of: String, default: lazy { node['berkshelf-api']['user'] })
    attribute(:group, kind_of: String, default: lazy { node['berkshelf-api']['group'] })
    attribute(:install_path, kind_of: String, default: lazy { node['berkshelf-api']['install_path'] })
    attribute(:log_path, kind_of: String, default: lazy { node['berkshelf-api']['log_path'] } )
    attribute(:log_verbosity, kind_of: String, equal_to: ['', '-d', '-v', '-q'], default: lazy { node['berkshelf-api']['log_verbosity'] })
    attribute(:git_repository, kind_of: [String, FalseClass], default: lazy { version.match(/^\d+(\.\d+(\.\d+)?)?$/) ? false : node['berkshelf-api']['git_repository'] })
    attribute(:config, option_collector: true)

    def config_path
      ::File.join(path, 'config.json')
    end

    def binary_path
      if git_repository
        ::File.join(install_path, 'vendor', 'bin', 'berks-api')
      else
        'berks-api'
      end
    end

    # Helpers to configure endpoints
    def opscode_endpoint(url = node['berkshelf-api']['opscode_url'], &block)
      berkshelf_api_opscode_endpoint url do
        url url
        instance_exec(&block) if block
      end
    end

    def chef_server_endpoint(url, client_name=nil, client_key=nil, &block)
      berkshelf_api_chef_server_endpoint url do
        url url
        client_name client_name
        client_key client_key
{'fraction_non_alphanumeric': 0.13587528965662524, 'fraction_numerical': 0.005055824731409311, 'mean_word_length': 4.051063829787234, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5365063', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1419, 'n_words': 410}