source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/bz2_validator_spec.rb
Ruby
mit
193
master
5,812
# frozen_string_literal: true require "spec_helper" require "tempfile" require "fileutils" require "wp2txt/bz2_validator" RSpec.describe Wp2txt::Bz2Validator do let(:temp_dir) { Dir.mktmpdir } after { FileUtils.rm_rf(temp_dir) } describe ".validate" do context "with non-existent file" do it "returns...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/output_writer_spec.rb
Ruby
mit
193
master
10,910
# frozen_string_literal: true require "spec_helper" require "tempfile" require "fileutils" require "json" RSpec.describe Wp2txt::OutputWriter do let(:temp_dir) { Dir.mktmpdir } after do FileUtils.rm_rf(temp_dir) end describe "#write" do context "with text format" do it "writes text content to ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/cli_options_spec.rb
Ruby
mit
193
master
20,493
# frozen_string_literal: true require_relative "spec_helper" require_relative "../lib/wp2txt" require_relative "../lib/wp2txt/utils" # Simulate CLI app for testing options class CLITestApp include Wp2txt # Default configuration matching bin/wp2txt defaults DEFAULT_CONFIG = { title: true, heading: true,...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/magic_words_spec.rb
Ruby
mit
193
master
8,517
# frozen_string_literal: true require "spec_helper" RSpec.describe Wp2txt::MagicWordExpander do let(:title) { "Test Article" } let(:namespace) { "" } let(:dump_date) { Time.new(2024, 6, 15, 14, 30, 45) } let(:expander) { described_class.new(title, namespace: namespace, dump_date: dump_date) } describe "#ex...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/cleanup_spec.rb
Ruby
mit
193
master
6,110
# frozen_string_literal: true require_relative "spec_helper" require_relative "../lib/wp2txt/utils" RSpec.describe "Wp2txt Cleanup" do include Wp2txt describe "MediaWiki magic words" do it "removes DEFAULTSORT lines" do input = "Some text\nDEFAULTSORT:にんちけんこかく\nMore text" result = cleanup(input) ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/category_cache_spec.rb
Ruby
mit
193
master
6,663
# frozen_string_literal: true require_relative "spec_helper" require "tmpdir" require "fileutils" RSpec.describe Wp2txt::CategoryCache do let(:cache_dir) { Dir.mktmpdir("wp2txt_category_cache_test_") } let(:cache) { described_class.new("en", cache_dir: cache_dir) } after do cache.close FileUtils.rm_rf(...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/global_data_cache_spec.rb
Ruby
mit
193
master
5,292
# frozen_string_literal: true require_relative "spec_helper" require "tmpdir" require "fileutils" RSpec.describe Wp2txt::GlobalDataCache do let(:cache_dir) { Dir.mktmpdir("wp2txt_global_cache_test_") } before do described_class.configure(cache_dir: cache_dir, enabled: true) described_class.clear! end ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/spec_helper.rb
Ruby
mit
193
master
1,798
# frozen_string_literal: true require "simplecov" SimpleCov.start do add_filter "/spec/" add_group "Core", "lib/wp2txt" minimum_coverage 20 # Temporarily lowered, will increase as we add tests end require "rspec" require "stringio" # Load wp2txt modules require_relative "../lib/wp2txt" require_relative "../li...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/markers_spec.rb
Ruby
mit
193
master
17,896
# frozen_string_literal: true require_relative "spec_helper" RSpec.describe "Wp2txt Markers" do include Wp2txt describe "marker classification constants" do it "defines INLINE_MARKERS" do expect(Wp2txt::INLINE_MARKERS).to be_a(Array) expect(Wp2txt::INLINE_MARKERS).to include(:math, :chem, :ipa, :...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/multistream_spec.rb
Ruby
mit
193
master
22,334
# frozen_string_literal: true require "spec_helper" require "tempfile" require "fileutils" require "zlib" require "webmock/rspec" RSpec.describe "Wp2txt Multistream" do before do # Ensure WebMock is enabled (may be disabled by other specs) WebMock.enable! # Allow localhost connections, stub external ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/file_utils_spec.rb
Ruby
mit
193
master
4,598
# frozen_string_literal: true require "spec_helper" require "tempfile" require "fileutils" RSpec.describe "Wp2txt FileUtils" do include Wp2txt describe "collect_files" do let(:temp_dir) { Dir.mktmpdir } after { FileUtils.remove_entry(temp_dir) } it "collects all files in a directory" do # Cre...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/category_fetcher_spec.rb
Ruby
mit
193
master
13,928
# frozen_string_literal: true require_relative "spec_helper" require "webmock/rspec" require "tmpdir" require "fileutils" RSpec.describe Wp2txt::CategoryFetcher do let(:lang) { "en" } let(:category) { "Japanese cities" } let(:fetcher) { described_class.new(lang, category) } before do WebMock.enable! ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/constants_spec.rb
Ruby
mit
193
master
3,530
# frozen_string_literal: true require "spec_helper" require "tempfile" RSpec.describe "Wp2txt Constants" do describe "Time Constants" do it "defines SECONDS_PER_DAY" do expect(Wp2txt::SECONDS_PER_DAY).to eq(86_400) end it "defines SECONDS_PER_HOUR" do expect(Wp2txt::SECONDS_PER_HOUR).to eq(...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/wp2txt_spec.rb
Ruby
mit
193
master
13,566
# frozen_string_literal: true require_relative "spec_helper" require "tempfile" require "fileutils" RSpec.describe Wp2txt do let(:temp_dir) { Dir.mktmpdir } after do FileUtils.rm_rf(temp_dir) if temp_dir && Dir.exist?(temp_dir) end describe Wp2txt::Splitter do let(:sample_xml) do <<~XML ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/memory_monitor_spec.rb
Ruby
mit
193
master
6,393
# frozen_string_literal: true require "spec_helper" require "wp2txt/memory_monitor" RSpec.describe Wp2txt::MemoryMonitor do describe ".current_memory_usage" do it "returns a non-negative integer" do usage = described_class.current_memory_usage expect(usage).to be_a(Integer) expect(usage).to be...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/template_data_spec.rb
Ruby
mit
193
master
8,040
# frozen_string_literal: true require "spec_helper" RSpec.describe "MediaWiki Data" do describe "extension_tags in mediawiki_aliases.json" do before(:all) do data_path = File.join(__dir__, "..", "lib", "wp2txt", "data", "mediawiki_aliases.json") @mediawiki_data = JSON.parse(File.read(data_path)) ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/template_expander_spec.rb
Ruby
mit
193
master
15,229
# frozen_string_literal: true require "spec_helper" RSpec.describe Wp2txt::TemplateExpander do let(:expander) { described_class.new } # Fixed reference date for age calculations let(:reference_date) { Time.new(2024, 6, 15) } let(:expander_with_date) { described_class.new(reference_date: reference_date) } d...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/section_extractor_spec.rb
Ruby
mit
193
master
13,921
# frozen_string_literal: true require "spec_helper" require "tmpdir" require "fileutils" require_relative "../lib/wp2txt/article" require_relative "../lib/wp2txt/section_extractor" RSpec.describe Wp2txt::SectionExtractor do let(:sample_wiki_text) do <<~WIKI This is the summary text before any headings. ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/regex_spec.rb
Ruby
mit
193
master
9,326
# frozen_string_literal: true require_relative "spec_helper" RSpec.describe "Wp2txt MediaWiki Data Loading" do describe "load_mediawiki_data" do it "loads data from JSON file" do data = Wp2txt.load_mediawiki_data expect(data).to be_a(Hash) expect(data).to have_key("magic_words") expect(d...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/utils_spec.rb
Ruby
mit
193
master
13,369
# frozen_string_literal: true require_relative "spec_helper" RSpec.describe "Wp2txt Utils" do include Wp2txt describe "process_nested_structure" do it "parse nested structure replacing str in the format specified" do str_before1 = "[[ab[[cde[[alfa]]]]fg]]" str_after1 = "<<ab<<cde<<alfa>>>>fg>>" ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/auto_download_spec.rb
Ruby
mit
193
master
11,114
# frozen_string_literal: true require_relative "spec_helper" require "tmpdir" require_relative "../lib/wp2txt/multistream" require_relative "../lib/wp2txt/cli" RSpec.describe "Wp2txt Auto Download" do include Wp2txt describe "DumpManager" do let(:cache_dir) { File.join(Dir.tmpdir, "wp2txt_test_cache_#{Proces...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/stream_processor_spec.rb
Ruby
mit
193
master
16,135
# frozen_string_literal: true require "spec_helper" require "tempfile" require "fileutils" RSpec.describe Wp2txt::StreamProcessor do let(:temp_dir) { Dir.mktmpdir } after do FileUtils.rm_rf(temp_dir) end describe "#each_page" do context "with XML file input" do let(:xml_content) do <<~...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/template_processing_spec.rb
Ruby
mit
193
master
7,072
# frozen_string_literal: true require "spec_helper" RSpec.describe "Template Processing (Data-Driven)" do include Wp2txt # Helper to extract template name from {{...}} for testing regex def template_content(str) str.gsub(/^\{\{/, "").gsub(/\}\}$/, "") end describe "REMOVE_TEMPLATES_REGEX" do it "i...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/config_spec.rb
Ruby
mit
193
master
5,729
# frozen_string_literal: true require_relative "spec_helper" require_relative "../lib/wp2txt/config" require "tmpdir" require "fileutils" RSpec.describe Wp2txt::Config do let(:tmpdir) { Dir.mktmpdir("wp2txt_config_test_") } let(:config_path) { File.join(tmpdir, "config.yml") } after do FileUtils.rm_rf(tmpd...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
spec/integration_spec.rb
Ruby
mit
193
master
17,943
# frozen_string_literal: true require_relative "spec_helper" require_relative "fixtures/samples" RSpec.describe "Integration Tests" do include Wp2txt # Use let blocks to avoid constant redefinition warnings let(:japanese_article) { Wp2txt::TestSamples::JAPANESE_ARTICLE } let(:russian_article) { Wp2txt::TestS...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/fetch_html_entities.rb
Ruby
mit
193
master
2,766
# frozen_string_literal: true # Fetches HTML named character references from WHATWG HTML specification # Usage: ruby scripts/fetch_html_entities.rb # # This script downloads the official entities.json from WHATWG and converts # it into a format suitable for wp2txt text processing. require "net/http" require "json" re...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/benchmark_regex.rb
Ruby
mit
193
master
3,733
# frozen_string_literal: true # Benchmark script for wp2txt regex performance # Compares pre-compiled regex patterns vs inline compilation # # Usage: ruby scripts/benchmark_regex.rb require "benchmark" begin require "benchmark/ips" rescue LoadError # benchmark-ips is optional end # Add lib to load path $LOAD_PAT...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/profile_memory.rb
Ruby
mit
193
master
4,427
# frozen_string_literal: true # Memory profiling script for wp2txt streaming operations # Demonstrates the MemoryMonitor module and adaptive buffer sizing # # Usage: ruby scripts/profile_memory.rb [input_file.xml] $LOAD_PATH.unshift(File.expand_path("../lib", __dir__)) require "wp2txt" require "wp2txt/memory_monitor"...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/fetch_language_metadata.rb
Ruby
mit
193
master
5,400
# frozen_string_literal: true # Fetches Wikipedia language metadata from Wikimedia APIs # Usage: ruby scripts/fetch_language_metadata.rb # # This script queries the Wikimedia sitematrix API to get all Wikipedia # language editions and their statistics (article counts, etc.) require "net/http" require "json" require "...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/fetch_template_data.rb
Ruby
mit
193
master
5,678
# frozen_string_literal: true # Fetches template aliases and redirects from Wikipedia APIs # Usage: ruby scripts/fetch_template_data.rb # # This script augments the existing template_aliases.json by: # - Fetching redirects for known templates (to discover aliases) # - Validating that templates exist # - Merging new al...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
scripts/fetch_mediawiki_data.rb
Ruby
mit
193
master
10,139
# frozen_string_literal: true # Fetches magic words, namespace data, and interwiki info from Wikipedia APIs # Usage: ruby scripts/fetch_mediawiki_data.rb # # This script queries the MediaWiki API for all Wikipedia language editions # and extracts: # - Magic words (redirect, defaultsort, displaytitle, image options, et...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt.rb
Ruby
mit
193
master
9,626
# frozen_string_literal: true require "nokogiri" require_relative "wp2txt/article" require_relative "wp2txt/utils" require_relative "wp2txt/stream_processor" require_relative "wp2txt/output_writer" module Wp2txt class Splitter include Wp2txt attr_reader :size_read, :file_index def initialize(input_fil...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/regex.rb
Ruby
mit
193
master
23,039
# frozen_string_literal: true require "htmlentities" require "json" require_relative "global_data_cache" # Make HTMLEntities gem Ractor-shareable # This must be done before any Ractor tries to use HTMLEntities if defined?(Ractor) && Ractor.respond_to?(:make_shareable) begin HTMLEntities.constants.each do |const...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/formatter.rb
Ruby
mit
193
master
11,002
# frozen_string_literal: true require_relative "utils" require_relative "regex" require_relative "section_extractor" module Wp2txt # Article formatting utilities for WpApp module Formatter # Debug mode flag (inherited from including class if defined) def formatter_debug_mode defined?(DEBUG_MODE) ? D...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/stream_processor.rb
Ruby
mit
193
master
8,524
# frozen_string_literal: true require "nokogiri" require "stringio" require_relative "constants" require_relative "memory_monitor" require_relative "bz2_validator" module Wp2txt # StreamProcessor handles streaming decompression and XML parsing # without creating intermediate files class StreamProcessor incl...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/section_extractor.rb
Ruby
mit
193
master
13,372
# frozen_string_literal: true require "yaml" require_relative "constants" module Wp2txt # SectionExtractor handles extraction of sections from Wikipedia articles # Supports both metadata extraction (headings only) and content extraction class SectionExtractor # Reserved keyword for the lead section (text be...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/template_expander.rb
Ruby
mit
193
master
24,260
# frozen_string_literal: true module Wp2txt # Expands common MediaWiki templates to their text representation # Handles date templates, convert templates, and other common patterns class TemplateExpander MONTH_NAMES = %w[ January February March April May June July August September October Novembe...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/global_data_cache.rb
Ruby
mit
193
master
10,590
# frozen_string_literal: true require "sqlite3" require "json" require "fileutils" require "digest" module Wp2txt # SQLite-based cache for global data files (templates, mediawiki aliases, entities) # Dramatically speeds up startup by avoiding JSON parsing overhead class GlobalDataCache CACHE_VERSION = 1 ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/utils.rb
Ruby
mit
193
master
26,496
# frozen_string_literal: true require "strscan" require_relative "constants" require_relative "regex" require_relative "text_processing" require_relative "file_utils" require_relative "magic_words" require_relative "template_expander" require_relative "parser_functions" module Wp2txt # Main wiki formatting utilitie...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/extractor.rb
Ruby
mit
193
master
19,323
# frozen_string_literal: true require_relative "multistream" require_relative "cli" module Wp2txt # Article extraction utilities for WpApp module Extractor # Exit codes EXIT_SUCCESS = 0 EXIT_ERROR = 1 EXIT_PARTIAL = 2 # Extract specific articles by title def extract_specific_articles(opts...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/bz2_validator.rb
Ruby
mit
193
master
7,532
# frozen_string_literal: true require_relative "constants" module Wp2txt # Validates bz2 files for corruption and integrity # Provides early detection of corrupt files before processing module Bz2Validator # Bz2 magic bytes: "BZ" followed by version ('h') and block size ('1'-'9') BZ2_MAGIC = "BZ".freeze...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/constants.rb
Ruby
mit
193
master
4,637
# frozen_string_literal: true module Wp2txt # ========================================================================= # Custom Exception Classes # ========================================================================= # Base error class for all Wp2txt errors class Error < StandardError; end # Raised ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/file_utils.rb
Ruby
mit
193
master
2,239
# frozen_string_literal: true require "find" module Wp2txt # File operation utilities # Collect filenames recursively def collect_files(str, regex = nil) regex ||= // text_array = [] Find.find(str) do |f| text_array << f if regex =~ f end text_array.sort end # Modify a file using...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/memory_monitor.rb
Ruby
mit
193
master
7,793
# frozen_string_literal: true require "etc" module Wp2txt # Memory monitoring and adaptive buffer sizing for streaming operations # Provides utilities to track memory usage and dynamically adjust buffer sizes module MemoryMonitor # Default memory thresholds LOW_MEMORY_THRESHOLD_MB = 256 HIGH_MEMORY_...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/article.rb
Ruby
mit
193
master
8,333
# frozen_string_literal: true require 'strscan' require_relative 'utils' module Wp2txt # possible element type, which could be later chosen to print or not to print # :mw_heading # :mw_htable # :mw_quote # :mw_unordered # :mw_ordered # :mw_definition # :mw_pre # :mw_paragraph # :mw_comment # :mw...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/parser_functions.rb
Ruby
mit
193
master
15,787
# frozen_string_literal: true require "time" module Wp2txt # Evaluates MediaWiki parser functions # Handles #if, #ifeq, #switch, #expr, #ifexpr, and string functions class ParserFunctions MONTH_NAMES = %w[ January February March April May June July August September October November December ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/magic_words.rb
Ruby
mit
193
master
11,704
# frozen_string_literal: true require_relative "regex" module Wp2txt # Expands MediaWiki magic words to their actual values # Supports: page context variables, date/time variables, string functions class MagicWordExpander # Page context magic words (case-insensitive) PAGE_CONTEXT_WORDS = { "PAGENA...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/multistream.rb
Ruby
mit
193
master
44,695
# frozen_string_literal: true require "fileutils" require "json" require "net/http" require "uri" require "openssl" require "parallel" require "set" require_relative "constants" require_relative "index_cache" require_relative "category_cache" module Wp2txt # Maximum number of retries for transient network errors ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/cli.rb
Ruby
mit
193
master
13,079
# frozen_string_literal: true require "optimist" require_relative "version" require_relative "multistream" require_relative "config" require_relative "memory_monitor" module Wp2txt # CLI option parsing and validation module CLI class << self # Get the optimal number of processors for this system #...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/text_processing.rb
Ruby
mit
193
master
11,678
# frozen_string_literal: true require_relative "constants" require_relative "regex" module Wp2txt # Text processing utilities: character conversion, nested structure handling, cleanup # Cache for dynamically generated regex patterns @regex_cache = {} class << self attr_accessor :regex_cache end def ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/config.rb
Ruby
mit
193
master
4,802
# frozen_string_literal: true require "yaml" require "fileutils" module Wp2txt # Configuration management for wp2txt # Loads and saves settings from ~/.wp2txt/config.yml class Config # Default configuration file path DEFAULT_CONFIG_PATH = File.expand_path("~/.wp2txt/config.yml") # Default cache dire...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/cli_ui.rb
Ruby
mit
193
master
12,964
# frozen_string_literal: true require "pastel" require "tty-spinner" require "tty-progressbar" require_relative "constants" module Wp2txt # CLI UI helper module for consistent styling module CliUI # Exit codes for CLI EXIT_SUCCESS = 0 EXIT_ERROR = 1 EXIT_PARTIAL = 2 # Partial success (e.g., some ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/ractor_worker.rb
Ruby
mit
193
master
7,370
# frozen_string_literal: true require "etc" module Wp2txt # Ractor-based parallel processing for Wikipedia article conversion # # Ractor allows true parallelism by bypassing Ruby's GVL (Global VM Lock), # enabling significant speedups for CPU-intensive text processing. # # REQUIREMENTS: Ruby 4.0+ (Ractor ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/output_writer.rb
Ruby
mit
193
master
5,481
# frozen_string_literal: true require "json" require "fileutils" module Wp2txt # OutputWriter handles output file management with rotation # Supports both text and JSONL formats class OutputWriter # @param output_dir [String] Output directory path # @param base_name [String] Base name for output files ...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/index_cache.rb
Ruby
mit
193
master
7,211
# frozen_string_literal: true require "sqlite3" require "fileutils" require "digest" module Wp2txt # SQLite-based cache for multistream index # Dramatically speeds up repeated index access by storing parsed entries in SQLite class IndexCache CACHE_VERSION = 1 CACHE_SUFFIX = ".sqlite3" attr_reader :...
github
yohasebe/wp2txt
https://github.com/yohasebe/wp2txt
lib/wp2txt/category_cache.rb
Ruby
mit
193
master
9,188
# frozen_string_literal: true require "sqlite3" require "json" require "fileutils" require_relative "constants" module Wp2txt # SQLite-based cache for Wikipedia category hierarchy and members # Dramatically speeds up repeated category extraction operations class CategoryCache CACHE_VERSION = 1 DEFAULT_C...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
Policyfile.rb
Ruby
apache-2.0
192
main
212
# frozen_string_literal: true name 'consul' default_source :supermarket cookbook 'consul', path: '.' cookbook 'test', path: 'test/cookbooks/test' run_list 'test::default' named_run_list 'client', 'test::client'
github
sous-chefs/consul
https://github.com/sous-chefs/consul
metadata.rb
Ruby
apache-2.0
192
main
762
# frozen_string_literal: true name 'consul' maintainer 'Sous Chefs' maintainer_email 'help@sous-chefs.org' license 'Apache-2.0' description 'Provides consul_installation, consul_config, consul_service, and related resources for managing HashiCorp Consul.' source_url 'https:/...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
libraries/diplomat_helpers.rb
Ruby
apache-2.0
192
main
921
# frozen_string_literal: true # # Cookbook: consul # License: Apache 2.0 # module ConsulCookbook module DiplomatHelpers def configure_diplomat begin require 'diplomat' rescue LoadError => e raise 'The diplomat gem is required; ' \ "include recipe[consul::client_gem] to inst...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
libraries/helpers.rb
Ruby
apache-2.0
192
main
1,836
# frozen_string_literal: true # # Cookbook: consul # License: Apache 2.0 # # Copyright:: 2014-2016, Bloomberg Finance L.P. # module ConsulCookbook module Helpers include Chef::Mixin::ShellOut extend self def consul_arch case node['kernel']['machine'] when 'x86_64', 'amd64' then 'amd64' ...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/helpers_spec.rb
Ruby
apache-2.0
192
main
3,730
# frozen_string_literal: true require 'spec_helper' require_relative '../libraries/helpers' describe ConsulCookbook::Helpers do let(:helper_class) do Class.new do include ConsulCookbook::Helpers attr_accessor :node def platform_family?(family) node['platform_family'] == family ...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_definition_spec.rb
Ruby
apache-2.0
192
main
1,431
# frozen_string_literal: true require 'spec_helper' describe 'consul_definition' do step_into :consul_definition platform 'ubuntu', '24.04' context 'creates a service definition' do recipe do consul_definition 'redis' do type 'service' parameters(tags: %w(master), address: '127.0.0.1'...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_token_spec.rb
Ruby
apache-2.0
192
main
717
# frozen_string_literal: true require 'spec_helper' # Diplomat-based resources are not stepped into because they require # the diplomat gem at converge time. We test resource declaration only. describe 'consul_token' do platform 'ubuntu', '24.04' context 'creates a token' do recipe do consul_token 'tes...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_execute_spec.rb
Ruby
apache-2.0
192
main
492
# frozen_string_literal: true require 'spec_helper' describe 'consul_execute' do step_into :consul_execute platform 'ubuntu', '24.04' context 'runs a command' do recipe do consul_execute 'uptime' end it { is_expected.to run_consul_execute('uptime') } end context 'runs a command with opt...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_role_spec.rb
Ruby
apache-2.0
192
main
739
# frozen_string_literal: true require 'spec_helper' # Diplomat-based resources are not stepped into because they require # the diplomat gem at converge time. We test resource declaration only. describe 'consul_role' do platform 'ubuntu', '24.04' context 'creates a role' do recipe do consul_role 'test-r...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_acl_spec.rb
Ruby
apache-2.0
192
main
751
# frozen_string_literal: true require 'spec_helper' # Diplomat-based resources are not stepped into because they require # the diplomat gem at converge time. We test resource declaration only. describe 'consul_acl' do platform 'ubuntu', '24.04' context 'creates an ACL' do recipe do consul_acl 'test-acl...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_config_spec.rb
Ruby
apache-2.0
192
main
1,605
# frozen_string_literal: true require 'spec_helper' describe 'consul_config' do step_into :consul_config platform 'ubuntu', '24.04' context 'with default properties' do recipe do consul_config '/etc/consul/consul.json' end it { is_expected.to create_directory('/etc/consul').with(owner: 'cons...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_policy_spec.rb
Ruby
apache-2.0
192
main
766
# frozen_string_literal: true require 'spec_helper' # Diplomat-based resources are not stepped into because they require # the diplomat gem at converge time. We test resource declaration only. describe 'consul_policy' do platform 'ubuntu', '24.04' context 'creates a policy' do recipe do consul_policy '...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_installation_spec.rb
Ruby
apache-2.0
192
main
2,318
# frozen_string_literal: true require 'spec_helper' describe 'consul_installation' do step_into :consul_installation platform 'ubuntu', '24.04' context 'with repository install method on debian' do recipe do consul_installation 'latest' do install_method 'repository' end end it...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_watch_spec.rb
Ruby
apache-2.0
192
main
805
# frozen_string_literal: true require 'spec_helper' describe 'consul_watch' do step_into :consul_watch platform 'ubuntu', '24.04' context 'creates a watch' do recipe do consul_watch 'app-deploy' do type 'event' parameters(handler: '/usr/local/bin/clear-disk-cache.sh') end en...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
spec/unit/resources/consul_service_spec.rb
Ruby
apache-2.0
192
main
1,784
# frozen_string_literal: true require 'spec_helper' describe 'consul_service' do step_into :consul_service platform 'ubuntu', '24.04' context 'action :enable' do recipe do consul_service 'consul' do action :enable end end it { is_expected.to create_directory('/var/lib/consul')....
github
sous-chefs/consul
https://github.com/sous-chefs/consul
test/cookbooks/test/recipes/client.rb
Ruby
apache-2.0
192
main
577
# frozen_string_literal: true consul_installation 'default' do version node['consul_test']['version'] install_method node['consul_test']['install_method'] end group 'consul' do system true end user 'consul' do system true group 'consul' shell '/bin/false' end config = consul_config node['consul_test']['...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
test/cookbooks/test/recipes/default.rb
Ruby
apache-2.0
192
main
856
# frozen_string_literal: true consul_installation 'default' do version node['consul_test']['version'] install_method node['consul_test']['install_method'] end group 'consul' do system true end user 'consul' do system true group 'consul' shell '/bin/false' end config = consul_config node['consul_test']['...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
test/integration/client/controls/client_spec.rb
Ruby
apache-2.0
192
main
1,970
# frozen_string_literal: true title 'Client Suite - Consul Client' config_file = '/etc/consul/consul.json' config_dir = '/etc/consul' control 'consul-client-install-01' do impact 1.0 title 'Consul binary is installed' describe command('consul version') do its(:exit_status) { should eq 0 } end end cont...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
test/integration/default/controls/default_spec.rb
Ruby
apache-2.0
192
main
2,619
# frozen_string_literal: true title 'Default Suite - Consul Server' config_file = '/etc/consul/consul.json' confd_dir = '/etc/consul/conf.d' data_dir = '/var/lib/consul' control 'consul-install-01' do impact 1.0 title 'Consul binary is installed' describe command('consul version') do its(:exit_status...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/acl.rb
Ruby
apache-2.0
192
main
1,359
# frozen_string_literal: true provides :consul_acl unified_mode true default_action :create use '_partial/_diplomat' property :id, String, name_property: true property :acl_name, String, default: '' property :type, String, equal_to: %w(client management), default: 'client' property :rules, String, default: '' def ...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/config.rb
Ruby
apache-2.0
192
main
10,674
# frozen_string_literal: true provides :consul_config unified_mode true property :path, String, name_property: true property :owner, String, default: 'consul' property :group, String, default: 'consul' property :config_dir, String, default: '/etc/consul/conf.d' property :config_dir_mode, String, default: '0755' prope...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/service.rb
Ruby
apache-2.0
192
main
2,162
# frozen_string_literal: true provides :consul_service unified_mode true property :config_file, String, default: '/etc/consul/consul.json' property :user, String, default: 'consul' property :group, String, default: 'consul' property :environment, Hash, default: lazy { default_environment } property :data_dir, String,...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/role.rb
Ruby
apache-2.0
192
main
1,595
# frozen_string_literal: true provides :consul_role unified_mode true default_action :create use '_partial/_diplomat' property :role_name, String, name_property: true property :description, String, default: '' property :policies, Array, default: [] property :service_identities, Array, default: [] def to_acl { 'N...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/token.rb
Ruby
apache-2.0
192
main
2,302
# frozen_string_literal: true provides :consul_token unified_mode true default_action :create use '_partial/_diplomat' property :secret_id, String property :description, String, name_property: true property :policies, Array, default: [] property :roles, Array, default: [] property :service_identities, Array, defaul...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/installation.rb
Ruby
apache-2.0
192
main
4,210
# frozen_string_literal: true provides :consul_installation unified_mode true default_action :create property :version, String, name_property: true property :install_method, String, default: 'repository', equal_to: %w(repository binary) property :checksum, String property :archive_url, String include ConsulCookbook...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/watch.rb
Ruby
apache-2.0
192
main
888
# frozen_string_literal: true provides :consul_watch unified_mode true default_action :create property :path, String, default: lazy { ::File.join('/etc/consul/conf.d', "#{name}.json") } property :user, String, default: 'consul' property :group, String, default: 'consul' property :type, String, equal_to: %w(checks ev...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/policy.rb
Ruby
apache-2.0
192
main
1,933
# frozen_string_literal: true provides :consul_policy unified_mode true default_action :create use '_partial/_diplomat' property :policy_name, String, name_property: true property :description, String, default: '' property :datacenters, Array, default: [] property :rules, String, default: '' def to_acl { 'Name' ...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/definition.rb
Ruby
apache-2.0
192
main
1,211
# frozen_string_literal: true provides :consul_definition unified_mode true default_action :create property :path, String, default: lazy { ::File.join('/etc/consul/conf.d', "#{name}.json") } property :user, String, default: 'consul' property :group, String, default: 'consul' property :mode, String, default: '0640' p...
github
sous-chefs/consul
https://github.com/sous-chefs/consul
resources/execute.rb
Ruby
apache-2.0
192
main
706
# frozen_string_literal: true provides :consul_execute unified_mode true default_action :run property :command, String, name_property: true property :environment, Hash, default: { 'PATH' => '/usr/local/bin:/usr/bin:/bin' } property :options, Hash, default: {} action :run do options = new_resource.options.map do |...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
huffshell.gemspec
Ruby
mit
192
master
740
require 'rake' Gem::Specification.new do |s| s.name = 'huffshell' s.version = '0.0.14' s.date = '2012-11-08' s.summary = "Automatic shell alias recommondations based on usage!" s.description = "A parser and recommendation system for your shell aliases based on your shell history" s.li...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/huffshell.rb
Ruby
mit
192
master
488
# ruby 1.8.6 class String def initial self[0,1] end def green self end end begin require 'colorize' rescue LoadError end require 'readers/history_reader' require 'readers/oh_my_zsh_reader' require 'command/command_word' require 'command/command_suggestor' require 'command/command_suggestion' requ...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/readers/history_reader.rb
Ruby
mit
192
master
1,369
class HistoryReader attr_accessor :filename, :file_contents def initialize(filename) @filename = filename path = File.expand_path(filename) if File.exist?(path) file = File.open(path, 'r') else raise "File does not exist." + path.inspect end @file_contents = "" if String....
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/readers/oh_my_zsh_reader.rb
Ruby
mit
192
master
355
require 'iconv' unless String.method_defined?(:encode) class OhMyZshReader < HistoryReader attr_accessor :file_name, :file_contents def shell_commands filtered_lines.map {|l| l.split(";").last.strip } end private def filtered_lines raw_lines.select{|l| valid_line?(l) } end def valid_line?(line)...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/tree/word_tree_node.rb
Ruby
mit
192
master
1,574
class WordTreeNode include Enumerable attr_accessor :word, :cleanword, :children, :line_count, :level, :parent def initialize(word = nil, level = 0, parent = nil) @word = word @cleanword = CommandWord.clean(word) if word @children = {} @line_count = 0 @level = level @parent = parent en...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/tree/word_tree.rb
Ruby
mit
192
master
291
class WordTree attr_accessor :root, :line_count def initialize @root = WordTreeNode.new @line_count = 0 end def add(line) @line_count += 1 root.add(line, 0) end def truncate!(minimum) root.truncate!(minimum) end def to_tree root.to_tree end end
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/command/command_suggestor.rb
Ruby
mit
192
master
475
class CommandSuggestor attr_accessor :wordtree def initialize() @wordtree = WordTree.new end def add(line) sl = ScriptLine.new(line) return unless sl.valid? wordtree.add(sl) end def truncate!(minimum) wordtree.root.truncate!(minimum) end def commands wordtree.root.children.ke...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/command/command_suggestion.rb
Ruby
mit
192
master
668
class CommandSuggestion attr_accessor :wordlist SHORT_ENOUGH = 3 def initialize(wordlist) @wordlist = wordlist end def to_s if exists? "'#{command}' => #{abbreviation} taken :(" else "'#{command}' => " + "#{abbreviation}".green end end def abbreviation wordlist.map{|w| ...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/command/command_word.rb
Ruby
mit
192
master
233
class CommandWord def self.clean(word) word.gsub(/(\-)+/, '') #.downcase end def self.suggested_letter(word) char = word.gsub(/(^\W)+/,"")[0,1].downcase return nil if char.empty? char rescue nil end end
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/shell/binary_checker.rb
Ruby
mit
192
master
224
class BinaryChecker def initialize(command) @command = command end def exist? !!ENV['PATH'].split(':'). map {|folder| File.exists?(folder+'/'+@command)}. inject(false){|a,b| a || b } end end
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/shell/alias_checker.rb
Ruby
mit
192
master
513
class AliasChecker attr_accessor :filename, :aliases def initialize(filename) @filename = filename if !File.exist?(File.expand_path(filename)) return end file_contents = File.open(File.expand_path(filename), 'r').read lines = file_contents.split("\n") @aliases = {} lines.each do...
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/shell/script_line.rb
Ruby
mit
192
master
385
class ScriptLine attr_accessor :line, :words, :clean_words def initialize(l) @line = l.strip @words = l.split(/[ \t]+/) @clean_words = @words.map{|w| CommandWord.clean(w) } end def command clean_words.first end def valid? !(comment? || empty?) end private def comment? @line....
github
paulmars/huffshell
https://github.com/paulmars/huffshell
lib/shell/alias_line.rb
Ruby
mit
192
master
260
class AliasLine attr_accessor :line def initialize(line) @line = line end def alias_name @line.split("=").first end def valid? @line.scan("=") != [] end def command c = @line.split("=")[1] c[1..(c.size-2)] if c end end
github
paulmars/huffshell
https://github.com/paulmars/huffshell
spec/shell/script_line_spec.rb
Ruby
mit
192
master
654
require 'spec_helper' describe ScriptLine do it "accepts a line of shell script" do ScriptLine.new("puts 'hey'") end it "returns the command word" do sl = ScriptLine.new("puts 'hey'") sl.command.should == "puts" end it "returns an array of words" do sl = ScriptLine.new("puts 'hey'") sl....
github
paulmars/huffshell
https://github.com/paulmars/huffshell
spec/shell/alias_line_spec.rb
Ruby
mit
192
master
526
require 'spec_helper' describe AliasLine do before(:each) do @al = AliasLine.new("gap='git add -p'") end it "is created with a string" do AliasLine.new("gap='git add -p'") end it "can tell if it is valid" do al = AliasLine.new("gap='git add -p'") al.should be_valid al = AliasLine.new("...