repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
nerdgeschoss/pixelpress
lib/generators/pixelpress/printer/templates/initializer.rb
Rails.application.config.autoload_paths << Rails.root.join('app', 'printers') Rails.application.config.autoload_paths << Rails.root.join('spec', 'printer', 'previews') if Rails.env.development?
nerdgeschoss/pixelpress
lib/pixelpress.rb
require 'pixelpress/version' require 'pixelpress/base' require 'pixelpress/document' require 'pixelpress/engine' if defined? Rails require 'pixelpress/preview' if defined? Rails module Pixelpress end
nerdgeschoss/pixelpress
spec/lib/generators/test/generator_spec/test_destination/app/printers/auth/user_printer.rb
class Auth::UserPrinter < ApplicationPrinter def user_data #put your code here, if you want :) end end
nerdgeschoss/pixelpress
spec/spec_helper.rb
<filename>spec/spec_helper.rb<gh_stars>1-10 require 'bundler/setup' require 'pixelpress' require 'pixelpress/base' require 'pry' require 'active_model' require 'weasyprint' require 'generator_spec' require 'rails/generators' require 'rails/generators/named_base' require 'generators/pixelpress/printer/printer_generator'...
nerdgeschoss/pixelpress
lib/generators/rspec/templates/preview.rb
class <%= class_name %>Preview < Pixelpress::Preview<% passed_methods.each do |m| %> def <%= m %> <%= class_name %>Printer.<%= m %> end<% end %> end
nerdgeschoss/pixelpress
lib/pixelpress/renderers/weasyprint_renderer.rb
<filename>lib/pixelpress/renderers/weasyprint_renderer.rb require 'weasyprint' class Pixelpress::WeasyPrintRenderer def render(html) WeasyPrint.new(html).to_pdf end end
nerdgeschoss/pixelpress
lib/generators/pixelpress/printer/printer_generator.rb
module Pixelpress module Generators class PrinterGenerator < ::Rails::Generators::NamedBase source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) argument :passed_methods, type: :array, default: [], required: false, banner: 'method_name1 method_name2 ...' check_class_col...
nerdgeschoss/pixelpress
config/routes.rb
Pixelpress::Engine.routes.draw do resources :printers, only: [:index] do get ':id', to: 'printers#show' end end
nerdgeschoss/pixelpress
spec/pixelpress_spec.rb
<gh_stars>1-10 require 'spec_helper' describe Pixelpress do let(:renderer) { TestRenderer.new } before(:each) do ActionController::Base.view_paths << File.join(spec_root) InvoicePrinter.default_renderer = renderer end class InvoicePrinter < Pixelpress::Base def invoice end def file_name ...
nerdgeschoss/pixelpress
lib/pixelpress/engine.rb
module Pixelpress class Engine < ::Rails::Engine isolate_namespace Pixelpress end end
nerdgeschoss/pixelpress
lib/pixelpress/instance_invocation.rb
<filename>lib/pixelpress/instance_invocation.rb module Pixelpress module InstanceInvocation def method_missing(m, *args, &block) return super unless respond_to_missing?(m) instance = new instance.instance_variable_set :@template_name, m.to_s instance.send(m, *args) instance.document ...
nerdgeschoss/pixelpress
lib/generators/pixelpress/printer/templates/application_printer.rb
class ApplicationPrinter < Pixelpress::Base layout 'printer' end
nerdgeschoss/pixelpress
lib/pixelpress/document.rb
<gh_stars>1-10 require_relative 'fake_file' module Pixelpress class Document attr_reader :html attr_reader :file_name def initialize(html, renderer, options = {}) @html = html @renderer = renderer @file_name = options[:file_name] end def pdf FakeFile.new pdf_data, origin...
nerdgeschoss/pixelpress
lib/generators/rspec/printer_generator.rb
<reponame>nerdgeschoss/pixelpress module Rspec module Generators class PrinterGenerator < ::Rails::Generators::NamedBase source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) argument :passed_methods, type: :array, default: [], required: false, banner: 'method_name1 method_name...
myokoym/gominohi
lib/gominohi/sources.rb
# -*- coding: utf-8 -*- module Gominohi SOURCES = [ { name: "chuo_1", areas: [ "中央区 南4条西7丁目・8丁目(南4条通の南側のみ),札幌センター1", "中央区 南5条~8条の西7丁目・8丁目(南7条西8丁目1024番地を除く),札幌センター1", "中央区 南9条西4丁目~6丁目(南9条通の南側のみ),札幌センター1", "中央区 南9条西7丁目~12丁目,札幌センター1", "中央区 南10条~13条の西5丁目~12丁目,札幌センター...
myokoym/gominohi
lib/gominohi.rb
require "gominohi/generator" require "gominohi/sources" require "gominohi/version"
myokoym/gominohi
lib/gominohi/command.rb
# -*- coding: utf-8 -*- require "thor" require "gominohi/generator" require "gominohi/sources" require "gominohi/version" module Gominohi class Command < Thor map "-v" => :version map "-g" => :generate desc "version", "Show version number." def version puts Gominohi::VERSION end desc ...
myokoym/gominohi
lib/gominohi/generator.rb
# -*- coding: utf-8 -*- require "date" require "gominohi/sources" module Gominohi class Generator class << self SOURCES.each do |source| define_method(source[:name]) do |begin_date = source[:begin_date], end_date = source[:end_date], ...
myokoym/gominohi
test/test-generator.rb
require "gominohi/generator" class GominohiGeneratorTest < Test::Unit::TestCase def test_leaf_in_december expected = [ "白石区 東札幌○条○丁目,札幌センター1,火 金,20141204,,水,,月", "白石区 菊水○条○丁目,札幌センター1,火 金,20141204,,水,,月", "白石区 菊水上町○条○丁目,札幌センター1,火 金,20141204,,水,,月", ] special_order = [:leaf] assert_e...
Flowspace-Team/omniauth-amazon-sp-api
lib/omniauth-amazon-sp-api.rb
<filename>lib/omniauth-amazon-sp-api.rb require 'omniauth/amazon-sp-api'
Flowspace-Team/omniauth-amazon-sp-api
lib/omniauth/amazon-sp-api.rb
require "omniauth/amazon-sp-api/version" require "omniauth/strategies/amazon-sp-api"
ablignaut/PagedList
rakefile.rb
<filename>rakefile.rb require 'albacore' # >= 0.2.7 require 'fileutils' load './version.rb' task :default => [:build] assemblyinfo :generate_pagedlist_assemblyinfo do |asm| asm.version = PAGEDLIST_VERSION asm.company_name = "<NAME>" asm.product_name = "PagedList" asm.title = "PagedList" asm.description = "P...
ablignaut/PagedList
version.rb
PAGEDLIST_VERSION = '1.14' PAGEDLIST_MVC_VERSION = '3.14'
ykominami/genx
lib/genx/plugin.rb
module Genx class Plugin def initialize(args) end def run end end end
ykominami/genx
lib/genx/util.rb
<gh_stars>0 module Genx # Utility class class Util class << self def get_file_content(file_path) get_file_content_lines(file_path).join("\n") end def get_file_content_lines(file_path) File.readlines(file_path).select{ |l| l !~ /^(\s*)#/ }.map(&:chomp) end end # Returns the current time in m...
ykominami/genx
lib/genx/varsplugin.rb
module Genx class VarsPlugin < Plugin def initialize(argv1) @argvx1 = argv1 @yaml_file = @argvx1[1] @templ_file = @argvx1[2] @templ_vars_file = @argvx1[3] templ_pn = Pathname.new(@templ_file) @templ_content = Util.get_file_content(templ_pn) templ_vars_pn = Pathname.new(@templ_vars_file) @tem...
ykominami/genx
spec/genx_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe Genx do it "has a version number" do expect(Genx::VERSION).not_to be nil end context "create instance" do before(:all) do home_dir = '/home/ykominami' home_pn = Pathname.new(home_dir) home_genx_pn =home_pn.join('.genx')...
ykominami/genx
spec2/tea_spec.rb
class Tea def flavor 'earl gray' end def temperature 250 end end RSpec.configure do |config| config.example_status_persistence_file_path = 'spec/example.txt' end RSpec.describe Tea do let(:tea) { Tea.new } it 'tastes like Earl Gray' do expect(tea.flavor).to eq('earl gray') end it 'is hot' do expe...
ykominami/genx
lib/genx.rb
<reponame>ykominami/genx<filename>lib/genx.rb # frozen_string_literal: true require_relative "genx/version" require_relative "genx/genx" require_relative "genx/util" require_relative "genx/plugin" require_relative "genx/varsplugin" module Genx class Error < StandardError; end # Your code goes here... end
ykominami/genx
lib/genx/genx.rb
<filename>lib/genx/genx.rb # frozen_string_literal: true module Genx require 'erubis' require 'pathname' require 'yaml' class Genx def initialize(argvx) plugin_name = argvx[0] module_name = "Genx" plugin_classname = plugin_name.capitalize + 'Plugin' plugin_classname_with_ns = [module_name , plugin_n...
jschmid/UpdatePlistFromStrings-fastlane-plugin
lib/fastlane/plugin/updateplistfromstrings/actions/updateplistfromstrings_action.rb
<filename>lib/fastlane/plugin/updateplistfromstrings/actions/updateplistfromstrings_action.rb module Fastlane module Actions class UpdateplistfromstringsAction < Action def self.run(params) input_file = params[:translations_source_file] target_file = params[:info_plist_strings_target_file] ...
jschmid/UpdatePlistFromStrings-fastlane-plugin
lib/fastlane/plugin/updateplistfromstrings/helper/updateplistfromstrings_helper.rb
module Fastlane module Helper class UpdateplistfromstringsHelper # class methods that you define here become available in your action # as `Helper::UpdateplistfromstringsHelper.your_method` # end end end
jschmid/UpdatePlistFromStrings-fastlane-plugin
lib/fastlane/plugin/updateplistfromstrings/version.rb
<gh_stars>1-10 module Fastlane module Updateplistfromstrings VERSION = "1.0.2" end end
jschmid/UpdatePlistFromStrings-fastlane-plugin
spec/updateplistfromstrings_action_spec.rb
<filename>spec/updateplistfromstrings_action_spec.rb describe Fastlane::Actions::UpdateplistfromstringsAction do end
tka/rails-with-webpack
app/helpers/webpack_helper.rb
<reponame>tka/rails-with-webpack<filename>app/helpers/webpack_helper.rb<gh_stars>1-10 # rails 整合 webpack 用的 helper # 開發環境要多跑一個 webpack-dev-server require 'open-uri' module WebpackHelper class CantGetResuorceError < StandardError; end def webpack_stylesheet_link_tag(*sources) begin sources = get_webpack_s...
tka/rails-with-webpack
lib/capistrano/tasks/webpack.rake
<gh_stars>1-10 namespace :deploy do namespace :assets do task :webpack do on roles(:web) do within release_path do execute :npm, "install" execute :webpack end end end end end before "deploy:assets:precompile", "deploy:assets:webpack"
mithucste30/solidus_cash_on_delivery
app/models/spree/payment_decorator.rb
Spree::Payment.class_eval do has_one :adjustment, :as => :source, :dependent => :destroy # for Cash on Delivery def build_source return if source_attributes.nil? if payment_method and payment_method.respond_to?(:post_create) payment_method.post_create(self) end if payment_method and pay...
mithucste30/solidus_cash_on_delivery
app/models/spree/payment_method/cash_on_delivery.rb
<reponame>mithucste30/solidus_cash_on_delivery module Spree class PaymentMethod::CashOnDelivery < PaymentMethod def payment_profiles_supported? false # we do not want to show the confirm step end # def post_create(payment) # payment.order.adjustments.each { |a| a.destroy if a.label == I18n.t...
mithucste30/solidus_cash_on_delivery
app/controllers/spree/checkout_controller_decorator.rb
Spree::CheckoutController.class_eval do before_action :pay_on_delivery, only: :update private def pay_on_delivery return unless params[:state] == 'payment' return if params[:order].blank? || params[:order][:payments_attributes].blank? pm_id = params[:order][:payments_attributes].first[:payment_met...
mithucste30/solidus_cash_on_delivery
app/models/spree/shipment_decorator.rb
module Spree Shipment.class_eval do # Determines the appropriate +state+ according to the following logic: # # pending unless order is complete and +order.payment_state+ is +paid+ # shipped if already shipped (ie. does not change the state) # ready all other cases def determine_stat...
mithucste30/solidus_cash_on_delivery
spree_cash_on_delivery.gemspec
<filename>spree_cash_on_delivery.gemspec # encoding: UTF-8 Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'solidus_cash_on_delivery' s.version = '1.2.1' s.summary = 'Solidus Cash On Delivery payment method for countries which provide goods and then collect cash' s.de...
mithucste30/solidus_cash_on_delivery
app/models/spree/app_configuration_decorator.rb
<gh_stars>0 Spree::AppConfiguration.class_eval do preference :cash_on_delivery_charge, :decimal, :default => 5.2 end
richardcalahan/exportr
ext/exportr/extconf.rb
require 'mkmf' create_makefile 'exportr'
richardcalahan/exportr
exportr.gemspec
<reponame>richardcalahan/exportr<gh_stars>1-10 $:.push File.expand_path("../lib", __FILE__) require 'exportr/version' Gem::Specification.new do |gem| gem.name = 'exportr' gem.version = Exportr::VERSION gem.authors = ['<NAME>'] gem.email = ['<EMAIL>'] gem.description = 'Helps m...
richardcalahan/exportr
lib/exportr.rb
begin require 'exportr.bundle' rescue LoadError end begin require 'exportr.so' rescue LoadError end module Exportr; end
richardcalahan/exportr
spec/exportr_spec.rb
<reponame>richardcalahan/exportr<filename>spec/exportr_spec.rb<gh_stars>1-10 require 'spec_helper' describe Exportr do it 'finds configuration file' do File.exists?(Exportr.config_file).should == true end it 'reads configuration file' do Exportr.read['FOO'].should == 'bar' end it 'wrote configurat...
richardcalahan/exportr
lib/generators/exportr/exportr_generator.rb
<reponame>richardcalahan/exportr<filename>lib/generators/exportr/exportr_generator.rb<gh_stars>1-10 class ExportrGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) def generate_initializer copy_file 'exportr.yml', 'config/exportr.yml' end def mod_gitignore retu...
Wendyv510/eric_carle_books
lib/eric_carle_books/books.rb
class EricCarleBooks::Books attr_accessor :title, :activity, :description @@all = [] def initialize(title,description,activity) @title = title @description = description @activity = activity self.save end def self.all @@all end def save @@all << self e...
Wendyv510/eric_carle_books
lib/eric_carle_books.rb
<reponame>Wendyv510/eric_carle_books<filename>lib/eric_carle_books.rb require "pry" require "nokogiri" require "open-uri" require_relative "eric_carle_books/version" require_relative "eric_carle_books/books" require_relative "eric_carle_books/scraper" require_relative "eric_carle_books/cli" module EricCarleBooks ...
Wendyv510/eric_carle_books
lib/eric_carle_books/scraper.rb
<filename>lib/eric_carle_books/scraper.rb class EricCarleBooks::Scraper def self.get_books @doc = Nokogiri::HTML(open("https://www.teachervision.com/authors/top-10-books-eric-carle")) root_url = "https://www.teachervision.com" titles = @doc.css("div.collection-title") titles.each_with...
Wendyv510/eric_carle_books
lib/eric_carle_books/cli.rb
class EricCarleBooks::CLI def greeting puts "Welcome, are you looking for the top 10 books <NAME> has written? Y/N" input = gets.chomp if input == "Y" EricCarleBooks::Scraper.get_books list_books info_prompt else puts "Sorry, we can't help you." ...
mikelaning/chef-datadog
libraries/recipe_helpers.rb
<filename>libraries/recipe_helpers.rb class Chef # Helper class for Datadog Chef recipes class Datadog class << self def agent_version(node) dd_agent_version = node['datadog']['agent_version'] if dd_agent_version.respond_to?(:each_pair) platform_family = node['platform_family'] ...
STRd6/apn_on_rails
spec/apn_on_rails/app/models/apn/group_notification_spec.rb
<filename>spec/apn_on_rails/app/models/apn/group_notification_spec.rb require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec_helper.rb') describe APN::GroupNotification do describe 'alert' do it 'should trim the message to 150 characters' do noty = APN::GroupNotification.new noty.a...
STRd6/apn_on_rails
lib/apn_on_rails/app/models/apn/group_notification.rb
<reponame>STRd6/apn_on_rails class APN::GroupNotification < APN::Base include ::ActionView::Helpers::TextHelper extend ::ActionView::Helpers::TextHelper serialize :custom_properties belongs_to :group, :class_name => 'APN::Group' has_one :app, :class_name => 'APN::App', :through => :group has_many :dev...
STRd6/apn_on_rails
spec/apn_on_rails/app/models/apn/notification_spec.rb
<reponame>STRd6/apn_on_rails require File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'spec_helper.rb') describe APN::Notification do describe 'alert' do it 'should trim the message to 150 characters' do noty = APN::Notification.new noty.alert = 'a' * 200 noty.alert.should == ('a' * ...
jasherai/authlogic_bundle
templates/testing.rb
SOURCE = "vendor/plugins/authlogic_bundle" unless defined? SOURCE load_template("#{SOURCE}/templates/helper.rb") unless self.respond_to? :file_inject ############################## # RSpec ############################## gem 'rspec', :lib => false, :version => '>= 1.2.6', :env => 'test' gem 'rspec-rails', :lib => false...
jasherai/authlogic_bundle
app/helpers/application_helper.rb
<gh_stars>1-10 # Methods added to this helper will be available to all templates in the application. module ApplicationHelper def secure_mail_to(email, name = nil) return name if email.blank? mail_to email, name, :encode => 'javascript' end def at(klass, attribute, options = {}) klass.human_attribute...
jasherai/authlogic_bundle
templates/remote.rb
ENV['SCM'] = 'git' if yes?('Use git as scm? (y/n)') def git? ENV['SCM'] == 'git' end load_template("http://github.com/tsechingho/authlogic_bundle/raw/master/templates/git_init.rb") if git? rails_edge_path = ask("If you want to symbol link rails edge, please give absolute path or press enter to skip:") run "ln -s #...
jasherai/authlogic_bundle
app/models/user.rb
class User < ActiveRecord::Base acts_as_authentic do |c| c.crypto_provider = Authlogic::CryptoProviders::BCrypt c.validates_length_of_password_field_options = {:minimum => 4, :on => :update, :if => :require_password?} c.validates_confirmation_of_password_field_options = {:minimum => 4, :on => :update, :if...
jasherai/authlogic_bundle
tasks/authlogic_bundle.rake
<reponame>jasherai/authlogic_bundle $LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib') namespace :authlogic_bundle do plugin_path = "vendor/plugins/authlogic_bundle" desc "Sync bundled files" task :sync do system "rsync -rbv #{plug...
revolutionhealth/acts_as_recoverable
lib/recoverable_object.rb
<filename>lib/recoverable_object.rb class RecoverableObject < ActiveRecord::Base serialize :object_hash def recover load_from_hash(object_hash) end def recover! result = recover result.save result.after_recover(self) if result.respond_to?(:after_recover) self.destroy result end ...
revolutionhealth/acts_as_recoverable
test/fixtures/schema.rb
begin ActiveRecord::Schema.define(:version => 1) do create_table :articles, :force => true do |t| t.string :name t.string :type t.timestamps end create_table :tags, :force => true do |t| t.string :name t.integer :article_id t.timestamps end create_table...
revolutionhealth/acts_as_recoverable
acts_as_recoverable.gemspec
Gem::Specification.new do |s| s.name = %q{acts_as_recoverable} s.version = "1.0.4" s.specification_version = 1 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Revolution Health"] s.autorequire ...
revolutionhealth/acts_as_recoverable
lib/acts_as_recoverable.rb
<gh_stars>1-10 module Patch module Acts module Recoverable def acts_as_recoverable return if self.included_modules.include?(InstanceMethods) include InstanceMethods end module InstanceMethods def self.included(base) base.class_eval do ...
revolutionhealth/acts_as_recoverable
test/fixtures/models.rb
<gh_stars>1-10 class Article < ActiveRecord::Base acts_as_recoverable has_many :comments, :dependent => :destroy has_many :authors has_many :tags, :dependent => :destroy end class HealthArticle < Article end class TechnicalArticle < Article end class Tag < ActiveRecord::Base acts_as_recoverable belong...
revolutionhealth/acts_as_recoverable
generators/recoverable_objects_migration/templates/migration.rb
<gh_stars>1-10 class RecoverableObjectsMigration < ActiveRecord::Migration def self.up create_table :recoverable_objects do |t| t.column :recoverable_id, :integer, :null => false t.column :recoverable_type, :string, :limit => 255, :null => false t.text :object_hash t.column :deleted_at, :...
revolutionhealth/acts_as_recoverable
test/acts_as_recoverable_test.rb
<filename>test/acts_as_recoverable_test.rb require File.join(File.dirname(__FILE__), 'test_helper') class ActsAsRecoverableTest < Test::Unit::TestCase def teardown [Tag, Article, Comment, RecoverableObject, Rating, Comment, Listing, Location].each do |klass| klass.all.each { |a| a.destroy } end e...
michaelgpearce/coinmux
lib/coinmux/http.rb
require 'net/http' class Coinmux::Http include Singleton, Coinmux::Facades def get(host, path, options = {:disable_cache => false}) begin info "HTTP GET Request #{host}#{path}" if options[:disable_cache] do_get(host, path) else with_cache(host, path) do do_get(host,...
michaelgpearce/coinmux
lib/coinmux/version.rb
module Coinmux VERSION = "0.2.1" BANNER = "Coinmux - Decentralized, Trustless, Anonymous and Open Bitcoin Mixer" end
michaelgpearce/coinmux
lib/coinmux/validation_model.rb
module Coinmux::ValidationModel class Errors def initialize @errors = {} end def [](key) @errors[key.to_sym] ||= [] end def full_messages @errors.collect { |key, value| "#{key.to_s.gsub('_', ' ')} #{value}" } end def clear @errors.clear end def empty? ...
michaelgpearce/coinmux
lib/coinmux/data_store/memory.rb
class Coinmux::DataStore::Memory < Coinmux::DataStore::Base def initialize(coin_join_uri) super(coin_join_uri) @data_store ||= Hash.new end def clear @data_store.clear end protected def write(key, value) @data_store[key] = value end def read(key) @data_store[key] end end
michaelgpearce/coinmux
lib/coinmux/p2p_bootstrap.rb
class Coinmux::DataStore include Singleton import 'java.io.IOException' import 'net.tomp2p.p2p.Peer' import 'net.tomp2p.p2p.PeerMaker' import 'net.tomp2p.peers.Number160' import 'java.util.Random' def startup @peer = PeerMaker.new(Number160.new(Random.new)).setPorts(14141).makeAndListen() @p...
michaelgpearce/coinmux
lib/coinmux/application/input_validator.rb
class Coinmux::Application::InputValidator include Coinmux::Facades REQUIRED_ATTRS = [:data_store, :input_private_key, :amount, :participants, :change_address, :output_address] OPTIONAL_ATTRS = [:coin_join_uri] ATTRS = REQUIRED_ATTRS + OPTIONAL_ATTRS attr_accessor *ATTRS def initialize(params) params....
michaelgpearce/coinmux
lib/coinmux/assert_keys.rb
class Hash def assert_keys!(options) required = options[:required] || [] required = [required] unless required.is_a?(Array) optional = options[:optional] || [] optional = [optional] unless optional.is_a?(Array) unknown = keys - (required + optional) raise "Unknown keys: #{unknown.join(', ')}"...
michaelgpearce/coinmux
spec/message/coin_join_spec.rb
require 'spec_helper' describe Coinmux::Message::CoinJoin do before do fake_all_network_connections end let(:amount) { SATOSHIS_PER_BITCOIN } let(:participants) { 2 } let(:participant_transaction_fee) { DEFAULT_TRANSACTION_FEE / 2 } let(:version) { Coinmux::Message::CoinJoin::VERSION } describe "...
michaelgpearce/coinmux
lib/coinmux/pki.rb
<reponame>michaelgpearce/coinmux<filename>lib/coinmux/pki.rb require 'openssl' class Coinmux::PKI include Singleton def generate_keypair pki = OpenSSL::PKey::RSA.new(2048) private_key = pki.to_s public_key = pki.public_key.to_s [private_key, public_key] end def public_encrypt(public_key, c...
michaelgpearce/coinmux
lib/coinmux/data_store/file.rb
require 'fileutils' class Coinmux::DataStore::File < Coinmux::DataStore::Base def initialize(coin_join_uri) super(coin_join_uri) path = if path_override = coin_join_uri.params['path'] path_override = File.expand_path(path_override) FileUtils.mkdir_p(path_override) path_override else ...
michaelgpearce/coinmux
gui/application.rb
<gh_stars>10-100 class Gui::Application < Java::JavaxSwing::JFrame include Coinmux::Facades WIDTH = 600 HEIGHT = 450 MIXES_TABLE_REFRESH_SECONDS = 5 attr_accessor :amount, :participants, :coin_join_uri, :input_private_key, :output_address, :change_address, :current_view import 'java.awt.CardLayout' imp...
michaelgpearce/coinmux
spec/bitcoin_network_spec.rb
<gh_stars>10-100 require 'spec_helper' describe Coinmux::BitcoinNetwork do describe "#unspent_inputs_for_address" do let(:data) { load_fixture("#{address}.json") } let(:address) { 'mjcSuqvGTuq8Ys82juwa69eAb4Z69VaqEE' } before do http_facade.stub(:get).with(config_facade.webbtc_host, "/address/#{ad...
michaelgpearce/coinmux
spec/factories/messages.rb
FactoryGirl.define do factory :association_message, :class => Coinmux::Message::Association do sequence(:name) { |n| "association-#{n}" } type :list read_only false data_store_identifier_from_build { Helper.data_store.generate_identifier } data_store_identifier do if read_only data_s...
michaelgpearce/coinmux
lib/coinmux/inflections.rb
class String def humanize gsub(/_/, ' ') end def classify singularize.gsub(/_/, ' ').split(' ').collect(&:capitalize).join end def singularize if match /uses$/ self[0...-2] elsif match /es$/ self[0...-1] elsif match /[^us]s$/ self[0...-1] else self end e...
michaelgpearce/coinmux
lib/coinmux/logger.rb
require 'logger' class Coinmux::Logger include Singleton def debug(*messages) write_messages(:debug, messages) end def info(*messages) write_messages(:info, messages) end def warn(*messages) write_messages(:warn, messages) end def error(*messages) write_messages(:error, messages) ...
michaelgpearce/coinmux
lib/coinmux.rb
$:.unshift(File.expand_path("../..", __FILE__)) require 'json' require 'singleton' require 'base64' require 'set' Dir[File.join(File.dirname(__FILE__), 'jar', '*.jar')].each { |filename| require filename } module Coinmux require 'rbconfig' module Application; end module Message; end module StateMachine; e...
michaelgpearce/coinmux
lib/coinmux/message/message_verification.rb
class Coinmux::Message::MessageVerification < Coinmux::Message::Base property :encrypted_message_identifier property :encrypted_secret_keys attr_accessor :message_identifier, :secret_key validates :encrypted_message_identifier, :encrypted_secret_keys, :presence => true validates :message_identifier, :se...
michaelgpearce/coinmux
cli/application.rb
<gh_stars>10-100 class Cli::Application include Coinmux::BitcoinUtil, Coinmux::Facades attr_accessor :participant, :director attr_accessor :amount, :participants, :input_private_key, :output_address, :change_address, :coin_join_uri def initialize(options = {}) options.assert_keys!(required: [:amount, :par...
michaelgpearce/coinmux
lib/coinmux/message/base.rb
<filename>lib/coinmux/message/base.rb class Coinmux::Message::Base include Coinmux::ValidationModel, Coinmux::Facades, Coinmux::Proper MAX_JSON_DATA_SIZE = 10_000 # not sure the best number for this, but all our messages should be small ASSOCIATION_TYPES = [:list, :fixed, :variable] attr_accessor :coin_join, ...
michaelgpearce/coinmux
gui/view/mix_settings.rb
<filename>gui/view/mix_settings.rb class Gui::View::MixSettings < Gui::View::Base DEFAULT_PARTICIPANTS = 5 DEFAULT_AMOUNT = 1.0 * SATOSHIS_PER_BITCOIN MAX_PARTICIPANTS = 100 import 'java.awt.Component' import 'java.awt.Dimension' import 'java.awt.Insets' import 'javax.swing.JButton' import 'javax.swing...
michaelgpearce/coinmux
lib/coinmux/state_machine/base.rb
<reponame>michaelgpearce/coinmux class Coinmux::StateMachine::Base include Coinmux::Facades MESSAGE_POLL_INTERVAL = 5 attr_accessor :event_queue, :coin_join_message, :notification_callback, :state, :amount, :participants, :data_store def initialize(options = {}) super() # NOTE: This *must* be called,...
michaelgpearce/coinmux
lib/coinmux/data_store/factory.rb
class Coinmux::DataStore::Factory NETWORK_TO_CLASS = { p2p: 'Tomp2p', filesystem: 'File', test: 'Memory' } class << self def build(coin_join_uri) data_store_class_name = NETWORK_TO_CLASS[coin_join_uri.network.to_sym] Coinmux::DataStore.const_get(data_store_class_name).new(coin_join_u...
michaelgpearce/coinmux
spec/message/transaction_spec.rb
require 'spec_helper' describe Coinmux::Message::Transaction do let(:template_message) { build(:transaction_message) } let(:coin_join) { template_message.coin_join } let(:inputs) { template_message.inputs } let(:outputs) { template_message.outputs } before do stub_bitcoin_network_for_coin_join(coin_join...
michaelgpearce/coinmux
gui/view/preferences.rb
class Gui::View::Preferences < Gui::View::Base NETWORK_CONFIG_KEYS = %w(mainnet testnet) NETWORK_CONFIG_KEYS.reverse! if Coinmux.env == 'development' # first element will be default DATA_STORE_NAME_MAP = { 'P2P' => 'p2p', 'Filesystem' => 'filesystem' } # first element will be default NETWORK_NAME_MA...
michaelgpearce/coinmux
cli/event.rb
class Cli::Event attr_accessor :callback, :invoke_at, :interval_period, :interval_identifier, :mutex, :condition_variable def initialize(attrs = {}) attrs.each { |k, v| send("#{k}=", v) } end end
michaelgpearce/coinmux
lib/coinmux/error.rb
<gh_stars>10-100 class Coinmux::Error < StandardError end
michaelgpearce/coinmux
lib/coinmux/data_store/tomp2p.rb
<filename>lib/coinmux/data_store/tomp2p.rb require 'java' class Coinmux::DataStore::Tomp2p < Coinmux::DataStore::Base include Coinmux::Facades DEFAULT_BOOTSTRAP_HOST = "coinjoin.coinmux.com" DEFAULT_P2P_PORT = 14141 PEER_DISCOVERY_TIMEOUT_SECONDS = 30 import 'java.io.IOException' import 'java.net.InetA...
michaelgpearce/coinmux
spec/message/transaction_signature_spec.rb
require 'spec_helper' describe Coinmux::Message::TransactionSignature do let(:template_message) { build(:transaction_signature_message) } let(:coin_join) { template_message.coin_join } let(:transaction_input_index) { template_message.transaction_input_index } let(:script_sig) { template_message.script_sig } ...
michaelgpearce/coinmux
lib/coinmux/threading.rb
module Coinmux::Threading def self.wait_for_callback(object, method, *args, &callback) done = false results = nil object.send(method, *args) do |*callback_results| done = true results = callback_results end loop { break if done; sleep(0.05) } results end def wait_for_callbac...
michaelgpearce/coinmux
cli/bootstrap.rb
<gh_stars>10-100 require 'fileutils' class Cli::Bootstrap DEFAULT_PORT = 14141 attr_accessor :port import 'java.io.IOException' import 'java.util.Random' import 'net.tomp2p.p2p.Peer' import 'net.tomp2p.p2p.PeerMaker' import 'net.tomp2p.peers.Number160' import 'net.tomp2p.storage.StorageDisk' import...
michaelgpearce/coinmux
lib/coinmux/bitcoin_network.rb
class Coinmux::BitcoinNetwork include Singleton, Coinmux::BitcoinUtil, Coinmux::Facades import 'com.google.bitcoin.core.Transaction' import 'java.math.BigInteger' import 'java.security.SignatureException' import 'com.google.bitcoin.core.Address' import 'com.google.bitcoin.core.ECKey' import 'com.google.b...
michaelgpearce/coinmux
spec/message/output_spec.rb
require 'spec_helper' describe Coinmux::Message::Output do before do fake_all_network_connections end let(:coin_join) { build(:coin_join_message, :with_inputs, :with_message_verification, :with_outputs) } let(:message) { coin_join.outputs.value.detect(&:created_with_build?) } describe "validations" d...
michaelgpearce/coinmux
lib/coinmux/event.rb
class Coinmux::Event attr_accessor :error, :data def initialize(params = {}) params.each do |key, value| send("#{key}=", value) end end end