repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/test/formatters/test_matrix.rb | test/formatters/test_matrix.rb | require "test_helper"
require "matrix"
class TestRooFormatterMatrix < Minitest::Test
def test_matrix
expected_result = Matrix[
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0],
[7.0, 8.0, 9.0]
]
with_each_spreadsheet(name: "matrix", format: :openoffice) do |workbook|
workbook.default_sheet = work... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/test/formatters/test_csv.rb | test/formatters/test_csv.rb | require "test_helper"
class TestRooFormatterCSV < Minitest::Test
def test_date_time_to_csv
with_each_spreadsheet(name: "time-test") do |workbook|
Dir.mktmpdir do |tempdir|
csv_output = File.join(tempdir, "time_test.csv")
assert workbook.to_csv(csv_output)
assert File.exist?(csv_outp... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/test/formatters/test_yaml.rb | test/formatters/test_yaml.rb | require "test_helper"
class TestRooFormatterYAML < Minitest::Test
def test_date_time_yaml
name = "time-test"
expected = File.open(TESTDIR + "/expected_results/#{name}.yml").read
with_each_spreadsheet(name: name) do |workbook|
assert_equal expected, workbook.to_yaml
end
end
def test_bug_to_... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/test/formatters/test_xml.rb | test/formatters/test_xml.rb | require "test_helper"
class TestRooFormatterXML < Minitest::Test
def test_to_xml
expected_sheet_count = 5
options = { name: "numbers1", encoding: "utf8" }
with_each_spreadsheet(options) do |workbook|
skip if defined? JRUBY_VERSION
workbook.to_xml
sheetname = workbook.sheets.first
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/helpers.rb | spec/helpers.rb | module Helpers
def yaml_entry(row,col,type,value)
"cell_#{row}_#{col}: \n row: #{row} \n col: #{col} \n celltype: #{type} \n value: #{value} \n"
end
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/spec_helper.rb | spec/spec_helper.rb | require 'simplecov'
require 'roo'
require 'helpers'
RSpec.configure do |c|
c.include Helpers
c.color = true
c.formatter = :documentation if ENV["USE_REPORTERS"]
original_stderr = $stderr
original_stdout = $stdout
c.before(:all) do
# Redirect stderr and stdout
$stderr = File.open(File::NULL, "w")
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo_spec.rb | spec/lib/roo_spec.rb | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false | |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/weak_instance_cache_spec.rb | spec/lib/roo/weak_instance_cache_spec.rb | require 'spec_helper'
if RUBY_PLATFORM == "java"
require 'java'
java_import 'java.lang.System'
end
describe Roo::Helpers::WeakInstanceCache do
let(:klass) do
Class.new do
include Roo::Helpers::WeakInstanceCache
def memoized_data
instance_cache(:@memoized_data) do
"Some Costly ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/openoffice_spec.rb | spec/lib/roo/openoffice_spec.rb | require 'spec_helper'
describe Roo::OpenOffice do
describe '.new' do
subject do
Roo::OpenOffice.new('test/files/numbers1.ods')
end
it 'creates an instance' do
expect(subject).to be_a(Roo::OpenOffice)
end
context 'for float/integer values' do
context 'integer without point' do
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/libreoffice_spec.rb | spec/lib/roo/libreoffice_spec.rb | require 'spec_helper'
describe Roo::LibreOffice do
describe '.new' do
subject do
Roo::LibreOffice.new('test/files/numbers1.ods')
end
it 'creates an instance' do
expect(subject).to be_a(Roo::LibreOffice)
end
end
describe '#sheets' do
let(:path) { 'test/files/hidden_sheets.ods' }
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/csv_spec.rb | spec/lib/roo/csv_spec.rb | require 'spec_helper'
describe Roo::CSV do
let(:path) { 'test/files/csvtypes.csv' }
let(:csv) { Roo::CSV.new(path) }
describe '.new' do
it 'creates an instance' do
expect(csv).to be_a(Roo::CSV)
end
end
describe '.new with stream' do
let(:csv) { Roo::CSV.new(File.read(path)) }
it 'crea... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/utils_spec.rb | spec/lib/roo/utils_spec.rb | require 'spec_helper'
RSpec.describe ::Roo::Utils do
subject { described_class }
context '#number_to_letter' do
described_class::LETTERS.each_with_index do |letter, index|
it "should return '#{ letter }' when passed #{ index + 1 }" do
expect(described_class.number_to_letter(index + 1)).to eq(let... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/strict_spec.rb | spec/lib/roo/strict_spec.rb | require 'spec_helper'
describe Roo::Excelx do
subject { Roo::Excelx.new('test/files/strict.xlsx') }
example '#sheets' do
expect(subject.sheets).to eq %w(Sheet1 Sheet2)
end
example '#sheet' do
expect(subject.sheet('Sheet1')).to be_a(Roo::Excelx)
end
example '#cell' do
expect(subject.cell(1, 1... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/excelx_spec.rb | spec/lib/roo/excelx_spec.rb | # encoding: utf-8
require 'spec_helper'
describe Roo::Excelx do
subject(:xlsx) do
Roo::Excelx.new(path)
end
describe 'Constants' do
describe 'ERROR_VALUES' do
it 'returns all possible errorr values' do
expect(described_class::ERROR_VALUES).to eq(%w(#N/A #REF! #NAME? #DIV/0! #NULL! #VALUE! ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/base_spec.rb | spec/lib/roo/base_spec.rb | require 'spec_helper'
describe Roo::Base do
let(:klass) do
Class.new(Roo::Base) do
def initialize(filename, data = {})
super(filename)
@data ||= data
end
def read_cells(sheet = default_sheet)
return if @cells_read[sheet]
type_map = { String => :string, Date => :... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/spreadsheet_spec.rb | spec/lib/roo/spreadsheet_spec.rb | require 'spec_helper'
describe Roo::Spreadsheet do
describe '.open' do
context 'when the file name includes a space' do
let(:filename) { 'great scott.xlsx' }
it 'loads the proper type' do
expect(Roo::Excelx).to receive(:new).with(filename, {})
Roo::Spreadsheet.open(filename)
en... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/excelx/relationships_spec.rb | spec/lib/roo/excelx/relationships_spec.rb | # frozen_string_literal: true
require "spec_helper"
describe Roo::Excelx::Relationships do
subject(:relationships) { Roo::Excelx::Relationships.new Roo::Excelx.new(path).rels_files[0] }
describe "#include_type?" do
[
["with hyperlink type", "test/files/link.xlsx", true, false],
["with nil path", ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/excelx/format_spec.rb | spec/lib/roo/excelx/format_spec.rb | require 'spec_helper'
describe Roo::Excelx::Format do
describe '#to_type' do
FORMATS = {
'General' => :float,
'0' => :float,
'0.00' => :float,
'#,##0' => :float,
'#,##0.00' => :float,
'0%' => :percentage,
'0.00%' => :percentage,
'0.00E+00' => :float,
'# ?/?' ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/excelx/sheet_doc_spec.rb | spec/lib/roo/excelx/sheet_doc_spec.rb | # frozen_string_literal: true
require "spec_helper"
describe Roo::Excelx::SheetDoc do
subject(:blank_children) { Roo::Excelx.new("test/files/blank_children.xlsx") }
example "#last_row" do
expect(subject.last_row).to eq 3
end
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/spec/lib/roo/excelx/cell/time_spec.rb | spec/lib/roo/excelx/cell/time_spec.rb | require 'spec_helper'
RSpec.describe Roo::Excelx::Cell::Time do
it "should set the cell value to the correct number of seconds" do
value = 0.05513888888888888 # '1:19:24'
excelx_type = [:numeric_or_formula, "h:mm:ss"]
base_timestamp = Date.new(1899, 12, 30).to_time.to_i
time_cell = Roo::Excelx::Cell:... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/examples/write_me.rb | examples/write_me.rb | require 'roo'
#-- create a new spreadsheet within your google-spreadsheets and paste
#-- the 'key' parameter in the spreadsheet URL
MAXTRIES = 1000
print "what's your name? "
my_name = gets.chomp
print 'where do you live? '
my_location = gets.chomp
print 'your message? (if left blank, only your name and location will ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/examples/roo_soap_server.rb | examples/roo_soap_server.rb | require 'roo'
require 'soap/rpc/standaloneServer'
NS = 'spreadsheetserver' # name of your service = namespace
class Server2 < SOAP::RPC::StandaloneServer
def on_init
spreadsheet = OpenOffice.new('./Ferien-de.ods')
add_method(spreadsheet, 'cell', 'row', 'col')
add_method(spreadsheet, 'officeversion')
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/examples/roo_soap_client.rb | examples/roo_soap_client.rb | require 'soap/rpc/driver'
def ferien_fuer_region(proxy, region, year = nil)
proxy.first_row.upto(proxy.last_row) do |row|
if proxy.cell(row, 2) == region
jahr = proxy.cell(row, 1).to_i
if year.nil? || jahr == year
bis_datum = proxy.cell(row, 5)
if DateTime.now > bis_datum
pr... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo.rb | lib/roo.rb | # frozen_string_literal: true
require 'roo/version'
require 'roo/constants'
require 'roo/errors'
require 'roo/spreadsheet'
require 'roo/base'
module Roo
autoload :OpenOffice, 'roo/open_office'
autoload :LibreOffice, 'roo/libre_office'
autoload :Excelx, 'roo/excelx'
autoload :CSV, 'roo/csv'
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/version.rb | lib/roo/version.rb | module Roo
VERSION = "3.0.0"
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/errors.rb | lib/roo/errors.rb | module Roo
# A base error class for Roo. Most errors thrown by Roo should inherit from
# this class.
class Error < StandardError; end
# Raised when Roo cannot find a header row that matches the given column
# name(s).
class HeaderRowNotFoundError < Error; end
class FileNotFound < Error; end
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/spreadsheet.rb | lib/roo/spreadsheet.rb | require 'uri'
module Roo
class Spreadsheet
class << self
def open(path, options = {})
path = path.respond_to?(:path) ? path.path : path
extension = extension_for(path, options)
begin
Roo::CLASS_FOR_EXTENSION.fetch(extension).new(path, options)
rescue KeyError... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/font.rb | lib/roo/font.rb | module Roo
class Font
attr_accessor :bold, :italic, :underline
def bold?
@bold
end
def italic?
@italic
end
def underline?
@underline
end
end
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/utils.rb | lib/roo/utils.rb | # frozen_string_literal: true
module Roo
module Utils
extend self
LETTERS = ('A'..'Z').to_a
URI_PARSER = defined?(::URI::RFC2396_PARSER) ? ::URI::RFC2396_PARSER : ::URI::DEFAULT_PARSER
def extract_coordinate(s)
num = letter_num = 0
num_only = false
s.each_byte do |b|
if !... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/constants.rb | lib/roo/constants.rb | # frozen_string_literal: true
module Roo
ROO_EXCEL_NOTICE = "Excel support has been extracted to roo-xls due to its dependency on the GPL'd spreadsheet gem. Install roo-xls to use Roo::Excel."
ROO_EXCELML_NOTICE = "Excel SpreadsheetML support has been extracted to roo-xls. Install roo-xls to use Roo::Excel2003XM... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/csv.rb | lib/roo/csv.rb | # frozen_string_literal: true
require "csv"
require "time"
# The CSV class can read csv files (must be separated with commas) which then
# can be handled like spreadsheets. This means you can access cells like A5
# within these files.
# The CSV class provides only string objects. If you want conversions to other
# ty... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/link.rb | lib/roo/link.rb | require 'uri'
module Roo
class Link < String
# FIXME: Roo::Link inherits from String. A link cell is_a?(Roo::Link). **It is
# the only situation where a cells `value` is always a String**. Link
# cells have a nifty `to_uri` method, but this method isn't easily
# reached. (e.g. `s... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/open_office.rb | lib/roo/open_office.rb | # frozen_string_literal: true
require 'date'
require 'nokogiri'
require 'cgi'
require 'zip/filesystem'
require 'roo/font'
require 'roo/tempdir'
require 'base64'
require 'openssl'
module Roo
class OpenOffice < Roo::Base
extend Roo::Tempdir
ERROR_MISSING_CONTENT_XML = 'file missing required content.xml'
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/base.rb | lib/roo/base.rb | require "tmpdir"
require "stringio"
require "nokogiri"
require "roo/utils"
require "roo/formatters/base"
require "roo/formatters/csv"
require "roo/formatters/matrix"
require "roo/formatters/xml"
require "roo/formatters/yaml"
# Base class for all other types of spreadsheets
class Roo::Base
include Enumerable
includ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx.rb | lib/roo/excelx.rb | require 'nokogiri'
require 'zip/filesystem'
require 'roo/link'
require 'roo/tempdir'
require 'roo/utils'
require 'forwardable'
require 'set'
module Roo
class Excelx < Roo::Base
extend Roo::Tempdir
extend Forwardable
ERROR_VALUES = %w(#N/A #REF! #NAME? #DIV/0! #NULL! #VALUE! #NUM!).to_set
require 'r... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/tempdir.rb | lib/roo/tempdir.rb | module Roo
module Tempdir
def finalize_tempdirs(object_id)
if @tempdirs && (dirs_to_remove = @tempdirs[object_id])
@tempdirs.delete(object_id)
dirs_to_remove.each do |dir|
# Pass force=true to avoid an exception (and thus warnings in Ruby 3.1) if dir has
# already been re... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/libre_office.rb | lib/roo/libre_office.rb | require 'roo/open_office'
# LibreOffice is just an alias for Roo::OpenOffice class
Roo::LibreOffice = Roo::OpenOffice
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/helpers/default_attr_reader.rb | lib/roo/helpers/default_attr_reader.rb | # frozen_string_literal: true
module Roo
module Helpers
module DefaultAttrReader
def attr_reader_with_default(attr_hash)
attr_hash.each do |attr_name, default_value|
instance_variable = :"@#{attr_name}"
define_method attr_name do
if instance_variable_defined? instanc... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/helpers/weak_instance_cache.rb | lib/roo/helpers/weak_instance_cache.rb | # frozen_string_literal: true
require "weakref"
module Roo
module Helpers
module WeakInstanceCache
private
def instance_cache(key)
object = nil
if instance_variable_defined?(key) && (ref = instance_variable_get(key)) && ref.weakref_alive?
begin
object = ref.__... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/relationships.rb | lib/roo/excelx/relationships.rb | # frozen_string_literal: true
require 'roo/excelx/extractor'
module Roo
class Excelx
class Relationships < Excelx::Extractor
def [](index)
to_a[index]
end
def to_a
@relationships ||= extract_relationships
end
def include_type?(type)
to_a.any? do |_, rel|
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/workbook.rb | lib/roo/excelx/workbook.rb | require 'roo/excelx/extractor'
module Roo
class Excelx
class Workbook < Excelx::Extractor
class Label
attr_reader :sheet, :row, :col, :name
def initialize(name, sheet, row, col)
@name = name
@sheet = sheet
@row = row.to_i
@col = ::Roo::Utils.letter_t... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/comments.rb | lib/roo/excelx/comments.rb | require 'roo/excelx/extractor'
module Roo
class Excelx
class Comments < Excelx::Extractor
def comments
@comments ||= extract_comments
end
private
def extract_comments
return {} unless doc_exists?
doc.xpath('//comments/commentList/comment').each_with_object({}) d... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/styles.rb | lib/roo/excelx/styles.rb | require 'roo/font'
require 'roo/excelx/extractor'
module Roo
class Excelx
class Styles < Excelx::Extractor
# convert internal excelx attribute to a format
def style_format(style)
id = num_fmt_ids[style.to_i]
num_fmts[id] || Excelx::Format::STANDARD_FORMATS[id.to_i]
end
de... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell.rb | lib/roo/excelx/cell.rb | require 'date'
require 'roo/excelx/cell/base'
require 'roo/excelx/cell/boolean'
require 'roo/excelx/cell/datetime'
require 'roo/excelx/cell/date'
require 'roo/excelx/cell/empty'
require 'roo/excelx/cell/number'
require 'roo/excelx/cell/string'
require 'roo/excelx/cell/time'
module Roo
class Excelx
class Cell
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/format.rb | lib/roo/excelx/format.rb | # frozen_string_literal: true
module Roo
class Excelx
module Format
extend self
EXCEPTIONAL_FORMATS = {
'h:mm am/pm' => :date,
'h:mm:ss am/pm' => :date
}
STANDARD_FORMATS = {
0 => 'General',
1 => '0',
2 => '0.00',
3 => '#,##0',
4 =>... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/sheet_doc.rb | lib/roo/excelx/sheet_doc.rb | # frozen_string_literal: true
require 'forwardable'
require 'roo/excelx/extractor'
module Roo
class Excelx
class SheetDoc < Excelx::Extractor
extend Forwardable
delegate [:workbook] => :@shared
def initialize(path, relationships, shared, options = {})
super(path)
@shared = sha... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/coordinate.rb | lib/roo/excelx/coordinate.rb | module Roo
class Excelx
class Coordinate < ::Array
def initialize(row, column)
super() << row << column
freeze
end
def row
self[0]
end
def column
self[1]
end
end
end
end
| ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/extractor.rb | lib/roo/excelx/extractor.rb | # frozen_string_literal: true
require "roo/helpers/weak_instance_cache"
module Roo
class Excelx
class Extractor
include Roo::Helpers::WeakInstanceCache
COMMON_STRINGS = {
t: "t",
r: "r",
s: "s",
ref: "ref",
html_tag_open: "<html>",
html_tag_closed: "<... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/sheet.rb | lib/roo/excelx/sheet.rb | require 'forwardable'
module Roo
class Excelx
class Sheet
extend Forwardable
delegate [:styles, :workbook, :shared_strings, :rels_files, :sheet_files, :comments_files, :image_rels] => :@shared
attr_reader :images
def initialize(name, shared, sheet_index, options = {})
@name = na... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/images.rb | lib/roo/excelx/images.rb | require 'roo/excelx/extractor'
module Roo
class Excelx
class Images < Excelx::Extractor
# Returns: Hash { id1: extracted_file_name1 },
# Example: { "rId1"=>"roo_media_image1.png",
# "rId2"=>"roo_media_image2.png",
# "rId3"=>"roo_media_image3.png" }
def list
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/shared_strings.rb | lib/roo/excelx/shared_strings.rb | # frozen_string_literal: true
require 'roo/excelx/extractor'
module Roo
class Excelx
class SharedStrings < Excelx::Extractor
def [](index)
to_a[index]
end
def to_a
@array ||= extract_shared_strings
end
def to_html
@html ||= extract_html
end
# ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/shared.rb | lib/roo/excelx/shared.rb | module Roo
class Excelx
# Public: Shared class for allowing sheets to share data. This should
# reduce memory usage and reduce the number of objects being passed
# to various inititializers.
class Shared
attr_accessor :comments_files, :sheet_files, :rels_files, :image_rels, :i... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/empty.rb | lib/roo/excelx/cell/empty.rb |
module Roo
class Excelx
class Cell
class Empty < Cell::Base
attr_reader :value, :formula, :format, :cell_type, :cell_value, :coordinate
attr_reader_with_default default_type: nil, style: nil
def initialize(coordinate)
@coordinate = coordinate
end
def emp... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/time.rb | lib/roo/excelx/cell/time.rb | require 'date'
module Roo
class Excelx
class Cell
class Time < Roo::Excelx::Cell::DateTime
attr_reader :value, :formula, :format, :cell_value, :coordinate
attr_reader_with_default default_type: :time
def initialize(value, formula, excelx_type, style, link, base_date, coordinate)
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/boolean.rb | lib/roo/excelx/cell/boolean.rb | # frozen_string_literal: true
module Roo
class Excelx
class Cell
class Boolean < Cell::Base
attr_reader :value, :formula, :format, :cell_value, :coordinate
attr_reader_with_default default_type: :boolean, cell_type: :boolean
def initialize(value, formula, style, link, coordinate)
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/base.rb | lib/roo/excelx/cell/base.rb | # frozen_string_literal: true
require "roo/helpers/default_attr_reader"
module Roo
class Excelx
class Cell
class Base
extend Roo::Helpers::DefaultAttrReader
attr_reader :cell_type, :cell_value, :value
# FIXME: I think style should be deprecated. Having a style attribute
# ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/number.rb | lib/roo/excelx/cell/number.rb | # frozen_string_literal: true
module Roo
class Excelx
class Cell
class Number < Cell::Base
attr_reader :value, :formula, :format, :cell_value, :coordinate
# FIXME: change default_type to number. This will break brittle tests.
attr_reader_with_default default_type: :float
d... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/string.rb | lib/roo/excelx/cell/string.rb | module Roo
class Excelx
class Cell
class String < Cell::Base
attr_reader :value, :formula, :format, :cell_value, :coordinate
attr_reader_with_default default_type: :string, cell_type: :string
def initialize(value, formula, style, link, coordinate)
super(value, formula, ni... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/datetime.rb | lib/roo/excelx/cell/datetime.rb | # frozen_string_literal: true
require 'date'
module Roo
class Excelx
class Cell
class DateTime < Cell::Base
SECONDS_IN_DAY = 60 * 60 * 24
attr_reader :value, :formula, :format, :cell_value, :coordinate
attr_reader_with_default default_type: :datetime
def initialize(value... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/excelx/cell/date.rb | lib/roo/excelx/cell/date.rb | require 'date'
module Roo
class Excelx
class Cell
class Date < Roo::Excelx::Cell::DateTime
attr_reader :value, :formula, :format, :cell_type, :cell_value, :coordinate
attr_reader_with_default default_type: :date
def initialize(value, formula, excelx_type, style, link, base_date, c... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/formatters/xml.rb | lib/roo/formatters/xml.rb | # returns an XML representation of all sheets of a spreadsheet file
module Roo
module Formatters
module XML
def to_xml
Nokogiri::XML::Builder.new do |xml|
xml.spreadsheet do
sheets.each do |sheet|
self.default_sheet = sheet
xml.sheet(name: sheet) do ... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/formatters/yaml.rb | lib/roo/formatters/yaml.rb | module Roo
module Formatters
module YAML
# returns a rectangular area (default: all cells) as yaml-output
# you can add additional attributes with the prefix parameter like:
# oo.to_yaml({"file"=>"flightdata_2007-06-26", "sheet" => "1"})
def to_yaml(prefix = {}, from_row = nil, from_column... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/formatters/csv.rb | lib/roo/formatters/csv.rb | module Roo
module Formatters
module CSV
def to_csv(filename = nil, old_separator = nil, old_sheet = nil, separator: ",", sheet: default_sheet)
if old_separator
warn("[DEPRECATION] optional argument for separator is deprecated. Please use keyword argument :separator instead")
sepa... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/formatters/base.rb | lib/roo/formatters/base.rb | module Roo
module Formatters
module Base
# converts an integer value to a time string like '02:05:06'
def integer_to_timestring(content)
h = (content / 3600.0).floor
content -= h * 3600
m = (content / 60.0).floor
content -= m * 60
s = content
Kernel.form... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
roo-rb/roo | https://github.com/roo-rb/roo/blob/20d424f8bf96f20929a8bbf4184e059cfd029531/lib/roo/formatters/matrix.rb | lib/roo/formatters/matrix.rb | module Roo
module Formatters
module Matrix
# returns a matrix object from the whole sheet or a rectangular area of a sheet
def to_matrix(from_row = nil, from_column = nil, to_row = nil, to_column = nil, sheet = default_sheet)
require 'matrix'
return ::Matrix.empty unless first_row
... | ruby | MIT | 20d424f8bf96f20929a8bbf4184e059cfd029531 | 2026-01-04T15:52:40.549208Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/configuration_spec.rb | spec/configuration_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::Configuration do
it "is returned by MetaTags.config" do
expect(MetaTags.config).to be_instance_of(described_class)
end
it "is yielded by MetaTags.configure" do
MetaTags.configure do |c|
expect(c).to be_instance_of(descri... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/controller_helper_spec.rb | spec/controller_helper_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ControllerHelper do
subject do
MetaTagsRailsApp::MetaTagsController.new.tap do |c|
c.set_request! ActionDispatch::TestRequest.create
c.set_response! ActionDispatch::TestResponse.new
end
end
describe "module" do
... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper_spec.rb | spec/view_helper_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, type: :view_helper do
describe "returning values" do
it "returns headline if specified" do
expect(subject.title("some-title", "some-headline")).to eq("some-headline")
end
it "returns title" do
expect(su... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
if ENV["ENABLE_CODE_COVERAGE"]
require "simplecov"
require "simplecov_json_formatter"
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
SimpleCov.start do
enable_coverage :branch
end
end
require "meta_tags"
require "rspec-html-matchers"
Dir[File.expand_path("suppor... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/text_normalizer/truncate_array_spec.rb | spec/text_normalizer/truncate_array_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::TextNormalizer, ".truncate_array" do
it "returns array as is when limit is not specified" do
arr = %w[a]
expect(subject.truncate_array(arr, nil)).to be(arr)
expect(subject.truncate_array(arr, 0)).to be(arr)
end
it "returns... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/text_normalizer/normalize_description_spec.rb | spec/text_normalizer/normalize_description_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::TextNormalizer, ".normalize_description" do
let(:description) { "d" * (MetaTags.config.description_limit + 10) }
it "truncates description when limit is reached" do
expect(subject.normalize_description(description)).to eq("d" * Meta... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/text_normalizer/normalize_title_spec.rb | spec/text_normalizer/normalize_title_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::TextNormalizer, ".normalize_title" do
context "when site_title is blank" do
it "returns title when site_title is blank" do
expect(subject.normalize_title(nil, "title", "-")).to eq("title")
expect(subject.normalize_title("",... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/support/shared_examples_for_set_meta_tags.rb | spec/support/shared_examples_for_set_meta_tags.rb | # frozen_string_literal: true
shared_examples_for ".set_meta_tags" do
context "with a Hash parameter" do
it "updates meta tags" do
subject.set_meta_tags(title: "hello")
expect(subject.meta_tags[:title]).to eq("hello")
subject.set_meta_tags(title: "world")
expect(subject.meta_tags[:title]... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/support/initialize_rails.rb | spec/support/initialize_rails.rb | # frozen_string_literal: true
# Pretend we are a normal Rails application to trigger all the initializers
# that are normally happen during Rails boot process. This is done to properly
# test Railtie used by this gem to properly integrate into the Rails.
#
# TLDR. This is a real Rails application
require "logger" # R... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/support/view_helper_setup.rb | spec/support/view_helper_setup.rb | # frozen_string_literal: true
RSpec.configure do |config|
config.define_derived_metadata(file_path: %r{spec/view_helper}) do |metadata|
metadata[:type] = :view_helper
end
end
RSpec.shared_context "with an initialized view", type: :view_helper do
subject do
assigns = {}
controller = nil
MetaTagsR... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/charset_spec.rb | spec/view_helper/charset_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying charset" do
it "does not display charset if blank" do
expect(subject.display_meta_tags).to eq("")
expect(subject.display_meta_tags(charset: "")).to eq("")
end
it "displays charset" do
subject.displa... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/article_spec.rb | spec/view_helper/article_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying Article meta tags" do
it "displays meta tags specified with :article" do
subject.set_meta_tags(article: {author: "https://www.facebook.com/facebook"})
subject.display_meta_tags(site: "someSite").tap do |meta... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/description_spec.rb | spec/view_helper/description_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying description" do
it "does not display description if blank" do
subject.description("")
expect(subject.display_meta_tags).to eq("")
end
it 'displays description when "description" used' do
subject.des... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/module_spec.rb | spec/view_helper/module_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "module" do
it "is mixed into ActionView::Base" do
expect(ActionView::Base.included_modules).to include(described_class)
end
it 'responds to "title" helper' do
expect(subject).to respond_to(:title)
end
it 'res... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/links_spec.rb | spec/view_helper/links_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper do
describe "displaying canonical url" do
it "does not display canonical url by default" do
subject.display_meta_tags(site: "someSite").tap do |meta|
expect(meta).not_to have_tag("link", with: {href: "http://ex... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/title_spec.rb | spec/view_helper/title_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper do
describe "displaying title" do
it "does not display title if blank" do
expect(subject.display_meta_tags).to eq("")
subject.title("")
expect(subject.display_meta_tags).to eq("")
end
it "uses webs... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/refresh_spec.rb | spec/view_helper/refresh_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying refresh" do
it 'displays refresh when "refresh" is used' do
subject.refresh(5)
subject.display_meta_tags(site: "someSite").tap do |meta|
expect(meta).to have_tag("meta", with: {:content => "5", "http-e... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/open_graph_spec.rb | spec/view_helper/open_graph_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying Open Graph meta tags" do
it "displays meta tags specified with :open_graph" do
subject.set_meta_tags(
open_graph: {
title: "Facebook Share Title",
description: "Facebook Share Description"
... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/open_search_spec.rb | spec/view_helper/open_search_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying Open Search meta tags" do
it "displays meta tags specified with :open_search" do
subject.set_meta_tags(
open_search: {
title: "Open Search Title",
href: "/open_search_path.xml"
}
... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/noindex_spec.rb | spec/view_helper/noindex_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper do
describe "displaying noindex" do
it 'displays noindex when "noindex" used' do
subject.noindex(true)
subject.display_meta_tags(site: "someSite").tap do |meta|
expect(meta).to have_tag("meta", with: {con... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/open_tags_spec.rb | spec/view_helper/open_tags_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "meta tags" do
context "with open_meta_tags=true" do
it "generates open charset tag" do
subject.display_meta_tags(charset: "UTF-8").tap do |meta|
expect(meta).to eq('<meta charset="UTF-8">')
end
end
... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/twitter_spec.rb | spec/view_helper/twitter_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying Twitter meta tags" do
it "displays meta tags specified with :twitter" do
subject.set_meta_tags(
twitter: {
title: "Twitter Share Title",
card: "photo",
image: {
_: "http:/... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/icon_spec.rb | spec/view_helper/icon_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper do
it "does not display icon by default" do
subject.display_meta_tags(site: "someSite").tap do |meta|
expect(meta).not_to have_tag("link", with: {rel: "icon"})
end
end
it 'displays icon when "set_meta_tags" us... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/keywords_spec.rb | spec/view_helper/keywords_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper, "displaying keywords" do
it "does not display keywords if blank" do
subject.keywords("")
expect(subject.display_meta_tags).to eq("")
subject.keywords([])
expect(subject.display_meta_tags).to eq("")
end
it ... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/spec/view_helper/custom_spec.rb | spec/view_helper/custom_spec.rb | # frozen_string_literal: true
require "spec_helper"
RSpec.describe MetaTags::ViewHelper do
describe "display any named meta tag that you want to" do
it "displays testing meta tag" do
subject.display_meta_tags(testing: "this is a test").tap do |meta|
expect(meta).to have_tag("meta", with: {content:... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta-tags.rb | lib/meta-tags.rb | # frozen_string_literal: true
require "meta_tags"
| ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags.rb | lib/meta_tags.rb | # frozen_string_literal: true
require "set"
require "active_support/core_ext/hash/indifferent_access"
# MetaTags gem namespace.
module MetaTags
# Returns MetaTags gem configuration.
#
def self.config
@config ||= Configuration.new
end
# Configures MetaTags gem.
#
# @yield [Configuration] configurati... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/tag.rb | lib/meta_tags/tag.rb | # frozen_string_literal: true
module MetaTags
# Represents an HTML meta tag with no content (<tag />).
class Tag
attr_reader :name, :attributes
# Initializes a new instance of Tag class.
#
# @param [String, Symbol] name HTML tag name
# @param [Hash] attributes list of HTML tag attributes
#... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/view_helper.rb | lib/meta_tags/view_helper.rb | # frozen_string_literal: true
module MetaTags
# Contains methods to use in views and helpers.
#
module ViewHelper
# Get meta tags for the page.
def meta_tags
@meta_tags ||= MetaTagsCollection.new
end
# Set meta tags for the page.
#
# Method could be used several times, and all opti... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/content_tag.rb | lib/meta_tags/content_tag.rb | # frozen_string_literal: true
module MetaTags
# Represents an HTML meta tag with content (<tag></tag>).
# Content should be passed as a `:content` attribute.
class ContentTag < Tag
# Render tag into a Rails view.
#
# @param [ActionView::Base] view instance of a Rails view.
# @return [String] HTML... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/version.rb | lib/meta_tags/version.rb | # frozen_string_literal: true
module MetaTags
# Gem version.
VERSION = "2.22.2"
public_constant :VERSION
end
| ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/controller_helper.rb | lib/meta_tags/controller_helper.rb | # frozen_string_literal: true
module MetaTags
# Contains methods to use in controllers.
#
# You can define several instance variables to set meta tags:
# @page_title = 'Member Login'
# @page_description = 'Member login page.'
# @page_keywords = 'Site, Login, Members'
#
# Also you can use {#set_me... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/railtie.rb | lib/meta_tags/railtie.rb | # frozen_string_literal: true
module MetaTags
class Railtie < Rails::Railtie
initializer "meta_tags.setup_action_controller" do
ActiveSupport.on_load :action_controller do
include MetaTags::ControllerHelper
end
end
initializer "meta_tags.setup_action_view" do
ActiveSupport.on_l... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/configuration.rb | lib/meta_tags/configuration.rb | # frozen_string_literal: true
module MetaTags
# MetaTags configuration.
class Configuration
# How many characters to truncate title to.
attr_accessor :title_limit
# HTML attributes for the title tag.
attr_accessor :title_tag_attributes
# Truncate site_title instead of title.
attr_accessor... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
kpumuk/meta-tags | https://github.com/kpumuk/meta-tags/blob/ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb/lib/meta_tags/renderer.rb | lib/meta_tags/renderer.rb | # frozen_string_literal: true
module MetaTags
# This class is used by MetaTags gems to render HTML meta tags into page.
class Renderer
attr_reader :meta_tags, :normalized_meta_tags
# Initialized a new instance of Renderer.
#
# @param [MetaTagsCollection] meta_tags meta tags object to render.
#... | ruby | MIT | ec137b3e500c3aca2d0e9c113bf732a2dbe6b9cb | 2026-01-04T15:53:03.900592Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.