From 10c1a016682aabdfe22d461ff751e56f8f1e5df8 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Mon, 20 Aug 2018 13:04:21 -0700 Subject: [PATCH] Remove "experiment" script and awesome_print dependency awesome_print was only used by this one exploratory script from 2012. This repo should be more production code, less developer one-offs. --- Gemfile | 1 - Gemfile.lock | 4 +- bin/experiment | 135 ------------------------------------------------- 3 files changed, 1 insertion(+), 139 deletions(-) delete mode 100755 bin/experiment diff --git a/Gemfile b/Gemfile index 75eb41893..5e965924b 100644 --- a/Gemfile +++ b/Gemfile @@ -45,7 +45,6 @@ group :deployment do end group :development do - gem 'awesome_print' gem 'listen' end diff --git a/Gemfile.lock b/Gemfile.lock index de8de31b8..2e462ea1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,7 +72,6 @@ GEM druid-tools (>= 0.2.6) nokogiri ast (2.4.0) - awesome_print (1.8.0) builder (3.2.3) bundler-audit (0.6.0) bundler (~> 1.2) @@ -434,7 +433,6 @@ DEPENDENCIES assembly-image assembly-objectfile (> 1.6.6) assembly-utils - awesome_print byebug capistrano (~> 3) capistrano-bundler @@ -470,4 +468,4 @@ DEPENDENCIES yard BUNDLED WITH - 1.16.3 + 1.16.4 diff --git a/bin/experiment b/bin/experiment deleted file mode 100755 index 24e2820a1..000000000 --- a/bin/experiment +++ /dev/null @@ -1,135 +0,0 @@ -#! /usr/bin/env ruby - -# Script for experimentation -- in the vein of bin/console. - -require File.expand_path(File.dirname(__FILE__) + '/../config/boot') - - - -__END__ - - -yaml = "--- -- - :foo: 123 - :bar: 456 -- - :foo: 22 - :bar: 44 -" - -yaml = " ---- -:action: :started -:container: B/x/image1.tif ---- -:action: :finished -:pid: druid:aa111aa1111 ---- -:action: :started -:container: B/x/image2.tif ---- -:action: :finished -:pid: druid:aa111aa2222 -" - -yf = StringIO.new yaml - -exp = [ - { :foo => 123, :bar => 456 }, - { :foo => 22, :bar => 44 }, -] - - - YAML.each_document(yf) do |ydoc| - ap ydoc - end - -__END__ - - -# puts data.to_yaml - - -# data = YAML.load(yaml) - -# ap data -# ap data == exp - -y = "--- \n" -exp.each { |dobj| - y << "-\n" - dobj.each { |k,v| - y << " :#{k}: #{v}\n" - } -} - -data = YAML.load(y) - -ap exp.to_yaml -ap data -ap data == exp - -__END__ - - -class DOMock - - def initialize(barcode) - @project_style = {} - @apo_druid_id = 'druid:sr292kr3857' - @mock_barcode = barcode - end - - def container_basename - return @mock_barcode - end - - def get_pid_from_container_barcode - return DruidMinter.next if @project_style[:use_druid_minter] - barcode = container_basename - pids = query_dor_by_barcode(barcode) - pids.each do |pid| - apos = get_dor_item_apos(pid) - return pid if apo_matches_exactly_one?(apos) - end - return nil - end - - def query_dor_by_barcode(barcode) - return Dor::SearchService.query_by_id :barcode => barcode - end - - def get_dor_item_apos(pid) - begin - item = Dor::Item.find pid - return item.admin_policy_object - rescue ActiveFedora::ObjectNotFoundError - return [] - end - end - - def apo_matches_exactly_one?(apos) - n = 0 - apos.each { |apo| n += 1 if apo.pid == @apo_druid_id } - return n == 1 - end - -end - -require 'awesome_print' - -def main(barcode_file_name, limit = nil) - n = 0 - limit = limit.to_i if limit - IO.foreach(barcode_file_name) do |barcode| - barcode.strip! - dobj = DOMock.new barcode - pid = dobj.get_pid_from_container_barcode - n += 1 - puts [n, barcode, pid].join "\t" - break if limit and n >= limit - end -end - -main *ARGV