Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: renamed all caps module names to camel case #38

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
= IEV
= Iev

image:https://img.shields.io/gem/v/iev.svg["Gem Version", link="https://rubygems.org/gems/iev"]
image:https://github.com/metanorma/iev/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/iev/actions?query=workflow%3Arake"]
image:https://codeclimate.com/github/metanorma/iev/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/iev"]
image:https://img.shields.io/github/issues-pr-raw/metanorma/iev.svg["Pull Requests", link="https://github.com/metanorma/iev/pulls"]
image:https://img.shields.io/github/commits-since/metanorma/iev/latest.svg["Commits since latest",link="https://github.com/metanorma/iev/releases"]

Fetch and encode IEV term from Electropedia.
Fetch and encode Iev term from Electropedia.

== Installation

Expand All @@ -31,15 +31,15 @@ Or install it yourself as:
----
# Get term

IEV.get("103-01-02", "en")
Iev.get("103-01-02", "en")
=> "functional"

# If code not found
IEV.get("111-11-11", "en")
Iev.get("111-11-11", "en")
=> ""

# If language not found
IEV.get("103-01-02", "eee")
Iev.get("103-01-02", "eee")
=> nil
----

Expand Down
2 changes: 1 addition & 1 deletion exe/iev-glossarist
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ end
require "iev"
require "iev/cli"

IEV::CLI.start(ARGV)
Iev::Cli.start(ARGV)
6 changes: 3 additions & 3 deletions iev.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ require "iev/version"

Gem::Specification.new do |spec|
spec.name = "iev"
spec.version = IEV::VERSION
spec.version = Iev::VERSION
spec.authors = ["Ribose Inc."]
spec.email = ["open.source@ribose.com"]

spec.summary = "IEV: Fetch and encode IEV term from Electropedia"
spec.description = "IEV: Fetch and encode IEV term from Electropedia"
spec.summary = "Iev: Fetch and encode Iev term from Electropedia"
spec.description = "Iev: Fetch and encode Iev term from Electropedia"
spec.homepage = "https://github.com/metanorma/iev"
spec.license = "BSD-2-Clause"

Expand Down
7 changes: 1 addition & 6 deletions lib/iev.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
require "zeitwerk"

loader = Zeitwerk::Loader.for_gem
loader.inflector.inflect(
"cli" => "CLI",
"iev" => "IEV",
"ui" => "UI",
)
loader.setup

module IEV
module Iev
#
# Scrape Electropedia for term.
#
Expand Down
10 changes: 5 additions & 5 deletions lib/iev/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module CLI
module Iev
module Cli
def self.start(arguments)
Signal.trap("INT") do
UI.info "Signal SIGINT received, quitting!"
Ui.info "Signal SIGINT received, quitting!"
Kernel.exit(1)
end

Signal.trap("TERM") do
UI.info "Signal SIGTERM received, quitting!"
Ui.info "Signal SIGTERM received, quitting!"
Kernel.exit(1)
end

IEV::CLI::Command.start(arguments)
Iev::Cli::Command.start(arguments)
end
end
end
4 changes: 2 additions & 2 deletions lib/iev/cli/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module CLI
module Iev
module Cli
class Command < Thor
include CommandHelper

Expand Down
6 changes: 3 additions & 3 deletions lib/iev/cli/command_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module CLI
module Iev
module Cli
module CommandHelper
include CLI::UI
include Cli::Ui

protected

Expand Down
6 changes: 3 additions & 3 deletions lib/iev/cli/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module CLI
module Iev
module Cli
# @todo
# Make it thread-safe. Currently, calling UI methods from different
# threads may result with mangled output. At first glance it seems like
# something is wrong with carriage returns, but more research is needed.
module UI
module Ui
module_function

def debug(*args)
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/converter.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

module IEV
module Iev
module Converter
def self.mathml_to_asciimath(input)
IEV::Converter::MathmlToAsciimath.convert(input)
Iev::Converter::MathmlToAsciimath.convert(input)
end
end
end
2 changes: 1 addition & 1 deletion lib/iev/converter/mathml_to_asciimath.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module IEV
module Iev
module Converter
class MathmlToAsciimath
using DataConversions
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/data_conversions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
module DataConversions
refine String do
def decode_html!
Expand Down Expand Up @@ -32,7 +32,7 @@ def sanitize
end

def to_three_char_code
IEV::Iso639Code.three_char_code(self).first
Iev::Iso639Code.three_char_code(self).first
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/iev/db.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# require 'pstore'
require_relative "db_cache"

module IEV
module Iev
# Cache class.
class Db
# @param global_cache [String] filename of global DB
Expand Down Expand Up @@ -43,12 +43,12 @@ def bib_retval(entry)

# @return [Hash]
def new_bib_entry(code, lang)
IEV.get(code, lang)
Iev.get(code, lang)
end

# @param dir [String] DB dir
# @param global [TrueClass, FalseClass]
# @return [IEV::DbCache, nil]
# @return [Iev::DbCache, nil]
def open_cache_biblio(dir, global: true)
return nil if dir.nil?

Expand Down
4 changes: 2 additions & 2 deletions lib/iev/db_cache.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "fileutils"

