From 3db595f602ea08c2ef7157120487da1abc65a34b Mon Sep 17 00:00:00 2001 From: lkv Date: Thu, 9 Oct 2014 13:53:39 +0600 Subject: [PATCH] Replace console-based file search with Dir.glob --- .gitignore | 3 ++- lib/wordnik/configuration.rb | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8976b9e..a6143d6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ pkg/* *.gem .bundle USAGE.md -spec/vcr/* \ No newline at end of file +spec/vcr/* +.idea/* \ No newline at end of file diff --git a/lib/wordnik/configuration.rb b/lib/wordnik/configuration.rb index 13f54c0..fde6130 100644 --- a/lib/wordnik/configuration.rb +++ b/lib/wordnik/configuration.rb @@ -44,11 +44,11 @@ def initialize @user_agent = "ruby-#{Wordnik::VERSION}" # Build the default set of resource names from the filenames of the API documentation begin - api_docs_path = File.join(File.dirname(__FILE__), "../../api_docs") - @resource_names = `find #{api_docs_path} -name '*.json'`.split("\n").map {|f| f.split("/").last.sub('.json', '') }.sort + api_docs_path = File.join(File.dirname(__FILE__), '../../api_docs') + @resource_names = Dir.glob(File.join(api_docs_path, '*.json')).map {|f| f.split('/').last.sub('.json', '') }.sort true rescue - raise "Problem loading the resource files in ./api_docs/" + raise 'Problem loading the resource files in ./api_docs/' end end