<commit_before>#
# Cookbook Name:: java_wrapper
# Recipe:: default
#
# Copyright 2013, <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.
#
def whyrun_supported?
  true
end

action :create do
  create_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :enable do
  deploy_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :start do
  start_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :remove do
  remove_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end

def extract_native_lib
  # copy the native library to specified folder
  return if new_resource.native_library_dest_dir.empty?

  filename = case new_resource.wrapper_os
             when 'linux'
               'libwrapper.so'
             when 'windows'
               'wrapper.dll'
             when 'osx'
               'libwrapper.jnilib'
             end

  ark 'java_wrapper_native_lib' do
    url "http://wrapper.tanukisoftware.com/download/#{new_resource.wrapper_version}/wrapper-#{new_resource.wrapper_os}-"\
      "#{new_resource.wrapper_cpu}-#{new_resource.wrapper_bit}-#{new_resource.wrapper_version}.#{new_resource.wrapper_extension}"
    action :cherry_pick
    path new_resource.native_library_dest_dir
    creates "wrapper-#{new_resource.wrapper_os}-#{new_resource.wrapper_cpu}-#{new_resource.wrapper_bit}-"\
      "#{new_resource.wrapper_version}/lib/#{filename}"<commit_msg>Fixed: idempotency was preventing this from running twice, as was intended<commit_after>#
# Cookbook Name:: java_wrapper
# Recipe:: default
#
# Copyright 2013, <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.
#
def whyrun_supported?
  true
end

action :create do
  create_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :enable do
  deploy_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :start do
  start_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end
action :remove do
  remove_app_with_wrapper

  # My state has changed so I'd better notify observers
  new_resource.updated_by_last_action(true)
end

def extract_native_lib
  # copy the native library to specified folder
  return if new_resource.native_library_dest_dir.empty?

  filename = case new_resource.wrapper_os
             when 'linux'
               'libwrapper.so'
             when 'windows'
               'wrapper.dll'
             when 'osx'
               'libwrapper.jnilib'
             end

  ark "#{new_resource.native_library_dest_dir.gsub('/', '_')}_java_wrapper_native_lib" do
    url "http://wrapper.tanukisoftware.com/download/#{new_resource.wrapper_version}/wrapper-#{new_resource.wrapper_os}-"\
      "#{new_resource.wrapper_cpu}-#{new_resource.wrapper_bit}-#{new_resource.wrapper_version}.#{new_resource.wrapper_extension}"
    action :cherry_pick
    path new_resource.native_library_dest_dir
    creates "wrapper-#{new_resource.wrapper_os}-#{new_resource.wrapper_cpu}-#{new_resource.wrapper_bit}-"\
      "#{new_resource.wrapper_version}/lib/#{filename}"
{'fraction_non_alphanumeric': 0.08171994597028366, 'fraction_numerical': 0.0036019810895992796, 'mean_word_length': 4.020338983050848, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6846642', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1289, 'n_words': 388}