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 | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/commands/upload/snapshots/client_libraries/swift_snapshot_testing.rb | Ruby | mit | 20 | main | 734 | module EmergeCLI
module Commands
module Upload
module ClientLibraries
class SwiftSnapshotTesting
def initialize(project_root)
@project_root = project_root
end
def image_files
Dir.glob(File.join(@project_root, '**/__Snapshots__/**/*.png'))
... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/commands/upload/snapshots/client_libraries/roborazzi.rb | Ruby | mit | 20 | main | 1,021 | module EmergeCLI
module Commands
module Upload
module ClientLibraries
class Roborazzi
def initialize(project_root)
@project_root = project_root
end
def image_files
Dir.glob(File.join(@project_root, '**/build/outputs/roborazzi/**/*.png'))
... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/commands/upload/snapshots/client_libraries/paparazzi.rb | Ruby | mit | 20 | main | 839 | module EmergeCLI
module Commands
module Upload
module ClientLibraries
class Paparazzi
def initialize(project_root)
@project_root = project_root
end
def image_files
# TODO: support "paparazzi.snapshot.dir" dynamic config
Dir.glob(File... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/commands/upload/snapshots/client_libraries/default.rb | Ruby | mit | 20 | main | 873 | module EmergeCLI
module Commands
module Upload
module ClientLibraries
class Default
def initialize(image_paths, group_delimiter)
@image_paths = image_paths
@group_delimiter = group_delimiter
end
def image_files
@image_paths.flat_map ... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/commands/reaper/reaper.rb | Ruby | mit | 20 | main | 6,384 | require 'dry/cli'
require 'json'
require 'tty-prompt'
module EmergeCLI
module Commands
class Reaper < EmergeCLI::Commands::GlobalOptions
desc 'Analyze dead code from an Emerge upload'
option :id, type: :string, required: true, desc: 'Emerge build ID to analyze'
option :project_root, type: :str... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/xcode_device_manager.rb | Ruby | mit | 20 | main | 5,956 | require 'json'
require_relative 'xcode_simulator'
require 'zip'
require 'cfpropertylist'
module EmergeCLI
class XcodeDeviceManager
class DeviceType
VIRTUAL = :virtual
PHYSICAL = :physical
ANY = :any
end
def initialize(environment: Environment.new)
@environment = environment
e... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/github.rb | Ruby | mit | 20 | main | 1,768 | module EmergeCLI
module Github
GITHUB_EVENT_PR = 'pull_request'.freeze
GITHUB_EVENT_PUSH = 'push'.freeze
def self.event_name
ENV.fetch('GITHUB_EVENT_NAME', nil)
end
def self.supported_github_event?
Logger.info "GitHub event name: #{event_name}"
pull_request? || push?
end
... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/macho_parser.rb | Ruby | mit | 20 | main | 11,686 | require 'macho'
module EmergeCLI
class MachOParser
TYPE_METADATA_KIND_MASK = 0x7 << 3
TYPE_METADATA_KIND_SHIFT = 3
# Bind Codes
BIND_OPCODE_MASK = 0xF0
BIND_IMMEDIATE_MASK = 0x0F
BIND_OPCODE_DONE = 0x00
BIND_OPCODE_SET_DYLIB_ORDINAL_IMM = 0x10
BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB = 0x2... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/xcode_physical_device.rb | Ruby | mit | 20 | main | 4,155 | require 'English'
require 'timeout'
require 'zip'
require 'cfpropertylist'
require 'fileutils'
module EmergeCLI
class XcodePhysicalDevice
attr_reader :device_id
def initialize(device_id)
@device_id = device_id
end
def install_app(ipa_path)
raise "Non-IPA file provided: #{ipa_path}" unle... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/project_detector.rb | Ruby | mit | 20 | main | 232 | module EmergeCLI
class ProjectDetector
def initialize(project_path)
@project_path = project_path
end
def ios_project?
Dir.glob(File.join(@project_path, '*.{xcodeproj,xcworkspace}')).any?
end
end
end |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/logger.rb | Ruby | mit | 20 | main | 1,435 | require 'logger'
require 'colored2'
module EmergeCLI
class Logger
class << self
def configure(log_level)
logger.level = log_level
end
def info(message)
log(:info, message)
end
def warn(message)
log(:warn, message)
end
def error(message)
... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/git_result.rb | Ruby | mit | 20 | main | 392 | module EmergeCLI
class GitResult
attr_accessor :sha, :base_sha, :previous_sha, :branch, :pr_number, :repo_name
def initialize(sha:, base_sha:, branch:, pr_number: nil, repo_name: nil, previous_sha: nil)
@pr_number = pr_number
@sha = sha
@base_sha = base_sha
@previous_sha = previous_sh... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/version_check.rb | Ruby | mit | 20 | main | 1,013 | require 'json'
module EmergeCLI
module Utils
class VersionCheck
def initialize(network: EmergeCLI::Network.new)
@network = network
end
def check_version
Sync do
response = @network.get(
path: 'https://rubygems.org/api/v1/gems/emerge.json',
head... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/profiler.rb | Ruby | mit | 20 | main | 1,310 | module EmergeCLI
# NOTE: This class is not thread-safe.
class Profiler
def initialize(enabled: false)
@enabled = enabled
@measurements = {}
@start_times = {}
end
def measure(label)
return yield unless @enabled
start(label)
result = yield
stop(label)
resu... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/xcode_simulator.rb | Ruby | mit | 20 | main | 4,140 | require 'English'
require 'zip'
require 'cfpropertylist'
require 'fileutils'
module EmergeCLI
class XcodeSimulator
attr_reader :device_id
def initialize(device_id, environment: Environment.new)
@device_id = device_id
@environment = environment
end
def boot
Logger.info "Booting sim... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/network.rb | Ruby | mit | 20 | main | 3,317 | require 'net/http'
require 'json'
require 'uri'
require 'async/http/internet/instance'
module EmergeCLI
class Network
EMERGE_API_PROD_URL = 'api.emergetools.com'.freeze
public_constant :EMERGE_API_PROD_URL
RETRY_DELAY = 5
MAX_RETRIES = 3
def initialize(api_token: nil, base_url: EMERGE_API_PROD_... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/git.rb | Ruby | mit | 20 | main | 3,954 | require 'open3'
module EmergeCLI
module Git
def self.branch
Logger.debug 'Getting current branch name'
command = 'git rev-parse --abbrev-ref HEAD'
Logger.debug command
stdout, _, status = Open3.capture3(command)
unless status.success?
Logger.error 'Failed to get the current ... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/utils/git_info_provider.rb | Ruby | mit | 20 | main | 814 | module EmergeCLI
class GitInfoProvider
def fetch_git_info
if EmergeCLI::Github.supported_github_event?
Logger.info 'Fetching Git info from Github event'
EmergeCLI::GitResult.new(
sha: EmergeCLI::Github.sha,
base_sha: EmergeCLI::Github.base_sha,
branch: EmergeCLI... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/reaper/code_deleter.rb | Ruby | mit | 20 | main | 11,560 | require 'xcodeproj'
module EmergeCLI
module Reaper
class CodeDeleter
def initialize(project_root:, platform:, profiler:, skip_delete_usages: false)
@project_root = File.expand_path(project_root)
@platform = platform
@profiler = profiler
@skip_delete_usages = skip_delete_usag... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | lib/reaper/ast_parser.rb | Ruby | mit | 20 | main | 16,898 | require 'tree_sitter'
module EmergeCLI
module Reaper
# Parses the AST of a given file using Tree Sitter and allows us to find usages or delete types.
# This does have a lot of limitations since it only looks at a single file at a time,
# but can get us most of the way there.
class AstParser
DEC... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/test_helper.rb | Ruby | mit | 20 | main | 782 | require 'simplecov'
require 'minitest/autorun'
require 'minitest/pride'
require 'minitest/reporters'
require 'tmpdir'
require 'fileutils'
require_relative 'support/fake_network'
require_relative 'support/fake_git_info_provider'
# Use the Progress Reporter for CI, otherwise use the Default Reporter
reporter_options = ... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/support/fake_network.rb | Ruby | mit | 20 | main | 1,454 | module EmergeCLI
class FakeNetwork
DEFAULT_RESPONSES = {
'/v1/snapshots/run' => { 'run_id' => 'fake-run-id' }.to_json,
'/v1/snapshots/run/image' => { 'image_url' => 'https://fake-upload-url.com' }.to_json,
'/v1/snapshots/run/finish' => '{}',
'https://fake-upload-url.com' => ''
}.freeze... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/reaper/ast_parser_test.rb | Ruby | mit | 20 | main | 61,641 | require 'test_helper'
module EmergeCLI
module Reaper
class AstParserTest < Minitest::Test
FIXTURES_PATH = File.join(__dir__, '../fixtures/reaper')
def self.load_fixture(path)
File.read(File.join(FIXTURES_PATH, path)).strip
end
describe 'Swift' do
describe 'delete_type' d... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/config/orderfiles/orderfiles_ios_test.rb | Ruby | mit | 20 | main | 2,483 | require 'test_helper'
module EmergeCLI
module Commands
module Config
class OrderFilesIOSTest < Minitest::Test
LINK_MAPS_CONFIG = 'LD_GENERATE_MAP_FILE'.freeze
LINK_MAPS_PATH = 'LD_MAP_FILE_PATH'.freeze
PATH_TO_LINKMAP = '$(TARGET_TEMP_DIR)/$(PRODUCT_NAME)-LinkMap-$(CURRENT_VARIANT)-... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/config/snapshots/snapshots_ios_test.rb | Ruby | mit | 20 | main | 2,051 | require 'test_helper'
module EmergeCLI
module Commands
module Config
class SnapshotsIOSTest < Minitest::Test
def setup
@command = EmergeCLI::Commands::Config::SnapshotsIOS.new
end
def teardown
FileUtils.rm_rf('emerge_config.yml')
end
def test_ra... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/upload/snapshots/snapshots_test.rb | Ruby | mit | 20 | main | 3,518 | require 'test_helper'
module EmergeCLI
module Commands
module Upload
class SnapshotsTest < Minitest::Test
def setup
@fake_network = EmergeCLI::FakeNetwork.new
@git_result = EmergeCLI::GitResult.new(
sha: 'abc123',
base_sha: 'def456',
branch: '... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/upload/snapshots/client_libraries/paparazzi_test.rb | Ruby | mit | 20 | main | 1,906 | require 'test_helper'
module EmergeCLI
module Commands
module Upload
module ClientLibraries
class PaparazziTest < Minitest::Test
def setup
@temp_dir = Dir.mktmpdir
setup_test_files
@paparazzi = Paparazzi.new(@temp_dir)
end
def teard... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/upload/snapshots/client_libraries/swift_snapshot_testing_test.rb | Ruby | mit | 20 | main | 1,943 | require 'test_helper'
require 'tmpdir'
require 'fileutils'
module EmergeCLI
module Commands
module Upload
module ClientLibraries
class SwiftSnapshotTestingTest < Minitest::Test
def setup
@temp_dir = Dir.mktmpdir
setup_test_files
@swift_snapshot_testing ... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/upload/snapshots/client_libraries/roborazzi_test.rb | Ruby | mit | 20 | main | 2,437 | require 'test_helper'
module EmergeCLI
module Commands
module Upload
module ClientLibraries
class RoborazziTest < Minitest::Test
def setup
@temp_dir = Dir.mktmpdir
setup_test_files
@roborazzi = Roborazzi.new(@temp_dir)
end
def teard... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/orderfiles/download_order_files_test.rb | Ruby | mit | 20 | main | 1,048 | require 'test_helper'
module EmergeCLI
module Commands
class DownloadOrderFilesTest < Minitest::Test
def teardown
FileUtils.remove_entry 'com.emerge.hn.Hacker-News-3.4.0.gz'
FileUtils.remove_entry 'com.emerge.hn.Hacker-News-3.4.0'
end
def test_unzips_file_when_unzip_flag_is_tru... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/autofixes/minify_strings_test.rb | Ruby | mit | 20 | main | 2,179 | require 'test_helper'
module EmergeCLI
module Commands
module Autofixes
class MinifyStringsTest < Minitest::Test
SCRIPT_NAME = 'EmergeTools Minify Strings'.freeze
ENABLE_USER_SCRIPT_SANDBOXING = 'ENABLE_USER_SCRIPT_SANDBOXING'.freeze
STRINGS_FILE_OUTPUT_ENCODING = 'STRINGS_FILE_OUTP... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/autofixes/strip_binary_symbols_test.rb | Ruby | mit | 20 | main | 1,904 | require 'test_helper'
module EmergeCLI
module Commands
module Autofixes
class StripBinarySymbolsTest < Minitest::Test
SCRIPT_NAME = 'EmergeTools Strip Binary Symbols'.freeze
ENABLE_USER_SCRIPT_SANDBOXING = 'ENABLE_USER_SCRIPT_SANDBOXING'.freeze
INPUT_FILE = '${DWARF_DSYM_FOLDER_PATH... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/autofixes/exported_symbols_test.rb | Ruby | mit | 20 | main | 1,691 | require 'test_helper'
module EmergeCLI
module Commands
module Autofixes
class ExportedSymbolsTest < Minitest::Test
EMERGE_TOOLS_GROUP = 'EmergeToolsHelperFiles'.freeze
EXPORTED_SYMBOLS_FILE = 'EXPORTED_SYMBOLS_FILE'.freeze
EXPORTED_SYMBOLS_PATH = '$(SRCROOT)/EmergeToolsHelperFiles/E... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/commands/snapshots/validate_app_test.rb | Ruby | mit | 20 | main | 1,044 | require 'test_helper'
module EmergeCLI
module Commands
module Snapshots
class ValidateAppTest < Minitest::Test
def setup
@command = EmergeCLI::Commands::Snapshots::ValidateApp.new
end
def test_returns_false_if_no_previews_found
options = {
path: 'tes... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/utils/version_check_test.rb | Ruby | mit | 20 | main | 1,852 | require 'test_helper'
module EmergeCLI
module Utils
class VersionCheckTest < Minitest::Test
def setup
@network = FakeNetwork.new
@version_check = VersionCheck.new(network: @network)
end
def test_warns_when_newer_version_available
@network = FakeNetwork.new(
'h... |
github | EmergeTools/emerge-cli | https://github.com/EmergeTools/emerge-cli | test/utils/xcode_device_manager_test.rb | Ruby | mit | 20 | main | 8,485 | require 'test_helper'
require 'utils/xcode_device_manager'
module EmergeCLI
class XcodeDeviceManagerTest < Minitest::Test
class FakeEnvironment
def initialize(responses = {})
@responses = responses
@commands = []
end
attr_reader :commands
def execute_command(command)
... |
github | mattfoster/gnuplot-tmbundle | https://github.com/mattfoster/gnuplot-tmbundle | Support/Gnuplot.rake | Ruby | mit | 19 | master | 644 | require 'rake/clean'
PLOTFILES = FileList['*.plt']
EPSFILES = FileList.new
PLOTFILES.each do |x|
t = File.read x
outfiles = t.scan(/^[^%]*?(['"])(.*\.dat)\1/).map { |y| y[1] }
t.scan(/^\W*set output\W+(['"])(.*)\1/) do |y|
EPSFILES << y[1]
file y[1] => ([x] + outfiles) do |f|
sh "gnuplot #{f.prer... |
github | mattfoster/gnuplot-tmbundle | https://github.com/mattfoster/gnuplot-tmbundle | Support/expand_gnuplot.rb | Ruby | mit | 19 | master | 2,603 | #!/usr/bin/env ruby
#
# Gnuplot completion functions
#
# Run using:
# echo set | gnuplot 2>&1 | egrep -o "'.*'" | tr ',' '\n' | \
# ~/Documents/expand_gnuplot.rb
#
# For a list that can be used in a language grammar, use something like:
# echo match = \'\\b\($(./expand_gnuplot.rb set | tr -t "\n" "|")\)\\b\'
#
# Matt ... |
github | mattfoster/gnuplot-tmbundle | https://github.com/mattfoster/gnuplot-tmbundle | Support/GnuplotMate.rb | Ruby | mit | 19 | master | 1,967 | class GnuplotMate
def initialize
path = File.dirname(ENV["TM_FILEPATH"])
Dir.chdir path
end
def path
possible_paths = [ENV["TM_GNUPLOT"], `which gnuplot`, "/opt/local/bin/gnuplot", "/sw/bin/gnuplot", "/usr/local/bin/gnuplot"]
possible_paths.select { |x| x && File.exist?(x) }.first
end
def ... |
github | mattfoster/gnuplot-tmbundle | https://github.com/mattfoster/gnuplot-tmbundle | Support/lib/gnuplot_help.rb | Ruby | mit | 19 | master | 3,006 | # Functions for converting gnuplot help to markdown
#
# Matt Foster 2008
module Gnuplot
def convert(word = '')
require 'cgi'
# Determine the title as needed.
unless word.nil?
help = "## Help for \'#{word}\'\n"
else
help = "## Introduction\n"
end
# Run gnuplot, and g... |
github | mattfoster/gnuplot-tmbundle | https://github.com/mattfoster/gnuplot-tmbundle | Support/bin/get_gnuplot_help.rb | Ruby | mit | 19 | master | 415 | #!/usr/bin/env ruby -w
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/markdown.rb"
require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/gnuplot_help.rb"
# require 'rubygems'
# require 'bluecloth'
require 'markdown'
require 'gnuplot_help'
include Gnuplot
include TextMate
if __FILE__ == $0
word = ARGV.shift || STDIN.read
help = co... |
github | rylev/apfel | https://github.com/rylev/apfel | Rakefile | Ruby | mit | 19 | master | 274 | #!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
Bundler::GemHelper.install_tasks
desc "Run all tests and documentation checks"
task :qa => [:spec]
task :default => :qa |
github | rylev/apfel | https://github.com/rylev/apfel | apfel.gemspec | Ruby | mit | 19 | master | 966 | # encoding: utf-8
lib_folder = File.join(File.dirname(__FILE__), 'lib')
apfel_folder = File.join(File.dirname(__FILE__), 'lib', 'apfel')
$:.unshift apfel_folder
require "version"
Gem::Specification.new do |s|
s.name = "apfel"
s.version = Apfel::VERSION
s.platform = Gem::Platform::RUBY
s.authors ... |
github | rylev/apfel | https://github.com/rylev/apfel | spec/apfel_spec.rb | Ruby | mit | 19 | master | 5,613 | require 'spec_helper'
require 'apfel'
require 'apfel/parsed_dot_strings'
describe Apfel do
describe '::parse_file' do
context 'when given an ASCII DotStrings file'do
let(:parsed_file) do
Apfel.parse(valid_file)
end
it 'returns a ParsedDotStrings object' do
parsed_file.should b... |
github | rylev/apfel | https://github.com/rylev/apfel | spec/reader_spec.rb | Ruby | mit | 19 | master | 606 | require 'spec_helper'
require 'apfel/reader'
module Apfel
describe Reader do
describe '#read' do
let(:temp_file) do
create_temp_file('ascii', <<-EOS
This is a file with some lines.
Roses are red, violets are blue.
This text is really boring,
and so are you!
EOS
)
end
it... |
github | rylev/apfel | https://github.com/rylev/apfel | spec/spec_helper.rb | Ruby | mit | 19 | master | 475 | require 'tempfile'
require 'json'
def create_temp_file(encoding, string)
temp_file = Tempfile.new([encoding, 'temp'])
temp_file << string
temp_file.flush
end
def valid_file(encoding='ascii')
create_temp_file(encoding, <<-EOS
/* This is the first comment */
"key_number_one" = "value number one";
/* This is
a
... |
github | rylev/apfel | https://github.com/rylev/apfel | spec/parsed_dot_strings_spec.rb | Ruby | mit | 19 | master | 3,592 | require 'spec_helper'
require 'apfel'
require 'apfel/parsed_dot_strings'
module Apfel
describe ParsedDotStrings do
let(:parsed_file) do
Apfel.parse(valid_file)
end
describe '#keys' do
it 'returns an array of all the keys'do
parsed_file.keys.should eq(
["key_number_one",
... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel.rb | Ruby | mit | 19 | master | 331 | # encoding: UTF-8
module Apfel
require 'apfel/reader'
require 'apfel/dot_strings_parser'
# Public module for parsing DotStrings files and returning a parsed dot
# strings object
def self.parse(file)
file = read(file)
DotStringsParser.new(file).parse_file
end
def self.read(file)
Reader.read(file)... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel/parsed_dot_strings.rb | Ruby | mit | 19 | master | 1,309 | module Apfel
require 'json'
class ParsedDotStrings
attr_accessor :kv_pairs
def initialize
@kv_pairs = []
end
def key_values
kv_pairs.map do |pair|
{pair.key => pair.value}
end
end
def keys
kv_pairs.map do |pair|
pair.key
end
end
def v... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel/kv_pair.rb | Ruby | mit | 19 | master | 536 | module Apfel
class KVPair
attr_reader :line, :raw_comment
def initialize(line, comment)
@line = line
@raw_comment = comment
end
def key
line.key.strip unless line.key.nil?
end
def value
line.value.strip unless line.key.nil?
end
def comment
if raw_comment.n... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel/reader.rb | Ruby | mit | 19 | master | 672 | module Apfel
# Class for reading in files and returning an array of its content
class Reader
# Reads in a file and returns an array consisting of each line of input
# cleaned of new line characters
def self.read(file)
File.open(file, 'r') do |f|
content = f.read.force_encoding('UTF-8')
... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel/line.rb | Ruby | mit | 19 | master | 1,323 | module Apfel
class Line
attr_reader :content
attr_accessor :in_comment
def initialize(line)
@content = line
@in_comment = false
raise "Line does not end in ;" unless valid?
end
def empty_line?
/^\s*$/.match(content) || false
end
def whole_comment
/((^\/\*(.... |
github | rylev/apfel | https://github.com/rylev/apfel | lib/apfel/dot_strings_parser.rb | Ruby | mit | 19 | master | 1,738 | module Apfel
require 'apfel/line'
require 'apfel/kv_pair'
require 'apfel/parsed_dot_strings'
class DotStringsParser
KEY = "KEY"
COMMENT = "COMMENT"
def initialize(read_file, parsed_file = ParsedDotStrings.new)
@read_file = read_file
@parsed_file = parsed_file
end
def parse_file... |
github | izniburak/qruby | https://github.com/izniburak/qruby | qruby.gemspec | Ruby | mit | 19 | master | 856 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'qruby/version'
Gem::Specification.new do |s|
s.name = 'qruby'
s.version = QRuby::VERSION
s.date = '2017-10-05'
s.summary = 'simple sql query builder library ... |
github | izniburak/qruby | https://github.com/izniburak/qruby | lib/qruby.rb | Ruby | mit | 19 | master | 7,191 | require_relative "qruby/version"
module QRuby
class Builder
@@escape_character = "\\"
def initialize
@select = "*"
@table, @join, @where, @group_by, @having, @order_by, @limit, @last_query = "", "", "", "", "", "", "", ""
@operators = ["=", "!=", "<", ">", "<=", ">=", "<>"]
end
de... |
github | izniburak/qruby | https://github.com/izniburak/qruby | spec/qruby_spec.rb | Ruby | mit | 19 | master | 6,612 | require 'spec_helper'
require './lib/qruby'
describe QRuby::Builder do
subject { QRuby::Builder.new }
it "determine the table name" do
expect( subject.table('test').get_all ).to eq 'SELECT * FROM test'
expect( subject.table('test').get ).to eq 'SELECT * FROM test LIMIT 1'
end
it "select method" do
... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | Rakefile | Ruby | mit | 19 | main | 294 | require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
RSpec::Core::RakeTask.new(:spec_with_formatters) do |t|
t.rspec_opts =
"--format RspecOverview::Formatter --format RspecOverview::FormatterCsv"
end
task default: [:spec, :spec_with_formatters] |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | rspec_overview.gemspec | Ruby | mit | 19 | main | 963 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "rspec_overview/version"
Gem::Specification.new do |spec|
spec.name = "rspec_overview"
spec.version = RspecOverview::VERSION
spec.authors = ["Oli Peate"]
spec.license = "MIT"
... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/formatter_csv.rb | Ruby | mit | 19 | main | 258 | require_relative "formatter"
require_relative "output/csv"
module RspecOverview
class FormatterCsv < Formatter
RSpec::Core::Formatters.register self, :dump_summary
private
def output_format
RspecOverview::Output::Csv
end
end
end |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/result.rb | Ruby | mit | 19 | main | 521 | module RspecOverview
class Result
attr_reader :identifier
attr_accessor :example_count, :duration_raw
def initialize(identifier)
@identifier = identifier
@example_count = 0
@duration_raw = 0.0
end
def avg_duration_seconds
format_seconds(duration_raw / example_count)
e... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/collator.rb | Ruby | mit | 19 | main | 810 | require_relative "result"
module RspecOverview
class Collator
def by_type_or_subfolder(examples)
by_identifier(examples) do |example|
example.metadata[:type] || extract_subfolder(example.file_path)
end
end
def by_file_path(examples)
by_identifier(examples) do |example|
... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/formatter.rb | Ruby | mit | 19 | main | 1,392 | require "rspec/core"
require_relative "output/markdown_table"
require_relative "collator"
module RspecOverview
class Formatter
RSpec::Core::Formatters.register self, :dump_summary
def initialize(output)
@output = output
end
def dump_summary(summary)
examples = summary.examples
su... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/output/markdown_table.rb | Ruby | mit | 19 | main | 1,627 | require "matrix"
module RspecOverview
module Output
class MarkdownTable
BORDER_SEPERATOR = "|".freeze
NOT_BORDER_SEPERATOR = /[^#{BORDER_SEPERATOR}]/
HEADING_SEPERATOR = "-".freeze
def initialize(headings:, rows:)
@matrix = Matrix.rows([headings] + rows)
end
def to_s... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | lib/rspec_overview/output/csv.rb | Ruby | mit | 19 | main | 462 | require "csv"
module RspecOverview
module Output
class Csv
def initialize(headings:, rows:)
@headings = headings
@rows = rows
end
def to_s
CSV.generate(**csv_options, headers: headings) do |csv|
rows.each { |row| csv << row }
end
end
priva... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | spec/spec_helper.rb | Ruby | mit | 19 | main | 471 | require "bundler/setup"
require "rspec_overview"
require "support/formatter_helpers"
RSpec.configure do |config|
config.example_status_persistence_file_path = ".rspec_status"
config.disable_monkey_patching!
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.mock_with :rspec do |mocks|
m... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | spec/rspec_overview/formatter_csv_spec.rb | Ruby | mit | 19 | main | 1,963 | require "csv"
require "rspec_overview/formatter_csv"
require "support/output_capturer"
RSpec.describe RspecOverview::FormatterCsv, type: :formatter do
let(:output) { OutputCapturer.new }
subject { described_class.new(output) }
describe "summary by spec type" do
it "groups examples by type and sums the execu... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | spec/rspec_overview/formatter_spec.rb | Ruby | mit | 19 | main | 2,717 | require "support/output_capturer"
require "rspec_overview/formatter"
RSpec.describe RspecOverview::Formatter, type: :formatter do
include FormatterHelpers
let(:output) { OutputCapturer.new }
subject { described_class.new(output) }
describe "summary by spec type" do
it "groups examples by type and sums th... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | spec/rspec_overview/output/markdown_table_spec.rb | Ruby | mit | 19 | main | 993 | require "rspec_overview/output/markdown_table"
RSpec.describe RspecOverview::Output::MarkdownTable do
it "generates a markdown table" do
table = described_class.new(
headings: ["Heading", "Longer Heading", "Short"],
rows: [
["Longer row 1A", "Row 1B", "1C"],
["Row 2A", "Row 2B", "2C"]... |
github | odlp/rspec_overview | https://github.com/odlp/rspec_overview | spec/support/formatter_helpers.rb | Ruby | mit | 19 | main | 637 | module FormatterHelpers
def example_double(metadata: {}, run_time: 0.0, file_path: "")
execution_result = instance_double(
RSpec::Core::Example::ExecutionResult,
run_time: run_time,
)
instance_double(
RSpec::Core::Example,
metadata: metadata,
file_path: file_path,
exec... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | Rakefile | Ruby | mit | 19 | master | 909 | require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
Rake::ExtensionTask.new('lexerc') do |config|
config.lib_dir = 'lib/hotcell'
end
task :default => :spec
desc 'Builds all the project'
task :project do
%w(project:lexerr project:lexerc project:... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | Guardfile | Ruby | mit | 19 | master | 1,151 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | Gemfile | Ruby | mit | 19 | master | 283 | source 'https://rubygems.org'
gemspec
gem 'rake'
gem 'rake-compiler'
gem 'awesome_print'
# gem 'ruby-prof'
group :test do
gem 'rspec'
gem 'guard'
gem 'guard-rspec'
gem 'rb-inotify', require: false
gem 'rb-fsevent', require: false
gem 'rb-fchange', require: false
end |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | hotcell.gemspec | Ruby | mit | 19 | master | 836 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hotcell/version'
Gem::Specification.new do |gem|
gem.name = 'hotcell'
gem.version = Hotcell::VERSION
gem.authors = ['pyromaniac']
gem.email = ['kinw... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/spec_helper.rb | Ruby | mit | 19 | master | 1,345 | require 'hotcell'
require 'awesome_print'
AwesomePrint::Formatter.class_eval do
def cast_with_hotcell_node(object, type)
cast = cast_without_hotcell_node(object, type)
cast = :hotcell_node if object.is_a?(Hotcell::Node)
cast
end
def awesome_hotcell_node(object)
"#{colorize(object.class.to_s, :cl... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell_spec.rb | Ruby | mit | 19 | master | 285 | require 'spec_helper'
describe Hotcell do
it { should respond_to :commands }
it { should respond_to :blocks }
it { should respond_to :helpers }
it { should respond_to :register_command }
it { should respond_to :register_helpers }
it { should respond_to :escape_tags }
end |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/source_spec.rb | Ruby | mit | 19 | master | 1,581 | # coding: UTF-8
require 'spec_helper'
describe Hotcell::Source do
subject(:source) { described_class.new('hello', 'file/path') }
describe '.wrap' do
specify { described_class.wrap('hello').should be_a described_class }
specify { described_class.wrap('hello').source.should == 'hello' }
specify { descr... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/scope_spec.rb | Ruby | mit | 19 | master | 4,217 | require 'spec_helper'
describe Hotcell::Scope do
subject { described_class.new }
describe '#initialize' do
its(:scope) { should == [{}] }
specify { described_class.new(foo: 1, 'bar' => 2).send(:scope).should == [{foo: 1, 'bar' => 2}] }
end
describe '#push' do
context do
before { subject.push... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/parser_spec.rb | Ruby | mit | 19 | master | 26,933 | # encoding: UTF-8
require 'spec_helper'
describe Hotcell::Parser do
def method_missing method, *args, &block
klass = Hotcell::Expression::HANDLERS[method] ?
Hotcell::Expression : Hotcell::Node
instance = Hotcell::Assigner.new *args if method == :ASSIGN
instance = Hotcell::Summoner.new *args if met... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/context_spec.rb | Ruby | mit | 19 | master | 3,874 | require 'spec_helper'
describe Hotcell::Context do
its('scope.scope') { should == [{}] }
its(:helpers) { should be_a Hotcell::Tong }
describe '#normalize_options' do
def result options = {}
default = { scope: {}, shared: {}, helpers: [], reraise: false, rescuer: described_class::DEFAULT_RESCUER }
... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/resolver_spec.rb | Ruby | mit | 19 | master | 775 | require 'spec_helper'
describe Hotcell::Resolver do
specify { expect { subject.template 'any/path' }.to raise_error NotImplementedError }
describe '#template' do
let(:dummy) do
Class.new(described_class) do
def resolve path, context = nil
path
end
end
end
subject ... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/tong_spec.rb | Ruby | mit | 19 | master | 2,442 | require 'spec_helper'
describe Hotcell::Tong do
context 'mixed in' do
context do
let(:klass) do
Class.new(Numeric) do
include Hotcell::Tong::Mixin
def foo; end
end
end
subject { klass.new }
its(:tong_methods) { should be_a Set }
its(:tong_method... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/config_spec.rb | Ruby | mit | 19 | master | 2,768 | require 'spec_helper'
describe Hotcell::Config do
subject { Hotcell::Config.send(:new) }
let(:command_class) { Class.new(Hotcell::Command) }
let(:block_class) do
Class.new(Hotcell::Block) do
subcommand :else
subcommand :elsif
end
end
let(:misc_class) { Class.new }
specify { subject.bl... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/lexer_spec.rb | Ruby | mit | 19 | master | 22,741 | # encoding: UTF-8
require 'spec_helper'
describe Hotcell::Lexer do
def scan template
described_class.new(template).tokens.map { |token| [token[0], token[1][0]] }
end
def expression template
scan("{{ #{template} }}")[1..-2]
end
specify { scan('').should == [] }
specify { scan('{{ }}').should == [[... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/template_spec.rb | Ruby | mit | 19 | master | 5,502 | require 'spec_helper'
describe Hotcell::Template do
describe '.parse' do
before do
Hotcell.stub(:commands) { { 'include' => Class.new } }
Hotcell.stub(:blocks) { { 'for' => Class.new } }
end
specify { described_class.parse('').should be_a described_class }
specify { described_class.parse... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/node/block_spec.rb | Ruby | mit | 19 | master | 5,293 | require 'spec_helper'
describe Hotcell::Block do
def method_missing method, *args, &block
klass = Hotcell::Expression::HANDLERS[method] ?
Hotcell::Expression : Hotcell::Node
instance = Hotcell::Assigner.new *args if method == :ASSIGN
instance = Hotcell::Summoner.new *args if method == :METHOD
... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/node/tag_spec.rb | Ruby | mit | 19 | master | 505 | require 'spec_helper'
describe Hotcell::Tag do
let(:context) { Hotcell::Context.new }
context 'complex parsing and rendering' do
def parse source
Hotcell::Template.parse(source)
end
specify { parse("{{ 'Hello' }}").render.should == 'Hello' }
specify { parse("{{! 'Hello' }}").render.should =... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/node/command_spec.rb | Ruby | mit | 19 | master | 1,661 | require 'spec_helper'
describe Hotcell::Command do
let(:context) { Hotcell::Context.new }
context 'complex parsing and rendering' do
def parse source
Hotcell::Template.parse(source)
end
let(:include_tag) do
Class.new(described_class) do
def validate!
raise Hotcell::Argum... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/for_spec.rb | Ruby | mit | 19 | master | 2,567 | require 'spec_helper'
describe Hotcell::Commands::For do
def parse source
Hotcell::Template.parse(source)
end
describe '#validate!' do
specify { expect { parse('{{ for }}{{ end for }}').syntax
}.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `for` (0 for 2) at 1:4' }
spe... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/unless_spec.rb | Ruby | mit | 19 | master | 1,132 | require 'spec_helper'
describe Hotcell::Commands::Unless do
def parse source
Hotcell::Template.parse(source)
end
describe '#validate!' do
specify { expect { parse('{{ unless }}{{ end unless }}').syntax
}.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `unless` (0 for 1) at 1:... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/if_spec.rb | Ruby | mit | 19 | master | 2,417 | require 'spec_helper'
describe Hotcell::Commands::If do
def parse source
Hotcell::Template.parse(source)
end
describe '#validate!' do
specify { expect { parse('{{ if }}{{ end if }}').syntax
}.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `if` (0 for 1) at 1:4' }
specify... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/case_spec.rb | Ruby | mit | 19 | master | 2,784 | require 'spec_helper'
describe Hotcell::Commands::If do
def parse source
Hotcell::Template.parse(source)
end
describe '#validate!' do
specify { expect { parse('{{ case }}{{ end case }}').syntax
}.to raise_error Hotcell::ArgumentError, 'Wrond number of arguments for `case` (0 for 1) at 1:4' }
s... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/cycle_spec.rb | Ruby | mit | 19 | master | 1,345 | require 'spec_helper'
describe Hotcell::Commands::Cycle do
def parse source
Hotcell::Template.parse(source)
end
describe '#normalize_arguments' do
subject { described_class.new 'cycle' }
specify { subject.normalize_arguments([42]).should == [[42], subject.object_id.to_s] }
specify { subject.norm... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/scope_spec.rb | Ruby | mit | 19 | master | 442 | require 'spec_helper'
describe Hotcell::Commands::Scope do
def parse source
Hotcell::Template.parse(source)
end
describe '#render' do
specify { parse(
'{{ count = 42 }} {{ scope count: count + 8 }}{{ count }}{{ end scope }} {{ count }}'
).render.should == '42 50 42' }
specify { parse(
... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | spec/lib/hotcell/commands/include_spec.rb | Ruby | mit | 19 | master | 1,285 | require 'spec_helper'
describe Hotcell::Commands::Include do
def parse source
Hotcell::Template.parse(source)
end
let(:resolver_class) do
Class.new(Hotcell::Resolver) do
attr_reader :templates
def initialize templates
@templates = templates.stringify_keys
end
def resolve... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell.rb | Ruby | mit | 19 | master | 650 | require 'active_support/all'
require 'set'
require 'hotcell/version'
require 'hotcell/resolver'
require 'hotcell/config'
require 'hotcell/errors'
module Hotcell
def self.config; Config.instance; end
singleton_class.delegate :commands, :blocks, :helpers, :register_command, :register_helpers,
:resolver, :resolv... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell/lexerr.rb | Ruby | mit | 19 | master | 19,487 | # line 1 "lib/hotcell/lexerr.rl"
# line 44 "lib/hotcell/lexerr.rl"
Hotcell::Lexer.class_eval do
def current_position
@ts
end
def current_value
@data[@ts...@te].pack(Hotcell::Source::PACK_MODE).force_encoding(@source.encoding)
end
def current_error
value = @data[@ts..@p].pack(Hotcell::Source::... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell/tong.rb | Ruby | mit | 19 | master | 1,157 | module Hotcell
class Tong
module Mixin
extend ActiveSupport::Concern
included do
class_attribute :tong_methods, instance_writter: false
self.tong_methods = Set.new
def self.manipulate *methods
self.tong_methods = Set.new(tong_methods.to_a + methods.flatten.map(&:to_... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell/resolver.rb | Ruby | mit | 19 | master | 1,265 | module Hotcell
# Base template resolving class for `include` command.
# Please inherit your own resolvers from it.
class Resolver
def template path, context = nil
cache(path, context) do
source = resolve path, context
Template.parse(source)
end
end
# Returns template sourc... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell/source.rb | Ruby | mit | 19 | master | 712 | module Hotcell
class Source
PACK_MODE = 'c*'
attr_reader :source, :file
def self.wrap source, *args
source.is_a?(Hotcell::Source) ? source : Source.new(source, *args)
end
def initialize source, file = nil
@source, @file = source, file
end
def encoding
'UTF-8'
end
... |
github | pyromaniac/hotcell | https://github.com/pyromaniac/hotcell | lib/hotcell/errors.rb | Ruby | mit | 19 | master | 1,113 | module Hotcell
class Error < StandardError
end
class ParseError < Error
def initialize value, line, column
@value, @line, @column = value, line, column
super(compose_message)
end
end
class UnexpectedSymbol < ParseError
def compose_message
"Unexpected symbol `#{@value}` at #{@li... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.