module IEV
module Iev
class DbCache
# @return [String]
attr_reader :dir
Expand Down Expand Up @@ -73,7 +73,7 @@ def check_version?
end

# Set version of the DB to the gem version.
# @return [IEV::DbCache]
# @return [Iev::DbCache]
def set_version
File.write "#{@dir}/version", VERSION, encoding: "utf-8"
self
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/db_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
class DbWriter
include CLI::UI
include Cli::Ui
using DataConversions

attr_reader :db
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/iso_639_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
# @todo This needs to be rewritten.
class Iso639Code
COUNTRY_CODES = YAML.load(IO.read(File.join(__dir__, "iso_639_2.yaml")))
Expand All @@ -14,7 +14,7 @@ def initialize(two_char_code)
when 2
two_char_code
else
# This is to handle code "nl BE" in the IEV sheet
# This is to handle code "nl BE" in the Iev sheet
two_char_code.split(" ").first
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/iev/profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
class Profiler
attr_reader :bench, :dir, :prefix, :profile

Expand Down
4 changes: 2 additions & 2 deletions lib/iev/relaton_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

require "singleton"

module IEV
module Iev
# Relaton cach singleton.
class RelatonDb
include Singleton
include CLI::UI
include Cli::Ui

def initialize
info "Initializing Relaton..."
Expand Down
8 changes: 4 additions & 4 deletions lib/iev/source_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

# rubocop:todo Style/RedundantRegexpEscape

module IEV
module Iev
# Parses information from the spreadsheet's SOURCE column.
#
# @example
# SourceParser.new(cell_data_string).parsed_sources
class SourceParser
include CLI::UI
include Cli::Ui
include Utilities
using DataConversions

Expand Down Expand Up @@ -79,7 +79,7 @@ def extract_single_source(raw_ref)
"clause" => clause,
"link" => obtain_source_link(source_ref),
"relationship" => relation_type,
"original" => IEV::Converter.mathml_to_asciimath(
"original" => Iev::Converter.mathml_to_asciimath(
parse_anchor_tag(raw_ref, @term_domain),
),
}.compact
Expand Down Expand Up @@ -329,7 +329,7 @@ def extract_source_relationship(str)
when /(modified|modifié|modifiée|modifiés|MOD)\s*[–-]?\s+(.+)\Z/
{
"type" => type.to_s,
"modification" => IEV::Converter.mathml_to_asciimath(
"modification" => Iev::Converter.mathml_to_asciimath(
parse_anchor_tag($2, @term_domain),
).strip,
}
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/supersession_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
# Parses information from the spreadsheet's REPLACES column.
#
# @example
# SupersessionParser.new(cell_data_string).supersessions
class SupersessionParser
include CLI::UI
include Cli::Ui
using DataConversions

attr_reader :raw_str, :src_str
Expand Down
4 changes: 2 additions & 2 deletions lib/iev/term_attrs_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# (c) Copyright 2020 Ribose Inc.
#

module IEV
module Iev
# Parses information from the spreadsheet's TERMATTRIBUTE column and alike.
#
# @example
Expand All @@ -12,7 +12,7 @@ module IEV
# parser.plurality # returns grammatical plurality
# parser.part_of_speech # returns part of speech
class TermAttrsParser
include CLI::UI
include Cli::Ui
using DataConversions

attr_reader :raw_str, :src_str
Expand Down
14 changes: 7 additions & 7 deletions lib/iev/term_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

require "pp"

module IEV
module Iev
class TermBuilder
include CLI::UI
include Cli::Ui
include Utilities
using DataConversions

Expand Down Expand Up @@ -209,23 +209,23 @@ def extract_international_symbol_designation

def extract_definition_value
if @definition
IEV::Converter.mathml_to_asciimath(
Iev::Converter.mathml_to_asciimath(
replace_newlines(parse_anchor_tag(@definition, term_domain)),
).strip
end
end

def extract_examples
@examples.map do |str|
IEV::Converter.mathml_to_asciimath(
Iev::Converter.mathml_to_asciimath(
replace_newlines(parse_anchor_tag(str, term_domain)),
).strip
end
end

def extract_notes
@notes.map do |str|
IEV::Converter.mathml_to_asciimath(
Iev::Converter.mathml_to_asciimath(
replace_newlines(parse_anchor_tag(str, term_domain)),
).strip
end
Expand Down Expand Up @@ -275,7 +275,7 @@ def extract_superseded_concepts
private

def build_expression_designation(raw_term, attribute_data:, status:)
term = IEV::Converter.mathml_to_asciimath(
term = Iev::Converter.mathml_to_asciimath(
parse_anchor_tag(raw_term, term_domain),
)
term_attributes = TermAttrsParser.new(attribute_data.to_s)
Expand All @@ -299,7 +299,7 @@ def build_expression_designation(raw_term, attribute_data:, status:)
end

def build_symbol_designation(raw_term)
term = IEV::Converter.mathml_to_asciimath(
term = Iev::Converter.mathml_to_asciimath(
parse_anchor_tag(raw_term, term_domain),
)

Expand Down
Loading
Loading