repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
Flatiron-group/tenant_verification
app/controllers/landlords_controller.rb
<gh_stars>0 class LandlordsController < ApplicationController def show id = params[:id] landlord = Landlord.find(id) render json: landlord end def create # param keys may subject to change depending on the body of the post request new_landlord = Landlord.new(first_name: params[:first_name], ...
Flatiron-group/tenant_verification
test/controllers/land_lords_controller_test.rb
require 'test_helper' class LandLordsControllerTest < ActionDispatch::IntegrationTest test "should get show" do get land_lords_show_url assert_response :success end test "should get create" do get land_lords_create_url assert_response :success end test "should get update" do get land_lo...
Flatiron-group/tenant_verification
config/routes.rb
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html post "/login", to: "sessions#create" delete "/logout", to: "sessions#destroy" get "/get_current_user", to: "sessions#get_current_user" resources :landlords do resources :a...
Flatiron-group/tenant_verification
app/controllers/tenants_controller.rb
<reponame>Flatiron-group/tenant_verification class TenantsController < ApplicationController def index if !params[:landlord_id] tenants = Tenant.all render json: tenants else tenants = Landlord.find(params[:landlord_id]).tenants render json: tenants end end def show if !pa...
raspimeteo/dutch_top40
lib/dutch_top40/cli.rb
class DutchTop40::CLI def call logo puts "One moment, acquiring data.","" list_songs menu end def list_songs @songs = DutchTop40::Songs.list print_songs puts end def print_songs puts "Dutch Top40 - week #{Time.now.strftime(...
raspimeteo/dutch_top40
lib/dutch_top40/songs.rb
<reponame>raspimeteo/dutch_top40 class DutchTop40::Songs attr_accessor :title, :name, :listed, :last_weeks_rank @@songs = [] def initialize(title, name, listed, last_weeks_rank) @title = title @name = name @listed = listed @last_weeks_rank = last_weeks_rank @@songs...
raspimeteo/dutch_top40
lib/dutch_top40.rb
require_relative "./dutch_top40/version" require 'nokogiri' require 'open-uri' require 'pry' require_relative './dutch_top40/cli' require_relative './dutch_top40/songs' require_relative './dutch_top40/scraper'
raspimeteo/dutch_top40
lib/dutch_top40/scraper.rb
class DutchTop40::Scraper attr_accessor :title, :name, :listed, :last_weeks_rank def self.scrape_songs doc = Nokogiri::HTML(open("http://top40.nl")) doc.search('.listScroller .list-right').each do |song| # binding.pry title = song.css('.songtitle').text.strip ...
johnbintz/sisyphus-rails
lib/sisyphus-rails/form_helper.rb
<gh_stars>1-10 module ActionView module Helpers module FormHelper def form_for_with_sisyphus(record, options = {}, &proc) case record when String, Symbol object_name = record else object = record.is_a?(Array) ? record.last : record object_name = op...
johnbintz/sisyphus-rails
lib/sisyphus-rails/engine.rb
<gh_stars>1-10 module Sisyphus class Engine < ::Rails::Engine initializer "sisyphus-rails.load_config_data" do |app| Sisyphus.setup do |config| config.app_root = app.root #Load the configuration from the environment or a yaml file Sisyphus.config = Hash.new #load the c...
johnbintz/sisyphus-rails
lib/sisyphus-rails/form_tag_helper.rb
module ActionView module Helpers module FormTagHelper def form_tag_with_sisyphus(url_for_options = {}, options = {}, &block) buf = ActiveSupport::SafeBuffer.new if options.has_key?(:id) && Sisyphus::process buf.safe_concat("<script type=\"text/javascript\">$(document).ready(funct...
johnbintz/sisyphus-rails
lib/sisyphus-rails.rb
<filename>lib/sisyphus-rails.rb require "sisyphus-rails/version" require "sisyphus-rails/engine" require "sisyphus-rails/form_helper" require "sisyphus-rails/form_tag_helper" module Sisyphus mattr_accessor :process mattr_accessor :app_root mattr_accessor :config def self.setup yield self end end
johnbintz/sisyphus-rails
lib/generators/sisyphus/configuration/configuration_generator.rb
<gh_stars>1-10 module Sisyphus module Generators class ConfigurationGenerator < ::Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) desc "Creates blank config file for extended configuration." def create_yaml template "sisyphus.yml", "config/sisyphus.yml" ...
johnbintz/sisyphus-rails
sisyphus-rails.gemspec
<gh_stars>1-10 # -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'sisyphus-rails/version' Gem::Specification.new do |gem| gem.name = "sisyphus-rails" gem.version = Sisyphus::Rails::VERSION gem.authors = ["<NAM...
salsify/avrolution
spec/avrolution/compatibility_break_spec.rb
# frozen_string_literal: true describe Avrolution::CompatibilityBreak do let(:name) { 'com.example.test' } let(:fingerprint) do Avro::Schema.parse({ name: name, type: :record }.to_json).sha256_resolution_fingerprint.to_s(16) end before do Avro.disable_schema_name_validation = true if Avro.respond_to?(...
salsify/avrolution
lib/avrolution/version.rb
# frozen_string_literal: true module Avrolution VERSION = '0.7.2' end
salsify/avrolution
spec/avrolution/configuration_spec.rb
# frozen_string_literal: true describe Avrolution, "configuration" do describe "#compatibility_schema_registry_url" do let(:configured_value) { 'http://static.example.com' } subject(:url) do described_class.compatibility_schema_registry_url end before do Avrolution.compatibility_schema_...
salsify/avrolution
lib/avrolution/compatibility_breaks_file.rb
<filename>lib/avrolution/compatibility_breaks_file.rb # frozen_string_literal: true module Avrolution module CompatibilityBreaksFile NONE = 'NONE' class DuplicateEntryError < StandardError def initialize(key) super("duplicate entry for key #{key}") end end def self.path A...
salsify/avrolution
spec/support/contexts/rake_setup.rb
# frozen_string_literal: true require 'rake' shared_context "rake setup" do let(:rake) { Rake::Application.new } let(:task) { rake[task_name] } before do Rake.application = rake Rake.application.rake_require(task_path, $LOAD_PATH, []) Rake::Task.define_task(:environment) end end
salsify/avrolution
spec/avrolution/compatibility_breaks_file_spec.rb
<filename>spec/avrolution/compatibility_breaks_file_spec.rb # frozen_string_literal: true describe Avrolution::CompatibilityBreaksFile, :fakefs do let(:logger) { instance_double(Logger, info: nil) } before do FileUtils.mkdir_p(File.dirname(described_class.path)) end describe ".path" do it "returns th...
salsify/avrolution
lib/avrolution/rake/add_compatibility_break_task.rb
<filename>lib/avrolution/rake/add_compatibility_break_task.rb # frozen_string_literal: true require 'avrolution/rake/base_task' module Avrolution module Rake class AddCompatibilityBreakTask < BaseTask def initialize(**) super @name ||= :add_compatibility_break @task_desc ||= 'Add ...
salsify/avrolution
lib/generators/avrolution/install_generator.rb
<reponame>salsify/avrolution # frozen_string_literal: true require 'rails/generators/base' module Avrolution class InstallGenerator < Rails::Generators::Base source_paths << File.join(__dir__, 'templates') def create_compatibility_breaks_file copy_file('avro_compatibility_breaks.txt') end end e...
salsify/avrolution
spec/avrolution/tasks_spec.rb
# frozen_string_literal: true describe "rake tasks" do include_context "rake setup" let(:task_path) { 'avrolution/rake/rails_avrolution' } describe "register_schemas" do let(:task_name) { 'avro:register_schemas' } let(:schema_files) { ['app.avsc'] } let(:register_schemas) { Avrolution::RegisterSche...
salsify/avrolution
lib/avrolution/compatibility_check.rb
# frozen_string_literal: true require 'avro-resolution_canonical_form' require 'private_attr' require 'diffy' require 'avro_schema_registry-client' module Avrolution class CompatibilityCheck extend PrivateAttr attr_reader :incompatible_schemas NONE = 'NONE' FULL = 'FULL' BOTH = 'BOTH' BACK...
salsify/avrolution
spec/spec_helper.rb
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path('../lib', __dir__) require 'simplecov' SimpleCov.start require 'avrolution' # pp must be required prior to fakefs/spec_helpers require 'pp' require 'fakefs/spec_helpers' require 'rspec/its' Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each {...
salsify/avrolution
lib/avrolution/rake/rails_avrolution.rake
# frozen_string_literal: true require 'avrolution/rake/check_compatibility_task' require 'avrolution/rake/add_compatibility_break_task' require 'avrolution/rake/register_schemas_task' Avrolution::Rake::AddCompatibilityBreakTask.define(dependencies: [:environment]) Avrolution::Rake::CheckCompatibilityTask.define(depen...
salsify/avrolution
lib/avrolution/rake/base_task.rb
# frozen_string_literal: true require 'rake/tasklib' module Avrolution module Rake class BaseTask < ::Rake::TaskLib attr_accessor :name, :task_namespace, :task_desc, :dependencies def self.define(**options, &block) new(**options, &block).define end def initialize(name: nil, de...
salsify/avrolution
lib/avrolution/configuration.rb
<filename>lib/avrolution/configuration.rb # frozen_string_literal: true module Avrolution COMPATIBILITY = 'compatibility' DEPLOYMENT = 'deployment' class << self # Root directory to search for schemas, and default location for # compatibility breaks file attr_writer :root # Path to the compati...
salsify/avrolution
lib/avrolution/rake/check_compatibility_task.rb
# frozen_string_literal: true require 'avrolution/rake/base_task' module Avrolution module Rake class CheckCompatibilityTask < BaseTask def initialize(**) super @name ||= :check_compatibility @task_desc ||= 'Check that all Avro schemas are compatible with latest registered in prod...
salsify/avrolution
spec/avrolution/register_schemas_spec.rb
<reponame>salsify/avrolution # frozen_string_literal: true describe Avrolution::RegisterSchemas, :fakefs do let(:schema_registry) { instance_double(AvroSchemaRegistry::Client) } let(:logger) { instance_double(Logger, info: nil) } let(:app_schema_path) { File.join(Avrolution.root, 'avro/schema') } let(:schema_f...
salsify/avrolution
lib/avrolution/railtie.rb
# frozen_string_literal: true module Avrolution class Railtie < Rails::Railtie initializer 'avrolution.configure' do Avrolution.configure do |config| config.root = Rails.root end end rake_tasks do load File.expand_path('rake/rails_avrolution.rake', __dir__) end end end
salsify/avrolution
lib/avrolution.rb
<gh_stars>0 # frozen_string_literal: true require 'avrolution/version' require 'logger' module Avrolution class PassthruLogger < Logger def initialize(*) super @formatter = ->(_severity, _time, _progname, msg) { "#{msg}\n" } end end end require 'active_support/core_ext/object/try' require 'av...
salsify/avrolution
lib/avrolution/register_schemas.rb
<filename>lib/avrolution/register_schemas.rb<gh_stars>0 # frozen_string_literal: true require 'avro_schema_registry-client' require 'private_attr' require 'procto' module Avrolution class RegisterSchemas extend PrivateAttr include Procto.call attr_reader :schema_files private_attr_reader :compatib...
salsify/avrolution
spec/avrolution/compatibility_check_spec.rb
# frozen_string_literal: true describe Avrolution::CompatibilityCheck, :fakefs do let(:schema_registry) { instance_double(AvroSchemaRegistry::Client) } let(:app_schema_path) { File.join(Avrolution.root, 'avro/schema') } let(:logger) { instance_double(Logger, info: nil) } let(:not_found_error) { Excon::Errors::...
salsify/avrolution
lib/avrolution/rake/register_schemas_task.rb
# frozen_string_literal: true require 'avrolution/rake/base_task' module Avrolution module Rake class RegisterSchemasTask < BaseTask def initialize(**) super @name ||= :register_schemas @task_desc ||= 'Register the specified Avro JSON schemas' end private def p...
salsify/avrolution
lib/avrolution/compatibility_break.rb
<reponame>salsify/avrolution # frozen_string_literal: true require 'active_model' module Avrolution class CompatibilityBreak include ActiveModel::Validations ValidationError = Class.new(StandardError) VALID_COMPATIBILITY_VALUES = [ 'BACKWARD', 'BACKWARD_TRANSITIVE', 'FORWARD', ...
LorTos/BottomDrawerView
BottomDrawerView.podspec
<filename>BottomDrawerView.podspec # # Be sure to run `pod spec lint BottomDrawerView.podspec' to ensure this is a # valid spec and to remove all comments including this before submitting the spec. # # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html # To see working Podsp...
salonlofts/spring-commands-specjour
lib/spring-commands-specjour.rb
<filename>lib/spring-commands-specjour.rb if defined?(Spring.register_command) require "spring/commands/specjour" end
salonlofts/spring-commands-specjour
lib/spring/commands/specjour.rb
module Spring module Commands class Specjour def env(*) 'test' end def exec_name 'specjour' end end Spring.register_command 'specjour', Specjour.new end end
cbenattrue/INDEX
SY_20190727.rb
# # DB Script Tool # Ruby - 2019-07-27 11:00:03 # # MODEL CLASSES FOR SY DATABASE #!/usr/bin/ruby # SY.rb ------------------------------------- # # Ruby - Model Class - SY.SY # 2019-07-27 10:57:35 # class SY #attr_accessor :SY # # Constructor # # Example: # mySY = SY.new( val1, va...
suvajitgupta/Tasks
proxy-patch.rb
<filename>proxy-patch.rb require 'net/http' require 'net/https' RootCA = '/etc/ssl/certs' module SC module Rack # Rack application proxies requests as needed for the given project. class Proxy def initialize(project) @project = project @proxies = project.buildfile.pro...
suvajitgupta/Tasks
spec/login.rb
<gh_stars>1-10 # Tasks/Lebowski login tests # Author: <NAME>, <NAME> describe "Login using bad user name should fail" do it "will confirm that an error message is displayed on a failed login attempt" do App['login_panel'].should be_pane_attached App['login_panel.login_error_message_label'].should have_value '...
suvajitgupta/Tasks
spec/main.rb
# Tasks/Lebowski login tests # Author: <NAME>, <NAME> App = MainApplication.new \ :app_root_path => "/tasks", :app_name => "Tasks", :app_server_port => 4400, :browser => :safari App.start do |app| app['isLoaded'] == true # app.driver.run_script "window.ononbeforeunload = nu...
suvajitgupta/Tasks
spec/config.rb
# Tasks/Lebowski login tests # Author: <NAME>, <NAME> App.define_path 'mainPane', 'mainPage.mainPane', MainPane USER_NAME = "SA" PASSWORD = "" USER_ROLE = "Manager" NEWUSERLOGINNAME = "guest" NEWUSERFULLNAME = "Guest User" App.define_framework 'core_tasks', 'CoreTasks' App.define_path 'login_panel', 'loginPage.pan...
Tonkpils/celluloid-eventsource
spec/celluloid/eventsource/response_parser_spec.rb
require 'spec_helper' RSpec.describe Celluloid::EventSource::ResponseParser do let(:success_headers) {<<-eos HTTP/1.1 200 OK Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT Content-Type: text/html; charset=UTF-8 Content-Length: 131 X_CASE_HEADER: foo X_Mixed-Case: bar x-lowcase-header: hello eos } let(:error_header...
Tonkpils/celluloid-eventsource
lib/celluloid/eventsource/version.rb
<reponame>Tonkpils/celluloid-eventsource module Celluloid class EventSource VERSION = "0.3.0" end end
Tonkpils/celluloid-eventsource
lib/celluloid/eventsource/response_parser.rb
require 'http/parser' module Celluloid class EventSource class ResponseParser extend Forwardable attr_reader :headers delegate [:status_code, :<<] => :@parser def initialize @parser = Http::Parser.new(self) @headers = nil @chunk = "" end def heade...
Tonkpils/celluloid-eventsource
lib/celluloid/eventsource.rb
<gh_stars>1-10 require "celluloid/eventsource/version" require 'celluloid/io' require 'celluloid/eventsource/response_parser' require 'uri' module Celluloid class EventSource include Celluloid::IO attr_reader :url, :with_credentials attr_reader :ready_state CONNECTING = 0 OPEN = 1 CLOSED = ...
Tonkpils/celluloid-eventsource
spec/support/dummy_server.rb
require 'webrick' require 'atomic' require 'json' require 'support/black_hole' class DummyServer < WEBrick::HTTPServer CHUNK_SIZE = 100 CONFIG = { :BindAddress => '127.0.0.1', :Port => 5000, :AccessLog => BlackHole, :Logger => BlackHole, :DoNotListen => true, ...
anotheren/SwiftyHash
SwiftyHash.podspec
Pod::Spec.new do |s| s.name = "SwiftyHash" s.version = "1.0" s.summary = "A Swifty wrapper for CommonCrypto" s.homepage = "https://github.com/anotheren/SwiftyHash" s.license = { :type => "MIT" } s.author = { "liudong" => "<EMAIL>" } s.requires_arc = true s.ios.deploymen...
rails753developer/find_mass_assignment
lib/tasks/find_mass_assignment_tasks.rake
<reponame>rails753developer/find_mass_assignment<filename>lib/tasks/find_mass_assignment_tasks.rake desc "Find potential mass assignment vulnerabilities" task :find_mass_assignment do require File.join(File.dirname(__FILE__), "../find_mass_assignment.rb") MassAssignment.find end
rails753developer/find_mass_assignment
lib/unsafe_build_and_create.rb
class ActiveRecord::Base # Build and create records unsafely, bypassing attr_accessible. # These methods are especially useful in tests and in the console. # Inspired in part by http://pastie.textmate.org/104042 class << self # Make a new record unsafely. # This replaces new/build. For example,...
rails753developer/find_mass_assignment
init.rb
require File.join(File.dirname(__FILE__), "lib", "unsafe_build_and_create")
wvk/railsdav
lib/railsdav/renderer.rb
# encoding: utf-8 require 'builder' if Rails.version > '4.0' require 'active_support' require 'active_support/core_ext/hash/conversions' end module Railsdav class Renderer autoload :ResourceDescriptor, 'railsdav/renderer/resource_descriptor' autoload :ResponseCollector, 'railsdav/renderer/respons...
wvk/railsdav
lib/railsdav/renderer/response_type_selector.rb
<filename>lib/railsdav/renderer/response_type_selector.rb # encoding: utf-8 module Railsdav class Renderer class ResponseTypeSelector attr_reader :subresources, :resource_options def initialize(controller, request_format) @controller, @request_format = controller, request_format @sub...
ChrisWilding/merchants-guide-to-the-galaxy
spec/converters/roman_to_arabic_converter_spec.rb
require 'spec_helper' RSpec.describe Merchant::RomanToArabicConverter do examples = { 'I' => 1, 'II' => 2, 'III' => 3, 'IV' => 4, 'V' => 5, 'VI' => 6, 'IX' => 9, 'XXVII' => 27, 'XLVIII' => 48, 'LIX' => 59, 'XCIII' => 93, 'CXXIII' => 123, 'CXLI' => 141, 'CLXIII'...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/commodity_conversion.rb
<gh_stars>0 module Merchant class CommodityConversion attr_reader :from_commodity, :to_commodity, :galactic def initialize(from_commodity, to_commodity, galactic) @from_commodity = from_commodity @to_commodity = to_commodity @galactic = galactic end end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant.rb
require 'merchant/converters/roman_to_arabic_converter' require 'merchant/models/commodity' require 'merchant/parser' require 'merchant/version' %w[nodes services].each do |dir| Dir["#{File.dirname(__FILE__)}/merchant/#{dir}/*.rb"].each do |file| require file end end require 'merchant/galactic_trade' require ...
ChrisWilding/merchants-guide-to-the-galaxy
spec/services/galatic_to_roman_service_spec.rb
require 'spec_helper' RSpec.describe Merchant::GalacticToRomanService do context 'handles?' do it 'returns true for TranslationDefinition nodes' do node = Merchant::TranslationDefinition.new('glob', 'I') expect(subject.handles?(node)).to be_truthy end it 'returns false for other nodes' do ...
ChrisWilding/merchants-guide-to-the-galaxy
spec/models/commodity_spec.rb
require 'spec_helper' RSpec.describe Merchant::Commodity do let(:name) { 'Sausages' } subject { described_class.new(450, name, 4950) } it 'has a name' do expect(subject.name).to eq(name) end it 'returns the unit price in credits' do expect(subject.credits).to eq(11) end context 'when the unit ...
ChrisWilding/merchants-guide-to-the-galaxy
spec/services/galatic_to_arabic_service_spec.rb
<reponame>ChrisWilding/merchants-guide-to-the-galaxy require 'spec_helper' RSpec.describe Merchant::GalacticToArabicService do subject do galactic_to_roman_service = Merchant::GalacticToRomanService.new nodes = [ Merchant::TranslationDefinition.new('glob', 'I'), Merchant::TranslationDefinition.ne...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/services/price_query_service.rb
module Merchant class PriceQueryService def initialize(galactic_to_arabic_service, price_definition_service) @galactic_to_arabic_service = galactic_to_arabic_service @price_definition_service = price_definition_service end def handles?(node) node.is_a?(PriceQuery) end def proce...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/translation_definition.rb
<gh_stars>0 module Merchant class TranslationDefinition attr_reader :galactic, :roman def initialize(galactic, roman) @galactic = galactic @roman = roman end end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/services/galactic_to_roman_service.rb
<reponame>ChrisWilding/merchants-guide-to-the-galaxy module Merchant class GalacticToRomanService def initialize @lookup = {} end def handles?(node) node.is_a?(TranslationDefinition) end def process(node) @lookup[node.galactic] = node.roman nil end def translate_...
ChrisWilding/merchants-guide-to-the-galaxy
spec/nodes/translation_definition_spec.rb
require 'spec_helper' RSpec.describe Merchant::TranslationDefinition do subject do described_class.new('prok', 'V') end it 'has a galactic property' do expect(subject.galactic).to eq('prok') end it 'has a roman property' do expect(subject.roman).to eq('V') end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/translation_query.rb
<filename>lib/merchant/nodes/translation_query.rb module Merchant class TranslationQuery attr_reader :galactic def initialize(galactic) @galactic = galactic end end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/price_definition.rb
<filename>lib/merchant/nodes/price_definition.rb module Merchant class PriceDefinition attr_reader :commodity, :credits, :galactic def initialize(galactic, commodity, credits) @galactic = galactic @commodity = commodity @credits = credits end end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/unknown_defintion_or_query.rb
<filename>lib/merchant/nodes/unknown_defintion_or_query.rb module Merchant class UnknownDefinitionOrQuery end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/parser.rb
require 'strscan' module Merchant class Parser COMMODITY_CONVERSION = /how many .* is .* \?/ NEWLINE = /\n/ NEWLINE_OR_EOS = /#{NEWLINE}|$/ PRICE_DEFINITION = /^.* is \d+ Credits$/ PRICE_QUERY = /^how many Credits is .* \?$/ ROMAN = /I|V|X|L|C|D|M/ IS = / is / TRANSLATION_DEFINITION =...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/services/galactic_to_arabic_service.rb
<gh_stars>0 module Merchant class GalacticToArabicService def initialize(galactic_to_roman_service) @roman_to_arabic_converter = RomanToArabicConverter.new @galactic_to_roman_service = galactic_to_roman_service end def convert(galactic) roman = @galactic_to_roman_service.translate_numer...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/cli.rb
module Merchant class CLI def run if ARGV.length == 1 input = File.read(ARGV[0]) galactic_trade = GalacticTrade.new puts galactic_trade.conduct(input) else puts 'Usage: merchant ./path/to/input.txt' end end end end
ChrisWilding/merchants-guide-to-the-galaxy
spec/galatic_trade_spec.rb
<reponame>ChrisWilding/merchants-guide-to-the-galaxy require 'spec_helper' RSpec.describe Merchant::GalacticTrade do input = 'glob is I prok is V pish is X tegj is L glob glob Silver is 34 Credits glob prok Gold is 57800 Credits pish pish Iron is 3910 Credits how much is pish tegj glob glob ? how many Credits is glo...
ChrisWilding/merchants-guide-to-the-galaxy
spec/nodes/unknown_defintion_or_translation_spec.rb
<gh_stars>0 require 'spec_helper' RSpec.describe Merchant::UnknownDefinitionOrQuery do end
ChrisWilding/merchants-guide-to-the-galaxy
spec/nodes/price_query_spec.rb
require 'spec_helper' RSpec.describe Merchant::PriceQuery do subject do described_class.new('glob glob', 'Silver') end it 'has a commodity property' do expect(subject.commodity).to eq('Silver') end it 'has a galactic property' do expect(subject.galactic).to eq('glob glob') end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/models/commodity.rb
<reponame>ChrisWilding/merchants-guide-to-the-galaxy<filename>lib/merchant/models/commodity.rb<gh_stars>0 require 'bigdecimal' module Merchant class Commodity attr_reader :credits, :name def initialize(number, name, credits) @credits = BigDecimal.new(credits) / BigDecimal.new(number) @name = nam...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/services/unknown_definition_or_query_service.rb
module Merchant class UnknownDefinitionOrQueryService def handles?(node) node.is_a?(UnknownDefinitionOrQuery) end def process(_) 'I have no idea what you are talking about' end end end
ChrisWilding/merchants-guide-to-the-galaxy
spec/cli_spec.rb
require 'spec_helper' RSpec.describe Merchant::CLI do expected = 'pish tegj glob glob is 42 atre mpor hnga is 1600 glob prok Silver is 68 Credits glob prok Gold is 57800 Credits glob prok Iron is 782 Credits I have no idea what you are talking about' it 'loads the file and conducts the galactic trade' do ARGV...
ChrisWilding/merchants-guide-to-the-galaxy
spec/services/price_definition_service_spec.rb
require 'spec_helper' RSpec.describe Merchant::PriceDefinitionService do subject do galactic_to_roman_service = Merchant::GalacticToRomanService.new galactic_to_roman_service.process( Merchant::TranslationDefinition.new('glob', 'I') ) galactic_to_arabic_service = Merchant::GalacticToArabicServi...
ChrisWilding/merchants-guide-to-the-galaxy
spec/nodes/commodity_conversion_spec.rb
RSpec.describe Merchant::CommodityConversion do subject do described_class.new('Silver', 'Gold', 'glob') end it 'has a from commodity property' do expect(subject.from_commodity).to eq('Silver') end it 'has a to commodity property' do expect(subject.to_commodity).to eq('Gold') end it 'has a ...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/services/price_definition_service.rb
module Merchant class PriceDefinitionService def initialize(galactic_to_arabic_service) @galactic_to_arabic_service = galactic_to_arabic_service @lookup = {} end def handles?(node) node.is_a?(PriceDefinition) end def process(node) arabic = @galactic_to_arabic_service.conv...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/converters/roman_to_arabic_converter.rb
module Merchant class RomanToArabicConverter MAPPING = { 'M' => 1000, 'CM' => 900, 'D' => 500, 'CD' => 400, 'C' => 100, 'XC' => 90, 'L' => 50, 'XL' => 40, 'X' => 10, 'IX' => 9, 'V' => 5, 'IV' => 4, 'I' => 1 }.freeze def initia...
ChrisWilding/merchants-guide-to-the-galaxy
spec/services/price_query_service_spec.rb
require 'spec_helper' RSpec.describe Merchant::PriceQueryService do subject do galactic_to_roman_service = Merchant::GalacticToRomanService.new galactic_to_roman_service.process( Merchant::TranslationDefinition.new('glob', 'I') ) galactic_to_roman_service.process( Merchant::TranslationDef...
ChrisWilding/merchants-guide-to-the-galaxy
spec/nodes/translation_query_spec.rb
<gh_stars>0 require 'spec_helper' RSpec.describe Merchant::TranslationQuery do let(:galactic) { 'prok' } subject do described_class.new(galactic) end it 'has a galactic property' do expect(subject.galactic).to eq(galactic) end end
ChrisWilding/merchants-guide-to-the-galaxy
spec/services/unknown_definition_or_query_service.rb
<gh_stars>0 require 'spec_helper' RSpec.describe Merchant::UnknownDefinitionOrQueryService do context 'handles?' do it 'returns true for UnknownDefinitionOrQuery nodes' do node = Merchant::UnknownDefinitionOrQuery.new expect(subject.handles?(node)).to be_truthy end it 'returns false for oth...
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/nodes/price_query.rb
<filename>lib/merchant/nodes/price_query.rb module Merchant class PriceQuery attr_reader :commodity, :galactic def initialize(galactic, commodity) @galactic = galactic @commodity = commodity end end end
ChrisWilding/merchants-guide-to-the-galaxy
lib/merchant/galactic_trade.rb
<gh_stars>0 module Merchant class GalacticTrade def initialize @galactic_to_roman_service = GalacticToRomanService.new @galactic_to_arabic_service = GalacticToArabicService.new( @galactic_to_roman_service ) @price_definition_service = PriceDefinitionService.new( @galactic_t...
ChrisWilding/merchants-guide-to-the-galaxy
spec/merchant_spec.rb
<gh_stars>0 require 'spec_helper' RSpec.describe Merchant do it 'has a version number' do expect(Merchant::VERSION).not_to be nil end end
ChrisWilding/merchants-guide-to-the-galaxy
spec/parser_spec.rb
require 'spec_helper' RSpec.describe Merchant::Parser do it 'parses a translation definition' do parser = described_class.new('prok is V') translation_definition = parser.parse.first expect(translation_definition.galactic).to eq('prok') expect(translation_definition.roman).to eq('V') end it 'par...
rajat2502/WikiEduDashboard
config/schedule.rb
<filename>config/schedule.rb # Use this file to easily define all of your cron jobs. # # It's helpful, but not entirely necessary to understand cron before proceeding. # http://en.wikipedia.org/wiki/Cron # Example: # # set :output, '/path/to/my/cron_log.log' # # every 2.hours do # command '/usr/bin/some_great_comman...
rajat2502/WikiEduDashboard
spec/features/multiwiki_assignment_spec.rb
<filename>spec/features/multiwiki_assignment_spec.rb<gh_stars>1-10 # frozen_string_literal: true require 'rails_helper' describe 'multiwiki assignments', type: :feature, js: true do let(:admin) { create(:admin) } let(:course) { create(:course, submitted: true) } let(:user) { create(:user) } before do pag...
rajat2502/WikiEduDashboard
app/workers/term_recap_email_worker.rb
<gh_stars>1-10 # frozen_string_literal: true class TermRecapEmailWorker include Sidekiq::Worker sidekiq_options unique: :until_executed def self.send_email(course:, campaign:) perform_async(course.id, campaign.id) end def perform(course_id, campaign_id) course = Course.find(course_id) campaign ...
rajat2502/WikiEduDashboard
spec/presenters/special_users_spec.rb
# frozen_string_literal: true require 'rails_helper' require_relative '../../app/presenters/special_users' describe SpecialUsers do let(:user) { create(:user) } describe 'Wikipedia Expert roles' do let(:role) { 'wikipedia_experts' } it 'can be added and removed' do expect(described_class.wikipedia...
rajat2502/WikiEduDashboard
setup/populate_dashboard.rb
# frozen_string_literal: true require_dependency "#{Rails.root}/lib/importers/user_importer" require_dependency "#{Rails.root}/app/services/update_course_stats" # Set up some example data in the dashboard def populate_dashboard puts "setting up example courses..." artfeminism_2018 = Campaign.find_by_slug('artfemin...
rajat2502/WikiEduDashboard
spec/features/students_page_spec.rb
<reponame>rajat2502/WikiEduDashboard<filename>spec/features/students_page_spec.rb<gh_stars>1-10 # frozen_string_literal: true require 'rails_helper' require "#{Rails.root}/lib/wiki_edits" # Wait one second after loading a path # Allows React to properly load the page # Remove this after implementing server-side rende...
rajat2502/WikiEduDashboard
app/controllers/alerts_controller.rb
# frozen_string_literal: true class AlertsController < ApplicationController before_action :require_signed_in, only: [:create] before_action :require_admin_permissions, only: [:resolve] before_action :set_alert, only: [:resolve] # Creates only NeedHelpAlert. Doesn't require admin permission. # Other type of...
rajat2502/WikiEduDashboard
lib/tasks/courses_wikis.rake
# frozen_string_literal: true namespace :courses_wikis do desc 'Creates CoursesWikis association for existing courses through revisions' task migrate: :environment do Rails.logger.debug 'Creating CoursesWikis associations' default_wiki_id = if Features.wiki_ed? [] ...
rajat2502/WikiEduDashboard
app/models/wiki_content/category.rb
<reponame>rajat2502/WikiEduDashboard # frozen_string_literal: true # == Schema Information # # Table name: categories # # id :bigint(8) not null, primary key # wiki_id :integer # article_titles :text(16777215) # name :string(255) # depth :integer default(0) # ...
rajat2502/WikiEduDashboard
app/views/revision_analytics/recent_uploads.json.jbuilder
<gh_stars>100-1000 # frozen_string_literal: true json.uploads @uploads do |upload| json.call(upload, :id, :uploaded_at, :usage_count, :url, :thumburl) json.file_name pretty_filename(upload) json.uploader upload.user.username end
rajat2502/WikiEduDashboard
lib/alerts/dyk_nomination_monitor.rb
<reponame>rajat2502/WikiEduDashboard # frozen_string_literal: true require_dependency "#{Rails.root}/lib/importers/category_importer" # This class identifies articles that have been nominated # for the Did You Know process on English Wikipedia class DYKNominationMonitor def self.create_alerts_for_course_articles ...
rajat2502/WikiEduDashboard
app/models/training_library.rb
<filename>app/models/training_library.rb<gh_stars>1-10 # frozen_string_literal: true # == Schema Information # # Table name: training_libraries # # id :bigint(8) not null, primary key # name :string(255) # wiki_page :string(255) # introduction :text(65535) # cate...