Created
March 21, 2017 14:01
-
-
Save ronan-mch/091d9f9ea790393fd4ec640fb311dc3f to your computer and use it in GitHub Desktop.
Replace fields with methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert_timestamp | alert_timestamp_dt | |
---|---|---|
update_timestamp | update_timestamp_dt | |
format | format | |
subformat | subformat_s | |
superformat | superformat_s | |
format_orig | format_orig_s | |
cluster_ids | cluster_id_ss | |
pub_date | pub_date_tis | |
pub_date_sort | pub_date_tsort | |
titles | title_ts | |
title_sort | title_sort | |
title_abbrs | title_abbr_ts | |
title_origs | title_orig_ts | |
subtitles | subtitle_ts | |
abstracts | abstract_ts | |
authors | author_ts | |
author_sort | author_sort | |
editors | editor_ts | |
supervisors | supervisor_ts | |
inventors | inventor_ts | |
orcids | orcid_ss | |
has_orcid | has_orcid_b | |
university_ids | university_id_ss | |
affiliations | affiliation_ts | |
has_publications | has_publications_b | |
pure_pub_count | pure_pub_count_i | |
research_areas | research_area_ss | |
author_affiliations | author_affiliation_ssf | |
affiliation_associations_json | affiliation_associations_json | |
is_active | is_active_b | |
affiliation_statuses | affiliation_status_ss | |
alis_keys | alis_key_ssf | |
alis_placements | alis_placement_ssf | |
journal_titles | journal_title_ts | |
journal_subtitles | journal_subtitle_ts | |
conf_titles | conf_title_ts | |
series_titles | series_title_ts | |
publishers | publisher_ts | |
publication_places | publication_place_ts | |
doi | doi_ss | |
journal_vols | journal_vol_ssf | |
journal_vol_sort | journal_vol_tsort | |
journal_issues | journal_issue_ssf | |
journal_issue_sort | journal_issue_tsort | |
journal_parts | journal_part_ssf | |
journal_part_sort | journal_part_sort | |
journal_pages | journal_page_ssf | |
journal_page_start_sort | journal_page_start_tsort | |
languages | language_ss | |
isolanguages | isolanguage_ss | |
editions | edition_ssf | |
names | name_ts | |
name_sort | name_sort | |
emails | email_ssf | |
phone_numbers | phone_number_ssf | |
mobile_numbers | mobile_number_ssf | |
person_affiliations | person_affiliations_ssf | |
bfi_publisher_nos | bfi_publisher_no_ss | |
bfi_serial_nos | bfi_serial_no_ss | |
pubmed_urls | pubmed_url_ssf | |
isi_urls | isi_url_ssf | |
person_addresses | person_address_ssf | |
orbit_ids | orbit_id_ssf | |
dissertation_dates | dissertation_date_ssf | |
toc_key | toc_key_s | |
access_condition | access_condition_s | |
scientific_level | scientific_level_s | |
review_status | review_status_s | |
submission_year | submission_year_tis | |
oa_indicator | oa_indicator_s | |
mendeley_count | mendeley_count_i | |
mendeley_normalized | mendeley_normalized_f | |
pub_date_normalized | pub_date_normalized_i | |
embargos | embargo_ssf | |
keywords | keywords_ts | |
issns | issn_ss | |
isbns | isbn_ss | |
sources | source_ss | |
source_exts | source_ext_ss | |
source_types | source_type_ss | |
source_ids | source_id_ss | |
member_ids | member_id_ss | |
lccns | lccn_ss | |
udcs | udc_ss | |
sicis | sici_ss | |
fulltext_lists | fulltext_list_ssf | |
fulltext_availabilities | fulltext_availability_ss | |
holdings | holdings_ssf | |
holdings_json | holdings_json | |
backlinks | backlink_ss | |
images | image_ssf | |
types | types_ss | |
tr_researcher_ids | tr_researcher_id_ss | |
scopus_author_ids | scopus_author_id_ss | |
cris_ids | cris_id_ss | |
patent_numbers | patent_number_ss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input = "fields.csv" | |
File.new(input, 'r').each do |l| | |
method_name, field_name = l.chomp.split(',') | |
`ag -Q 'document[:#{field_name}]' -l app spec --ruby | xargs sed -i 's/document\\[:#{field_name}\\]/document.#{method_name}/g'` | |
`ag -Q document[\'#{field_name}\'] -l app spec --ruby | xargs sed -i "s/document\\['#{field_name}'\\]/document.#{method_name}/g"` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment