repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
Marketcircle/Specs | AVAnimator/2.0.0/AVAnimator.podspec | #
Pod::Spec.new do |s|
s.name = "AVAnimator"
s.version = "2.0.0"
s.summary = "VAnimator is an iOS library that makes it easy to implement non-trivial animated/video content in iOS."
s.homepage = "http://www.modejong.com/AVAnimator/index.html"
s.license = { :type => 'LGPL', :fi... |
Marketcircle/Specs | MotionJpegImageView/0.0.1/MotionJpegImageView.podspec | Pod::Spec.new do |s|
s.name = "MotionJpegImageView"
s.version = "0.0.1"
s.summary = "MotionJpegImageView lets you display MJPEG streams on iOS. Typically 7 to 8 times faster than using UIView."
s.description = <<-DESC
MotionJpegImageView creates a connection to the strea... |
Marketcircle/Specs | CZDateFormatterCache/1.1.1/CZDateFormatterCache.podspec | <gh_stars>1-10
Pod::Spec.new do |s|
s.name = "CZDateFormatterCache"
s.version = "1.1.1"
s.summary = "A shared NSDateFormatter cache to improve scrolling performance in UITableViewCells."
s.homepage = "https://github.com/carezone/CZDateFormatterCache"
s.license = "Apache 2.0"
s.aut... |
Marketcircle/Specs | AFProgressiveImageDownload/0.1/AFProgressiveImageDownload.podspec | #
# Be sure to run `pod spec lint AFProgressiveImageDownload.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# To learn more about the attributes see http://docs.cocoapods.org/specification.html
#
Pod::Spec.new do |s|
s.name = "AFProgressiveImageDownload"
s.ve... |
Marketcircle/Specs | fullcontact-objc/1.0.0/fullcontact-objc.podspec | Pod::Spec.new do |s|
s.name = "fullcontact-objc"
s.version = "1.0.0"
s.license = { :type => 'Apache License Version 2.0', :file => 'LICENSE' }
s.summary = "Objective-C library to access FullContact's v2 API endpoints via iOS and Mac OS X."
s.homepage = "https://github.com/fullcontac... |
Marketcircle/Specs | ParseKit/0.7/ParseKit.podspec | <reponame>Marketcircle/Specs
Pod::Spec.new do |s|
s.name = 'ParseKit'
s.version = '0.7'
s.license = 'Apache'
s.summary = 'Objective-C/Cocoa String Tokenizer and Parser toolkit. Supports Grammars.'
s.homepage = 'http://parsekit.com/'
s.author = { '<NAME>' => '<EMAIL>' }
s.source = { :git => 'ht... |
Marketcircle/Specs | OLImageView/1.3.0/OLImageView.podspec | <gh_stars>0
Pod::Spec.new do |s|
s.name = "OLImageView"
s.version = "1.3.0"
s.summary = "Animated GIFs implemented the right way."
s.homepage = "https://www.github.com/ondalabs/OLImageView"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "<NAME>" => "<EMAIL>"... |
Marketcircle/Specs | ZXTools/1.3/ZXTools.podspec | <gh_stars>1-10
Pod::Spec.new do |s|
s.name = "ZXTools"
s.version = "1.3"
s.summary = "张玺的工具箱子,扩展部分UIKit和UIFoundation的类,实现更丰富的功能."
#s.license = {:type => 'BSD' }
s.license = 'MIT'
#s.license = { :type => 'MIT', :file => 'LICENSE' }
s.homepage = "https://github.com/zhangxigithu... |
Marketcircle/Specs | TheAmazingAudioEngine/1.0/TheAmazingAudioEngine.podspec | #
# Be sure to run `pod spec lint TheAmazingAudioEngine.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# To learn more about the attributes see http://docs.cocoapods.org/specification.html
#
Pod::Spec.new do |s|
s.name = "TheAmazingAudioEngine"
s.version ... |
Marketcircle/Specs | DTAUS/0.1.0/DTAUS.podspec | #
# Be sure to run `pod spec lint DTAUS.podspec' to ensure this is a
# valid spec and remove all comments before submitting the spec.
#
# To learn more about the attributes see http://docs.cocoapods.org/specification.html
#
Pod::Spec.new do |s|
s.name = "DTAUS"
s.version = "0.1.0"
s.summary = "A... |
AlessandroPTSN/heroku-buildpack-r | bin/copy_libs.rb | #!/usr/bin/env ruby
#
# utility to copy libraries (some installed via Aptfile) which are referenced by the R packages
# built during execution of init.R/packrat/renv, which need to be "packaged" into the slug since
# the chroot isn't included at runtime.
#
# this script uses ldd to inspect each .so file in the given d... |
lzrd/parley | test/test_parley.rb | <reponame>lzrd/parley<filename>test/test_parley.rb
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/../lib") if __FILE__ == $0
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}") if __FILE__ == $0
require 'helper'
require "test/unit"
require 'parley'
require 'stringio'
require 'open3'
#class TestParley < Test::Unit::TestCa... |
lzrd/parley | lib/parley.rb | <reponame>lzrd/parley
require 'pty'
# The Parley module is generally used to wrestle with the informal, interactive, text-mode,
# APIs of the world.
#
# Parley is an implementation of an expect-like API. It is designed to
# help port away from Perl Expect based applications.
# Parley was chosen as a name as an alter... |
IreneHodge/ith_palindrome | lib/ith_palindrome/version.rb | # frozen_string_literal: true
module IthPalindrome
VERSION = "0.1.0"
end
|
mtrautwig/logstash-plugins | filters/datesplit.rb | <filename>filters/datesplit.rb
# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
# The datesplit filter expands the @timestamp field into its individual
# components, like day of week and hour. This allows for data analysis
# tasks like finding the busiest day, or the time when you best ru... |
top1st/peatio-trading-ui-referral | lib/peatio_trading_ui/version.rb | <gh_stars>1-10
module PeatioTradingUI
VERSION = '1.8.15'
end
|
WalletOne/P2P | P2PUI.podspec | <reponame>WalletOne/P2P
Pod::Spec.new do |s|
s.name = "P2PUI"
s.version = "0.3.5"
s.summary = "P2PCore - UI Framework for Wallet One P2P"
s.homepage = "https://github.com/WalletOne/P2P.git"
s.license = 'MIT'
s.author = { "Vitaliy" => "<EMAIL>" }
s.ios.deployment_targ... |
Elenaltarien/palindrome_checker | palindrome_checker.rb | # Purpose of program: Test string to see if it's a palindrome. (same when letters are reversed)
# Must pass following tests:
# 1. Get user-input
# 2. Check user-input to see if palindrome.
# 3. If no input entered, inform user.
# 4. If word/phrase not palindrome, inform user.
# 5. If word/phrase is palindrome, inform... |
veresiah/TallestTrees | lib/trees.rb | <filename>lib/trees.rb
class Tree
attr_accessor :scientific_name, :common_name,:family_common_name, :genus, :year, :bibliography, :family, :image_url
@@all = []
def initialize(scientific_name, family_common_name, genus, year, bibliography, family, image_url)
@scientific_name = scientific_name
... |
veresiah/TallestTrees | lib/api.rb | <gh_stars>0
class API
def initialize
@url = "https://trefle.io/api/v1/plants?filter_not%5Bmaximum_height_cm%5D=null&filter%5Bligneous_type%5D=tree&order%5Bmaximum_height_cm%5D=desc&token=#{ENV['API_KEY']}"
end
def get_trees
uri = URI.parse(@url)
resp = Net::HTTP.get(uri)
... |
veresiah/TallestTrees | lib/cli.rb | <gh_stars>0
class CLI
def run
greeting
menu
end
def greeting
system "clear"
puts "Hello there! Welcome to Tallest Trees!".colorize(:green).colorize(:background => :blue)
puts "A CLI displaying details about some of the world's tallest trees.".colorize(:green).colo... |
veresiah/TallestTrees | config/environment.rb | require 'net/http'
require 'open-uri'
require 'json'
require 'dotenv/load'
require 'colorize'
require 'pry'
require_relative "../lib/trees.rb"
require_relative "../lib/api.rb"
require_relative "../lib/cli.rb"
|
siuying/moria | app/example_basic_view.rb | class ExampleBasicView < UIView
def init
super
view1 = UIView.new
view1.backgroundColor = UIColor.greenColor
self.addSubview view1
view2 = UIView.new
view2.backgroundColor = UIColor.redColor
self.addSubview view2
view3 = UIView.new
view3.backgroundColor = UIColor.blueColor
s... |
siuying/moria | spec/view_attribute_spec.rb | describe "Moria::ViewAttribute" do
before do
superview = UIView.alloc.init
@view = UIView.alloc.init
superview.addSubview(@view)
@view_attribute = Moria::ViewAttribute.new(@view, NSLayoutAttributeLeft)
end
describe "#offset" do
it "should set constant on view attribute" do
@view_attribu... |
siuying/moria | lib/moria/base.rb | module Moria
LAYOUT_ATTRIBUTES = {
:left => NSLayoutAttributeLeft,
:top => NSLayoutAttributeTop,
:right => NSLayoutAttributeRight,
:bottom => NSLayoutAttributeBottom,
:leading => NSLayoutAttributeLeading,
:trailing => NSLayoutAttributeTrailing,
:width => NSLayoutAttributeWidth,
:height... |
siuying/moria | lib/moria/view_constraint.rb | <reponame>siuying/moria<filename>lib/moria/view_constraint.rb
module Moria
# A constraint, created by a ConstraintBuilder.
# A view constraint contains two view attribute (view, attribute) and a relation (>=, == or <=).
class ViewConstraint
attr_accessor :first_view_attribute
attr_accessor :second_view_at... |
siuying/moria | spec/constraint_builder_spec.rb | describe "ConstraintBuilder" do
before do
@superview = UIView.alloc.init
@view = UIView.alloc.init
@superview.addSubview(@view)
@builder = Moria::ConstraintBuilder.new(@view)
end
describe "#superview" do
it "should return superview of view" do
@builder.superview.should == @superview
... |
siuying/moria | lib/moria/view_attribute.rb | <filename>lib/moria/view_attribute.rb<gh_stars>1-10
module Moria
# represent a attribute in a UIView
class ViewAttribute
attr_accessor :view
attr_accessor :layout_attribute
attr_accessor :constant
def initialize(view, layout_attribute)
@view = view
@layout_attribute = layout_attribute
... |
siuying/moria | app/example_constant_view.rb | class ExampleConstantView < UIView
def init
super
view1 = UIView.new
view1.backgroundColor = UIColor.purpleColor
self.addSubview view1
view2 = UIView.new
view2.backgroundColor = UIColor.orangeColor
self.addSubview view2
view1.create_constraint do
top == 20
left ==... |
siuying/moria | app/example_debug_view.rb | class ExampleDebugView < UIView
def init
super
view1 = UIView.new
view1.backgroundColor = UIColor.greenColor
addSubview view1
view2 = UIView.new
view2.backgroundColor = UIColor.redColor
addSubview view2
view3 = UILabel.new
view3.backgroundColor = UIColor.blueColor
view3.numb... |
siuying/moria | spec/view_ext_spec.rb | <reponame>siuying/moria<filename>spec/view_ext_spec.rb
describe "View Extension" do
before do
superview = UIView.alloc.init
@view = UIView.alloc.init
superview.addSubview(@view)
end
describe "#create_constraint" do
it "should build constraints on view" do
@view.superview.constraints.size.sh... |
siuying/moria | lib/moria/constraint_builder.rb | <gh_stars>1-10
module Moria
class ConstraintBuilder
attr_reader :view
attr_accessor :constraints
def initialize(view)
@view = view
@constraints = []
end
# install the constraints to view, the return the constraints object
def install
constraints = self.constraints.copy
... |
siuying/moria | spec/layout_constraint_debug_extension_spec.rb | <reponame>siuying/moria
describe "Moria::LayoutConstraintDebugExtension" do
before do
@subject = Object.new.extend(Moria::LayoutConstraintDebugExtension)
end
describe "#description_for_object" do
it "should show readable description of view using moria_key" do
view = UIView.new
view.moria_key... |
siuying/moria | lib/moria/layout_constraint_debug_extension.rb | <filename>lib/moria/layout_constraint_debug_extension.rb
module Moria
module LayoutConstraintDebugExtension
RELATION_DESCRIPTION = {
NSLayoutRelationEqual => "==",
NSLayoutRelationGreaterThanOrEqual => ">=",
NSLayoutRelationLessThanOrEqual => "<="
}
ATTRIBUTE_DESCRIPTION = {
NSLay... |
siuying/moria | app/example_list_controller.rb | class ExampleListController < UITableViewController
ExampleListControllerCellIdentifier = "ExampleListController"
attr_accessor :example_controllers
def init
super
self.title = "Examples"
self.example_controllers = [
ExampleViewController.alloc.initWithTitle("Basic Example", view_class: Example... |
siuying/moria | spec/view_constraint_spec.rb | describe "Moria::ViewConstraint" do
before do
@superview = UIView.new
@view1 = UIView.new
@view2 = UIView.new
@superview.addSubview(@view1)
@superview.addSubview(@view2)
@attribute1 = Moria::ViewAttribute.new(@view1, NSLayoutAttributeHeight)
@attribute2 = Moria::ViewAttribute.new(@view2, N... |
siuying/moria | lib/moria/layout_constraint.rb | <filename>lib/moria/layout_constraint.rb<gh_stars>1-10
module Moria
class LayoutConstraint < NSLayoutConstraint
# a key to asociate with this constraint
attr_accessor :moria_key
end
end |
siuying/moria | app/example_view_controller.rb | <gh_stars>1-10
class ExampleViewController < UIViewController
attr_accessor :view_class
def initWithTitle(title, view_class:view_class)
self.init
self.title = title
self.view_class = view_class
self
end
def loadView
self.view = self.view_class.new
self.view.backgroundColor = UIColor.whi... |
siuying/moria | lib/moria/view_ext.rb | <reponame>siuying/moria
module Moria
module LayoutAttributeExtension
LAYOUT_ATTRIBUTES.each do |key, value|
define_method(key) do
ViewAttribute.new self, value
end
end
end
module LayoutExtension
def create_constraint(&block)
self.translatesAutoresizingMaskIntoConstraints = f... |
siuying/moria | app/app_delegate.rb | <filename>app/app_delegate.rb
class AppDelegate
attr_accessor :window
def application(application, didFinishLaunchingWithOptions:launchOptions)
self.window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
self.window.backgroundColor = UIColor.whiteColor
view_controller = ExampleListControll... |
rtomayko/divvy | lib/divvy/worker.rb | <reponame>rtomayko/divvy<gh_stars>1-10
module Divvy
# Models an individual divvy worker process. These objects are used in both
# the master and the forked off workers to perform common tasks and for basic
# tracking.
class Worker
# The worker number. These are sequential starting from 1 and ending in the
... |
mauriciofloresl/aztecnews | app/models/user.rb | class User < ActiveRecord::Base
has_secure_password
validates_uniqueness_of :email
enum role: [:user, :admin]
end
|
mauriciofloresl/aztecnews | app/controllers/admin/articles_controller.rb | <reponame>mauriciofloresl/aztecnews<gh_stars>0
class Admin::ArticlesController < Admin::ApplicationController
before_action :set_article, only: [:show, :edit, :update, :destroy, :approve, :reject]
def index
@articles = Article.where(status: 0)
end
def approved
@articles = Article.where(status: 1)
en... |
mauriciofloresl/aztecnews | db/schema.rb | <filename>db/schema.rb
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition i... |
mauriciofloresl/aztecnews | config/routes.rb | Rails.application.routes.draw do
namespace :admin do
get 'log_in' => 'sessions#new', as: :log_in
get 'log_out' => 'sessions#destroy', as: :log_out
root 'articles#new'
get 'articles/approved' => 'articles#approved', as: 'approved_articles'
post 'articles/approve/:id' => 'articles#approve', as: '... |
mauriciofloresl/aztecnews | app/controllers/pages_controller.rb | <reponame>mauriciofloresl/aztecnews
class PagesController < ApplicationController
def home
@issues = Issue.all
end
end
|
wanelo/runner | lib/runner.rb | require 'runner/version'
require 'runner/runner'
module Runner
end
|
wanelo/runner | lib/runner/environment.rb | module Runner
class Environment
def load!
set_environment
load_rails
configure_logger
end
def set_environment
ENV['RAILS_ENV'] ||= 'development'
ENV['RACK_ENV'] ||= ENV['RAILS_ENV']
end
def load_rails
begin
require 'rails'
if ::Rails.applicatio... |
wanelo/runner | lib/runner/runner.rb | require 'runner/environment'
module Runner
class Runner
attr_reader :args
def initialize(args)
@args = args
end
def run
handle_signals!
Environment.new.load!
eval(args.join(' '))
end
def handle_signals!
Signal.trap('INT') { exit }
Signal.trap('TERM') { e... |
json-next/json-next | lib/json/next/pattern.rb | # encoding: utf-8
module JSON
module Next
## note: regex pattern \\ needs to get escaped twice, thus, \\.
## and for literal \\ use \\\\\.
## todo: check for newlines [^] incl. newline ?
## note: add named captures for "inner" unquotes string values
###############
##### quotes
... |
json-next/json-next | test/test_parser_hanson.rb | # encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_parser_hanson.rb
require 'helper'
class TestParser < MiniTest::Test
def test_hanson
sample1, exp1 = TestBlockFile.read_utf8( 'hanson1' )
puts HANSON.convert( sample1 )
pp HANSON.parse( sample1 )
a... |
json-next/json-next | lib/json/next.rb | <filename>lib/json/next.rb
# encoding: utf-8
require 'json'
require 'strscan' ## StringScanner
require 'pp'
# our own code
require 'json/next/version' # note: let version always go first
require 'json/next/pattern' # shared utils for "custom" parser
require 'json/next/commata'
require 'json/next... |
json-next/json-next | test/test_parser_son.rb | <filename>test/test_parser_son.rb
# encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_parser_son.rb
require 'helper'
class TestParserSon < MiniTest::Test
def test_son
sample1, exp1 = TestBlockFile.read_utf8( 'son1' )
puts SON.convert( sample1 )
assert_equ... |
json-next/json-next | test/test_parser_jsonx.rb | <filename>test/test_parser_jsonx.rb<gh_stars>10-100
# encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_parser_jsonx.rb
require 'helper'
class TestParserJsonx < MiniTest::Test
def test_jsonx
sample1, exp1 = TestBlockFile.read_utf8( 'jsonx1' )
puts JSONX.convert(... |
json-next/json-next | lib/json/next/commata.rb | # encoding: utf-8
module JSON
module Next
### auto-add commas for objects and arrays
class Commata
## convenience helper
def self.convert( str, opts={} )
self.new.convert( str, opts )
end
def convert( str, opts={} )
@debug = opts.fetch( :debug, false )
@out = ""
@buffer = Str... |
json-next/json-next | lib/json/next/parser/son.rb | # encoding: utf-8
###
# based on github.com/aleksandergurin/simple-object-notation
# Thanks to <NAME>
module SON
DOUBLE_QUOTE = JSON::Next::DOUBLE_QUOTE
SHELL_COMMENT = JSON::Next::SHELL_COMMENT
def self.strip_comments( text ) ## pass 1
text.gsub( /#{DOUBLE_QUOTE}|#{SHELL... |
json-next/json-next | test/test_version.rb | <filename>test/test_version.rb
# encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_version.rb
require 'helper'
class TestVersion < MiniTest::Test
def test_version
pp JSON::Next::UNESCAPE_MAP
pp JSON::Next::ML_ESCAPE_MAP
pp JSON::Next::BACKTICK_ML_QUOTE
... |
json-next/json-next | test/helper.rb | <filename>test/helper.rb<gh_stars>10-100
# encoding: utf-8
## minitest setup
require 'minitest/autorun'
$RUBYLIBS_DEBUG = true
## our own code
require 'json/next'
class TestBlockFile
def self.read_utf8( path )
BlockFile.read_utf8( "#{JSON::Next.root}/test/data/#{path}.txt" )
end
end
... |
json-next/json-next | lib/json/next/version.rb | # encoding: utf-8
module JSON
module Next
MAJOR = 1 ## todo: namespace inside version or something - why? why not??
MINOR = 2
PATCH = 1
VERSION = [MAJOR,MINOR,PATCH].join('.')
def self.version
VERSION
end
def self.banner
"json-next/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY... |
json-next/json-next | lib/json/next/parser/jsonx.rb | # encoding: utf-8
##
## JSON with Extensions (JSONX) or
## JSON 1.1 - JSON XI
module JSONX
BACKTICK_ML_QUOTE = JSON::Next::BACKTICK_ML_QUOTE
SINGLE_QUOTE = JSON::Next::SINGLE_QUOTE
DOUBLE_QUOTE = JSON::Next::DOUBLE_QUOTE
CLANG_ML_COMMENT = JSON::Next::CLANG_ML_COM... |
json-next/json-next | test/test_commata.rb | <gh_stars>10-100
# encoding: utf-8
###
# to run use
# ruby -I ./lib -I ./test test/test_commata.rb
require 'helper'
class TestCommata < MiniTest::Test
def test_commata
sample1, exp1 = TestBlockFile.read_utf8( 'commata1' )
sample2a, exp2a = TestBlockFile.read_utf8( 'commata2a' )
... |
json-next/json-next | lib/json/next/parser/hanson.rb | # encoding: utf-8
###
# based on github.com/timjansen/hanson
# Thanks to <NAME>
module HANSON
BACKTICK_ML_QUOTE = JSON::Next::BACKTICK_ML_QUOTE
SINGLE_QUOTE = JSON::Next::SINGLE_QUOTE
DOUBLE_QUOTE = JSON::Next::DOUBLE_QUOTE
CLANG_ML_COMMENT = JSON::Next::CLANG_ML_COMMENT
CLA... |
javagg/GitlabLicGen | keygen.rb | <reponame>javagg/GitlabLicGen
require 'openssl'
require 'gitlab/license'
license_text=<<HERE
-----<KEY>
HERE
private_key = OpenSSL::PKey::RSA.new license_text
puts "Private Key:"
puts private_key
public_key = private_key.public_key
puts "Public Key:"
puts public_key
Gitlab::License.encryption_key = private_key
licen... |
geomaster58/KeeneysAwesomeViewTool | lib/KeeneysAwesomeViewTool.rb | <reponame>geomaster58/KeeneysAwesomeViewTool
require "KeeneysAwesomeViewTool/version"
require "KeeneysAwesomeViewTool/renderer"
|
adrian-gomez/ward-web | spec/views/instances/show.html_spec.rb | require 'rails_helper'
RSpec.describe 'instances/show' do
let(:instance) { create(:instance) }
before { assign(:instance, instance) }
it 'renders attributes in <p>' do
render
end
end |
adrian-gomez/ward-web | spec/views/instances/index.html_spec.rb | require 'rails_helper'
RSpec.describe 'instances/index' do
let(:instances) { [create(:instance), create(:instance)] }
before(:each) { assign(:instances, instances) }
it 'renders a list of instances' do
render
end
end |
adrian-gomez/ward-web | spec/routing/instances_routing_spec.rb | require 'rails_helper'
RSpec.describe InstancesController do
describe 'routing' do
it 'routes to #index' do
expect(:get => '/instances').to route_to('instances#index')
end
it 'routes to #show' do
expect(get: '/instances/1').to route_to('instances#show', id: '1')
end
it 'routes to ... |
adrian-gomez/ward-web | spec/factories/instances.rb | FactoryGirl.define do
factory :instance do
sequence(:ip) { |n| "127.0.0.#{n}" }
label 'Example Instance'
end
end |
adrian-gomez/ward-web | app/models/reading.rb | class Reading
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :instance
embeds_one :data, class_name: 'ReadingData'
validates! :instance, presence: true
validates :data, presence: true
def self.from_last_hours(hours = 12)
self.where(:created_at.gte => (Time.now - hours.hours))
e... |
adrian-gomez/ward-web | app/models/instance.rb | <reponame>adrian-gomez/ward-web
class Instance
include Mongoid::Document
include Mongoid::Timestamps
field :label, type: String
field :ip, type: String
has_many :readings
validates :ip, presence: true
validates :ip, uniqueness: true, allow_nil: true
validate :valid_ip
private
def valid_ip
... |
adrian-gomez/ward-web | spec/factories/instance_data.rb | FactoryGirl.define do
factory :reading_data do
disk_usage { rand * 100 }
cpu_usage { rand * 100 }
process_list { %W[process-#{rand(1..100)}]*10 }
reading
# after_build
end
end |
adrian-gomez/ward-web | spec/controllers/api/readings_controller_spec.rb | require 'rails_helper'
RSpec.describe Api::ReadingsController do
let!(:instance) { create(:instance) }
describe 'POST #create' do
before { request.env['REMOTE_ADDR'] = instance.ip }
context 'with valid params' do
let(:valid_attributes) { attributes_for(:reading) }
it 'creates a new instanc... |
adrian-gomez/ward-web | spec/controllers/dashboard_controller_spec.rb | require 'rails_helper'
RSpec.describe DashboardController do
describe 'GET #index' do
let!(:instance) { create(:instance) }
it 'assigns all instances as @instances' do
get :index
expect(assigns(:instances)).to eq([instance])
end
it 'returns a success response' do
get :index
... |
adrian-gomez/ward-web | spec/models/reading_spec.rb | require 'rails_helper'
RSpec.describe Reading do
describe 'validations' do
let(:instance) { create(:instance) }
let(:reading_attrs) { attributes_for(:reading).merge(instance: instance) }
context 'when data is empty' do
before { reading_attrs[:data] = {} }
it 'adds an error for data' ... |
adrian-gomez/ward-web | config/deploy.rb | lock '3.5.0'
set :application, 'ward-server'
set :repo_url, '<EMAIL>:adrian-gomez/ward-web.git'
set :deploy_to, "/home/ubuntu/#{fetch(:application)}"
# Default value for :pty is false
set :pty, true
set :linked_files, fetch(:linked_files, []).push('config/mongoid.yml', 'config/secrets.yml')
set :linked_dirs, fetch... |
adrian-gomez/ward-web | spec/views/instances/edit.html_spec.rb | require 'rails_helper'
RSpec.describe 'instances/edit' do
let(:instance) { create(:instance) }
before { assign(:instance, instance) }
it 'renders the edit instance form' do
render
assert_select 'form[action=?][method=?]', instance_path(instance), 'post' do
assert_select 'input[name=?][value=?]'... |
adrian-gomez/ward-web | lib/capistrano/tasks/rvm.rake | namespace :rvm do
task :update_key do
on roles(fetch(:rvm1_roles, :all)) do
execute :gpg, '--keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3'
end
end
task :install_bundler do
on roles(fetch(:rvm1_roles, :all)) do
execute :gem, 'install', 'bundler'
end
end
end
before 'deploy', '... |
adrian-gomez/ward-web | app/controllers/instances/readings_controller.rb | class Instances::ReadingsController < ApplicationController
before_action :set_instance
before_action :set_reading, only: [:show]
# GET /instances/:instance_id/readings
def index
readings = @instance.readings.from_last_hours(2)
render json: readings.to_json
end
# GET /instances/:instance_id/read... |
adrian-gomez/ward-web | spec/controllers/instances_controller_spec.rb | <reponame>adrian-gomez/ward-web
require 'rails_helper'
RSpec.describe InstancesController do
describe 'GET #index' do
let!(:instance) { create(:instance) }
it 'assigns all instances as @instances' do
get :index
expect(assigns(:instances)).to eq([instance])
end
it 'returns a success r... |
adrian-gomez/ward-web | spec/controllers/instances/readings_controller_spec.rb | <reponame>adrian-gomez/ward-web
require 'rails_helper'
RSpec.describe Instances::ReadingsController do
let!(:instance) { create(:instance) }
describe 'GET #index' do
let!(:reading) { create(:reading, instance: instance) }
it 'returns a success response' do
get :index, instance_id: instance.id
... |
adrian-gomez/ward-web | spec/factories/readings.rb | FactoryGirl.define do
factory :reading do
data { { disk_usage: rand * 100, cpu_usage: rand * 100,
process_list: %W[process-#{rand(1..100)}]*10 } }
instance
end
end |
adrian-gomez/ward-web | app/controllers/api_controller.rb | class ApiController < ApplicationController
protect_from_forgery with: :null_session
rescue_from ActionController::ParameterMissing do |exception|
render json: { messages: ["Parameter #{exception.param} is required"] },
status: :unprocessable_entity
end
end |
adrian-gomez/ward-web | app/controllers/reports_controller.rb | class ReportsController < ApplicationController
def index
@cpu_usage_rank = cpu_usage_rank
@low_disk_space = low_disk_usage
end
private
def cpu_usage_rank
Instance.all.map do |instance|
reading = instance.readings.last
next unless reading
cpu_usage = reading.data.cpu_usage
... |
adrian-gomez/ward-web | app/controllers/api/readings_controller.rb | class Api::ReadingsController < ApiController
before_action :set_instance, only: [:create]
# POST /api/readings
def create
instance = Reading.create(reading_params)
if instance.persisted?
render json: { messages: ['Reading stored'], actions: [] }
else
render json: { messages: instance.e... |
adrian-gomez/ward-web | app/models/reading_data.rb | <filename>app/models/reading_data.rb
class ReadingData
include Mongoid::Document
include Mongoid::Attributes::Dynamic
field :cpu_usage, type: Float
field :disk_usage, type: Float
embedded_in :reading
end |
adrian-gomez/ward-web | spec/rails_helper.rb | ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
abort('The Rails environment is running in production mode!') if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
RSpec.configure do |config|... |
adrian-gomez/ward-web | app/helpers/instances_helper.rb | module InstancesHelper
def instance_title(instance)
if instance.label.present?
"#{instance.label} [#{instance.ip}]"
else
"#{instance.ip}"
end
end
end |
adrian-gomez/ward-web | config/routes.rb | <reponame>adrian-gomez/ward-web
Rails.application.routes.draw do
get :dashboard, controller: :dashboard, action: :index
get :reports, controller: :reports, action: :index
resources :instances do
resources :readings, only: [:index, :show], controller: 'instances/readings'
end
namespace :api, defaults: ... |
adrian-gomez/ward-web | spec/controllers/reports_controller_spec.rb | <gh_stars>0
require 'rails_helper'
RSpec.describe ReportsController do
describe 'GET #index' do
let!(:instance) { create(:instance) }
it 'assigns the cpu usage rank as @cpu_usage_rank' do
get :index
expect(assigns(:cpu_usage_rank)).to be
end
it 'assigns the instances with log disk sp... |
adrian-gomez/ward-web | config/deploy/production.rb | server 'ec2-54-187-76-110.us-west-2.compute.amazonaws.com', user: 'ubuntu', roles: %w{app db web} |
adrian-gomez/ward-web | app/controllers/dashboard_controller.rb | <reponame>adrian-gomez/ward-web
class DashboardController < ApplicationController
def index
@instances = Instance.all
end
end |
adrian-gomez/ward-web | spec/models/instance_spec.rb | <filename>spec/models/instance_spec.rb
require 'rails_helper'
RSpec.describe Instance do
describe 'validations' do
let(:instance_attrs) { attributes_for(:instance) }
context 'when the ip is empty' do
before { instance_attrs[:ip] = '' }
it 'adds an error for ip' do
instance = Instance.... |
adrian-gomez/ward-web | spec/helpers/instances_helper_spec.rb | <reponame>adrian-gomez/ward-web<gh_stars>0
require 'rails_helper'
RSpec.describe InstancesHelper do
describe '#instance_title' do
let(:instance) { create(:instance, ip: '127.1.1.4') }
context 'when the instance has a label' do
before { instance.label = 'some label' }
it 'returns the label and... |
adrian-gomez/ward-web | app/controllers/instances_controller.rb | class InstancesController < ApplicationController
before_action :set_instance, only: [:show, :edit, :update, :destroy]
# GET /instances
def index
@instances = Instance.all
end
# GET /instances/1
def show
end
# GET /instances/new
def new
@instance = Instance.new
end
# GET /instances/1/... |
adrian-gomez/ward-web | spec/views/instances/new.html_spec.rb | <gh_stars>0
require 'rails_helper'
RSpec.describe 'instances/new' do
let(:instance) { Instance.new }
before { assign(:instance, instance) }
it 'renders the new instance form' do
render
assert_select 'form[action=?][method=?]', instances_path, 'post' do
assert_select 'input[name=?]', 'instance[i... |
bkayes/home | _plugins/jsonfeed.rb | <filename>_plugins/jsonfeed.rb
module Jekyll
class JSONFeedFile < StaticFile
def initialize(site, base, dir, name, docs)
super(site, site.source, dir, name)
@docs = docs
end
def feed_data()
markdown = @site.find_converter_instance(Jekyll::Converters::Markdown)
smart = @site.find_c... |
rickytan/RTBlockCallChecker | RTBlockCallChecker.podspec | <reponame>rickytan/RTBlockCallChecker
#
# Be sure to run `pod lib lint RTBlockCallChecker.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spe... |
uk-gov-mirror/alphagov.search-admin | features/step_definitions/update_search_index_on_best_bet_change_steps.rb | Then(/^the query should have been sent to the metasearch index$/) do
check_search_api_was_sent_an_exact_best_bet_document(Query.last)
end
Then(/^the remaining merged best bets should have been sent to the metasearch index$/) do
check_search_api_was_sent_an_exact_best_bet_document(Query.last)
end
Then(/^the best b... |
uk-gov-mirror/alphagov.search-admin | app/mailers/application_mailer.rb | <gh_stars>1-10
class ApplicationMailer < Mail::Notify::Mailer
default from: proc { no_reply_email_address }
def no_reply_email_address
name = "GOV.UK publishing"
if GovukAdminTemplate.environment_label !~ /production/i
name.prepend("[GOV.UK #{GovukAdminTemplate.environment_label}] ")
end
addr... |
uk-gov-mirror/alphagov.search-admin | app/models/elastic_search_recommended_link.rb | class ElasticSearchRecommendedLink
delegate :format, :link, :title, :description, to: :recommended_link
def initialize(recommended_link)
@recommended_link = recommended_link
end
def body
{
link: link,
details: details.to_json,
}
end
def details
{
title: title,
link... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.