source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/helpers.rb | Ruby | mit | 86 | master | 665 | # frozen_string_literal: true
require_relative 'log'
require_relative 'mail'
module DoSnapshot
# Helpers for main class.
#
module Helpers
def logger
UniversalLogger
end
# UniversalLogger is a module to deal with singleton methods.
# Used to give classes access only for selected methods
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/runner.rb | Ruby | mit | 86 | master | 1,284 | # frozen_string_literal: true
require 'do_snapshot/cli'
module DoSnapshot
# CLI Runner
#
class Runner
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
@argv = argv
@stdin = stdin
@stdout = stdout
@stderr = stderr
@kernel = kernel
end
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/command.rb | Ruby | mit | 86 | master | 5,731 | # -*- encoding : utf-8 -*-
# frozen_string_literal: true
require_relative 'adapter'
module DoSnapshot
# Our commands live here :)
#
class Command # rubocop:disable ClassLength
include DoSnapshot::Helpers
RESET_OPTIONS = [:droplets, :exclude, :only, :keep, :quiet,
:stop, :clean, :tim... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/configuration.rb | Ruby | mit | 86 | master | 436 | # frozen_string_literal: true
module DoSnapshot
# Configuration class. Used to share config across application.
#
class Configuration
attr_accessor :logger
attr_accessor :logger_level
attr_accessor :verbose
attr_accessor :quiet
attr_accessor :mailer
def initialize
@logger = nil
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/core_ext/hash.rb | Ruby | mit | 86 | master | 1,035 | # -*- encoding : utf-8 -*-
# frozen_string_literal: true
# Rails symbolize keys methods for Hash
#
class Hash
# Returns a new hash with all keys converted using the block operation.
#
# hash = { name: 'Rob', age: '28' }
#
# hash.transform_keys{ |key| key.to_s.upcase }
# # => {"NAME"=>"Rob", "AGE"=>"28"}
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/rspec/environment.rb | Ruby | mit | 86 | master | 4,581 | # frozen_string_literal: true
module DoSnapshot
module RSpec
module Environment # rubocop:disable Style/Documentation
extend ::RSpec::Core::SharedContext
include ApiHelpers
def do_not_send_email
allow(Pony).to receive(:deliver) { |mail| mail }
end
let(:client_key) ... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/rspec/uri_helpers.rb | Ruby | mit | 86 | master | 793 | # frozen_string_literal: true
module DoSnapshot
module RSpec
module UriHelpers # rubocop:disable Style/Documentation
extend ::RSpec::Core::SharedContext
let(:droplet_url) { url_with_id(droplet_find_uri, droplet_id) }
let(:droplet_stop_url) { url_with_id(droplet_stop_uri, droplet_id) }
let... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/rspec/adapter.rb | Ruby | mit | 86 | master | 8,450 | # frozen_string_literal: true
module DoSnapshot
module RSpec
module Adapter # rubocop:disable Style/Documentation,Metrics/ModuleLength
extend ::RSpec::Core::SharedContext
subject(:api) { described_class }
subject(:log) { DoSnapshot::Log }
describe '.initialize' do
describe '#dela... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/rspec/api_helpers.rb | Ruby | mit | 86 | master | 1,404 | # frozen_string_literal: true
module DoSnapshot
module RSpec
module ApiHelpers # rubocop:disable Style/Documentation
extend ::RSpec::Core::SharedContext
# Stub helpers
#
def stub_with_id(request, id, fixture, status = 200)
return unless request && fixture && id
stub_reques... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/rspec/api_v2_helpers.rb | Ruby | mit | 86 | master | 5,252 | # frozen_string_literal: true
module DoSnapshot
module RSpec
module ApiV2Helpers # rubocop:disable Style/Documentation,Metrics/ModuleLength
extend ::RSpec::Core::SharedContext
let(:api_base) { 'https://api.digitalocean.com/v2' }
let(:droplets_api_base) { "#{api_base}/droplets" }
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/adapter/droplet_kit.rb | Ruby | mit | 86 | master | 4,525 | # -*- encoding : utf-8 -*-
# frozen_string_literal: true
require_relative '../gem_ext/resource_kit'
require 'droplet_kit' unless defined?(::DropletKit)
module DoSnapshot
module Adapter
# API for CLI commands
# Operating with Digital Ocean.
#
class DropletKit < Abstract
attr_reader :client, :pe... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/adapter/abstract.rb | Ruby | mit | 86 | master | 3,024 | # -*- encoding : utf-8 -*-
# frozen_string_literal: true
module DoSnapshot
module Adapter
# API for CLI commands
# Operating with Digital Ocean.
#
class Abstract
include DoSnapshot::Helpers
attr_accessor :delay, :timeout
attr_writer :stop_by
def initialize(options = {})
... |
github | merqlove/do_snapshot | https://github.com/merqlove/do_snapshot | lib/do_snapshot/gem_ext/resource_kit.rb | Ruby | mit | 86 | master | 1,059 | # frozen_string_literal: true
require 'resource_kit'
require 'forwardable'
# TODO: Remove after `resource_kit` gem update.
module ResourceKit
module ActionFix # rubocop:disable Style/Documentation
def handler(*response_codes, &block)
if response_codes.empty?
handlers[:any] = block
else
... |
github | ossert/ossert | https://github.com/ossert/ossert | Rakefile | Ruby | mit | 86 | master | 316 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'sequel'
require 'bundler'
Bundler.require
RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new
Dir.glob('lib/ossert/tasks/*.rake').each { |r| import r }
task default: %i[rubocop spec] |
github | ossert/ossert | https://github.com/ossert/ossert | ossert.gemspec | Ruby | mit | 86 | master | 2,221 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ossert/version'
Gem::Specification.new do |spec|
spec.name = 'ossert'
spec.version = Ossert::VERSION
spec.authors = ['Sergey Dolganov']
spec.email ... |
github | ossert/ossert | https://github.com/ossert/ossert | Gemfile | Ruby | mit | 86 | master | 340 | # frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'decisiontree', github: 'sclinede/decisiontree'
gem 'kmeans-clusterer', github: 'gbuesing/kmeans-clusterer'
gem 'sawyer', github: 'sclinede/sawyer'
# Specify your gem's dependencies in oss... |
github | ossert/ossert | https://github.com/ossert/ossert | config/sidekiq.rb | Ruby | mit | 86 | master | 333 | # frozen_string_literal: true
require 'ossert'
SIDEKIQ_REDIS_CONFIGURATION = {
url: ENV.fetch('REDIS_URL'),
namespace: 'ossert_sidekiq'
}.freeze
Sidekiq.configure_server do |config|
config.redis = SIDEKIQ_REDIS_CONFIGURATION.dup
end
Sidekiq.configure_client do |config|
config.redis = SIDEKIQ_REDIS_CONFIGURA... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert.rb | Ruby | mit | 86 | master | 1,406 | # frozen_string_literal: true
require 'ossert/version'
require 'sequel'
require 'active_support/all' # TODO: remove later
require 'json'
require 'oj'
require 'ossert/config'
Ossert::Config.load(:stats, :classifiers_growth, :classifiers_cluster, :translations, :descriptions, :fetchers)
require 'ossert/stats'
require ... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/project.rb | Ruby | mit | 86 | master | 7,621 | # frozen_string_literal: true
module Ossert
class Project
include Ossert::Saveable
attr_accessor :name, :github_alias, :rubygems_alias,
:community, :agility, :reference,
:meta, :created_at, :updated_at, :id
# Public: Default structure of meta data for project
MET... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter.rb | Ruby | mit | 86 | master | 415 | # frozen_string_literal: true
require 'ossert/twitter/tweets_fetcher'
require 'ossert/twitter/metrics_collector'
require 'ossert/twitter/metrics_updater'
require 'ossert/twitter/metrics_averager'
require 'ossert/twitter/search_results_patch'
require 'ossert/twitter/tokens_rotator'
require 'ossert/twitter/scheduler'
re... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/config.rb | Ruby | mit | 86 | master | 1,427 | # frozen_string_literal: true
require 'yaml'
module Ossert
class Config
# Public: Path to directory where config files are stored.
CONFIG_ROOT = File.join(File.dirname(__FILE__), '..', '..', 'config')
# Public: Name of constant which is used to access config.
CONST_NAME = 'Settings'
# Public: ... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch.rb | Ruby | mit | 86 | master | 5,242 | # frozen_string_literal: true
require 'nokogiri'
require 'open-uri'
require 'benchmark'
require 'ossert/fetch/utils/keys_storage'
require 'ossert/fetch/github'
require 'ossert/fetch/rubygems'
require 'ossert/fetch/bestgems'
require 'ossert/fetch/stackoverflow'
require 'ossert/fetch/twitter'
module Ossert
# Public:... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/quarters_store.rb | Ruby | mit | 86 | master | 6,035 | # frozen_string_literal: true
module Ossert
# Public: Class for data divided by quarters. Each quarter instantiates some statistics class.
# Contains methods for quarters calculations, such as grouping, preview and other.
class QuartersStore
attr_reader :quarters, :start_date, :end_date
# Public: Instan... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers.rb | Ruby | mit | 86 | master | 402 | # frozen_string_literal: true
require 'sidekiq'
require 'sidekiq-unique-jobs'
require 'ossert/workers/fork_processing'
require 'ossert/workers/fetch'
require 'ossert/workers/partial_fetch'
require 'ossert/workers/fetch_bestgems_page'
require 'ossert/workers/fetch_twitter'
require 'ossert/workers/refresh_fetch'
require... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/repositories.rb | Ruby | mit | 86 | master | 4,683 | # frozen_string_literal: true
require 'oj'
require 'multi_json'
Sequel::Model.require_valid_table = false
class NameException < Sequel::Model(:exceptions)
set_primary_key [:name]
class << self
alias by_name []
end
end
::NameException.unrestrict_primary_key
class TwitterMetrics < Sequel::Model(:twitter_me... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/saveable.rb | Ruby | mit | 86 | master | 3,765 | # frozen_string_literal: true
module Ossert
module Saveable
UNUSED_REFERENCE = 'unused'
ATTRIBUTE_EXTRACT_VALUE_MAP = {
agility_total_data: ->(project) { project.agility.total.to_json },
agility_quarters_data: ->(project) { project.agility.quarters.to_json },
community_total_data: ->(projec... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats.rb | Ruby | mit | 86 | master | 2,435 | # frozen_string_literal: true
require 'ossert/stats/base'
require 'ossert/stats/agility_total'
require 'ossert/stats/agility_quarter'
require 'ossert/stats/community_total'
require 'ossert/stats/community_quarter'
module Ossert
module Stats
# @return [Numeric] specifies too long interval border for quarter
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers.rb | Ruby | mit | 86 | master | 3,216 | # frozen_string_literal: true
require 'ossert/classifiers/base'
require 'ossert/classifiers/decision_tree'
require 'ossert/classifiers/growing'
require 'ossert/classifiers/cluster'
require 'ossert/classifiers/check'
module Ossert
module Classifiers
module_function
# The list of available data sections.
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/reference.rb | Ruby | mit | 86 | master | 2,446 | # frozen_string_literal: true
module Ossert
module Reference
def prepare_projects!
references = %w[A B C D E].map { |e| Kernel.const_get("Ossert::Reference::Class#{e}").new }
references.each(&:prepare_projects!)
references
end
module_function :prepare_projects!
def process_referenc... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats/community_quarter.rb | Ruby | mit | 86 | master | 885 | # frozen_string_literal: true
module Ossert
module Stats
class CommunityQuarter < Base
self.section = 'community'
self.section_type = 'quarter'
create_attributes_accessors
define_counts(
:users_creating_issues, :users_commenting_issues, :users_creating_pr,
:users_commenti... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats/agility_quarter.rb | Ruby | mit | 86 | master | 1,593 | # frozen_string_literal: true
module Ossert
module Stats
class AgilityQuarter < Base
self.section = 'agility'
self.section_type = 'quarter'
create_attributes_accessors
define_percent(
issues_active: :issues_all,
issues_closed: :issues_all,
pr_active: :pr_all,
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats/community_total.rb | Ruby | mit | 86 | master | 689 | # frozen_string_literal: true
module Ossert
module Stats
class CommunityTotal < Base
self.section = 'community'
self.section_type = 'total'
create_attributes_accessors
define_percent(questions_resolved: :questions)
define_counts(
:users_creating_issues, :users_commenting_i... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats/base.rb | Ruby | mit | 86 | master | 9,424 | # frozen_string_literal: true
module Ossert
module Stats
# A base class for storing and handling values extracted from the projects.
#
# All metric-specific methods and variables are creating in runtime via
# class instance methods "define_*" (intended to use in subclasses) and
# in the construct... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/stats/agility_total.rb | Ruby | mit | 86 | master | 1,584 | # frozen_string_literal: true
module Ossert
module Stats
class AgilityTotal < Base
self.section = 'agility'
self.section_type = 'total'
create_attributes_accessors
define_percent(
issues_active: :issues_all,
issues_closed: :issues_all,
issues_non_owner: :issues_al... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/scheduler.rb | Ruby | mit | 86 | master | 884 | # frozen_string_literal: true
module Ossert
module Twitter
class Scheduler
RATE_LIMIT = 180
RATE_INTERVAL = 15.minutes
FAULT_FACTOR = 0.75
REQUESTS_PER_PROJECT = 1.3
def call(projects)
tokens_count = Ossert::Twitter::Credentials.access_tokens.count
now = Time.now
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/metrics_updater.rb | Ruby | mit | 86 | master | 1,158 | # frozen_string_literal: true
require 'sequel'
module Ossert
module Twitter
# Updates twitter metrics to dabase and with moving averaging
class MetricsUpdater
attr_reader :project
def initialize(project)
@project = project
end
def call(date:, metrics:)
base_attrs = ... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/credentials.rb | Ruby | mit | 86 | master | 1,261 | # frozen_string_literal: true
require 'redis'
module Ossert
module Twitter
# Twitter API access tokens
class Credentials
MAX_TOKENS = 100
class << self
def consumer_key
@consumer_key ||= {
consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY'),
consumer_secret:... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/search_results_validator.rb | Ruby | mit | 86 | master | 883 | # frozen_string_literal: true
require 'json-schema'
module Ossert
module Twitter
# Validates tweets list user json-schema when enabled
class SearchResultsValidator
class << self
def validate!
enable!
yield
rescue StandardError => e
disable!
raise... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/metrics_collector.rb | Ruby | mit | 86 | master | 1,156 | # frozen_string_literal: true
module Ossert
module Twitter
# Calculates metrics of passed tweets
class MetricsCollector
attr_reader :tweets
def initialize(tweets)
@tweets = tweets
end
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def call
empty_metric... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/tweets_fetcher.rb | Ruby | mit | 86 | master | 857 | # frozen_string_literal: true
require 'ossert/twitter/search_results_validator'
module Ossert
module Twitter
# Fetches tweets from Twitter API
class TweetsFetcher
DEFAULT_TIMEOUTS = { connect: 2.seconds, read: 2.seconds }.freeze
attr_reader :project, :credentials, :timeouts
def initialize... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/tokens_rotator.rb | Ruby | mit | 86 | master | 1,265 | # frozen_string_literal: true
require 'ossert/twitter/credentials'
require 'redis'
module Ossert
module Twitter
class TokensRotator
DeferedTokenError = Class.new(StandardError) do
attr_reader :defer_time
def initialize(defer_time)
@defer_time = defer_time
end
end
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/search_results_patch.rb | Ruby | mit | 86 | master | 642 | # frozen_string_literal: true
require 'twitter'
require_relative 'search_results_validator'
module Ossert
module Twitter
# Patches Twitter::SearchResults class from twitter gem to
# validate json schema
module SearchResultsPatch
def self.apply_json_validator!
patch_module = Module.new do
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/twitter/metrics_averager.rb | Ruby | mit | 86 | master | 926 | # frozen_string_literal: true
module Ossert
module Twitter
# Calculates moving average for all twitter metrics
class MetricsAverager
attr_reader :previous_date, :previous_metrics
def initialize(previous_date:, previous_metrics:)
@previous_date = previous_date
@previous_metrics = ... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/decision_tree.rb | Ruby | mit | 86 | master | 3,571 | # frozen_string_literal: true
require 'graphr'
require 'decisiontree'
module Ossert
module Classifiers
class DecisionTree
class << self
attr_accessor :all
# Prepare and return decision tree classifier instance for existing
# refernce projects.
#
# @return [Ossert::... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/cluster.rb | Ruby | mit | 86 | master | 8,375 | # frozen_string_literal: true
require 'kmeans-clusterer'
module Ossert
module Classifiers
# Class for Cluster classification. Uses K-Means clusterization.
class Cluster < Base
THRESHOLDS_PATH = 'cluster/thresholds.yml'
DISTRIBUTION_PATH = 'cluster/distribution.yml'
# Prepare and return cl... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/growing.rb | Ruby | mit | 86 | master | 4,125 | # frozen_string_literal: true
require 'ossert/classifiers/growing/classifier'
module Ossert
module Classifiers
class Growing < Base
class << self
attr_accessor :all
# Prepare and return growing classifier instance.
# The last prepared growing classifier.
#
# @retur... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/check.rb | Ruby | mit | 86 | master | 6,588 | # frozen_string_literal: true
module Ossert
module Classifiers
class Check
GRADES = %w[
A
B
C
D
E
].freeze
KLASS_2_GRADE = {
'ClassA' => 'A',
'ClassB' => 'B',
'ClassC' => 'C',
'ClassD' => 'D',
'ClassE' => 'E'
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/base.rb | Ruby | mit | 86 | master | 3,174 | # frozen_string_literal: true
module Ossert
module Classifiers
class Base
# @return [Hash] the configuration of Cluster classifier.
def self.config
raise NotImplementedError
end
# (see .config)
def config
self.class.config
end
# @return [Array] the list... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/classifiers/growing/classifier.rb | Ruby | mit | 86 | master | 4,951 | # frozen_string_literal: true
module Ossert
module Classifiers
class Growing < Base
class Classifier
# @return [Hash] of classifier metrics values
attr_reader :classifier
# @return [Hash] of classifier configuration
attr_reader :config
# @return [Symbol] the classi... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/github.rb | Ruby | mit | 86 | master | 19,094 | # frozen_string_literal: true
require 'octokit'
module Ossert
module Fetch
class GitHub
attr_reader :client, :project
extend Forwardable
def_delegators :project, :agility, :community, :meta
def initialize(project)
@client = ::Octokit::Client.new(access_token: Utils::KeysStorage... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/bestgems.rb | Ruby | mit | 86 | master | 2,791 | # frozen_string_literal: true
module Ossert
module Fetch
class BestgemsBase
def self.process_page(page = nil)
doc = Nokogiri::HTML(open("http://bestgems.org/#{endpoint}#{page ? "?page=#{page}" : ''}"))
doc.css('table').xpath('//tr//td').each_slice(4) do |rank, downloads, name, _|
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/twitter.rb | Ruby | mit | 86 | master | 709 | # frozen_string_literal: true
require 'ossert/twitter'
module Ossert
module Fetch
# Fetches metrics of passed project from Twitter and stores them to db
class Twitter
attr_reader :project, :credentials
def initialize(project, credentials)
@project = project
@credentials = creden... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/rubygems.rb | Ruby | mit | 86 | master | 2,418 | # frozen_string_literal: true
module Ossert
module Fetch
class Rubygems
attr_reader :client, :project
extend Forwardable
def_delegators :project, :agility, :community, :meta
GITHUB_REPO_REGEX = %r{github.com/([a-zA-Z0-9\.\_\-]+)/([a-zA-Z0-9\.\_\-]+)}.freeze
def initialize(project... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/stackoverflow.rb | Ruby | mit | 86 | master | 4,695 | # frozen_string_literal: true
module Ossert
module Fetch
# Class implementing `StackOverflow` crawler.
class StackOverflow
attr_reader :client, :project
# @!attribute [r] client
# a trivial client for fetching web API
# @return [SimpleClient] instance of the prepared web page fetcher... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/fetch/utils/keys_storage.rb | Ruby | mit | 86 | master | 566 | # frozen_string_literal: true
module Ossert
module Fetch
module Utils
module KeysStorage
class Base
def self.call
new(name.split('::').last.upcase).call
end
def initialize(name)
@storage_name = "#{name}_TOKEN_ARRAY"
end
def... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/tasks/database.rake | Ruby | mit | 86 | master | 5,146 | # frozen_string_literal: true
require 'dotenv'
Dotenv.load('.env.test.local', '.env.test')
require 'uri'
namespace :db do
require 'sequel'
Sequel.extension :migration
def create_db(uri)
database_name = uri.path.split('/').last
sh "createdb #{db_opts(uri)} #{database_name}"
end
def drop_db(uri)
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/tasks/ossert.rake | Ruby | mit | 86 | master | 3,566 | # frozen_string_literal: true
namespace :ossert do
namespace :cache do
desc 'Reset data cache'
task :reset do
::Ossert.init
::Classifier.dataset.delete
Ossert::Classifiers::Growing.new.train
true
end
end
namespace :twitter do
desc 'Schedules twitter fetch jobs for nearest... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/presenters/project_v2.rb | Ruby | mit | 86 | master | 6,307 | # frozen_string_literal: true
module Ossert
module Presenters
module ProjectV2
# The list of projects class types
CLASSES = %w[
ClassE
ClassD
ClassC
ClassB
ClassA
].freeze
# The map of class to its grade
KLASS_2_GRADE = {
'ClassA' => '... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/presenters/project.rb | Ruby | mit | 86 | master | 8,070 | # frozen_string_literal: true
require 'ossert/presenters/project_v2'
module Ossert
module Presenters
class Project
include Ossert::Presenters::ProjectV2
attr_reader :project, :decorator
def initialize(project)
@project = project
@reference = Ossert::Classifiers::Growing.curre... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/fork_processing.rb | Ruby | mit | 86 | master | 362 | # frozen_string_literal: true
module Ossert
module Workers
module ForkProcessing
def self.included(base)
base.send :include, Process
end
def process_in_fork(force: false)
return yield if !force && (ENV['CI'] || ENV['TEST'])
pid = fork { yield }
waitpid(pid)
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/fetch_twitter.rb | Ruby | mit | 86 | master | 1,282 | # frozen_string_literal: true
module Ossert
module Workers
# Sidekiq worker for fetching metrics from Twitter API
class FetchTwitter
include ::Sidekiq::Worker
DEFER_TOKEN_DELTA = 5.seconds
sidekiq_options queue: :twitter,
unique: :until_executing,
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/refresh_fetch.rb | Ruby | mit | 86 | master | 641 | # frozen_string_literal: true
module Ossert
module Workers
class RefreshFetch
include Sidekiq::Worker
include ForkProcessing
sidekiq_options unique: :until_executed,
unique_expiration: 1.hour,
retry: 3
def perform
process_in_fork do
... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/fetch.rb | Ruby | mit | 86 | master | 550 | # frozen_string_literal: true
module Ossert
module Workers
class Fetch
include Sidekiq::Worker
include ForkProcessing
sidekiq_options unique: :until_executed,
unique_expiration: 1.hour,
retry: 3
def perform(name, reference = Ossert::Saveable::U... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/partial_fetch.rb | Ruby | mit | 86 | master | 720 | # frozen_string_literal: true
module Ossert
module Workers
class PartialFetch
include Sidekiq::Worker
include ForkProcessing
sidekiq_options unique: :until_executed,
unique_expiration: 1.hour,
retry: 3
def perform(fetcher_name, name, reference ... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/partial_refresh_fetch.rb | Ruby | mit | 86 | master | 587 | # frozen_string_literal: true
module Ossert
module Workers
class PartialRefreshFetch
include Sidekiq::Worker
include ForkProcessing
sidekiq_options unique: :until_executed,
unique_expiration: 1.hour,
retry: 3
def perform(fetcher_name)
p... |
github | ossert/ossert | https://github.com/ossert/ossert | lib/ossert/workers/fetch_bestgems_page.rb | Ruby | mit | 86 | master | 926 | # frozen_string_literal: true
module Ossert
module Workers
class FetchBestgemsPage
include Sidekiq::Worker
include ForkProcessing
sidekiq_options retry: 3,
unique: :until_executed
def perform(pages, type = :total)
pages = Array(pages)
bestgems_page_... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/spec_helper.rb | Ruby | mit | 86 | master | 4,083 | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start
if ENV['CI']
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
end
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
ENV['TEST'] = '1'
require 'sequel'
require 'ossert'
require 'dotenv'
Dotenv.load('.env.test.local', '.... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert_spec.rb | Ruby | mit | 86 | master | 14,547 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert do
let(:projectA) { Ossert::Project.load_by_name(@a_project) }
let(:projectB) { Ossert::Project.load_by_name(@b_project) }
let(:projectC) { Ossert::Project.load_by_name(@c_project) }
let(:projectD) { Ossert::Project.load_by_name(@d_project) }... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert_stats_spec.rb | Ruby | mit | 86 | master | 15,466 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert do
describe 'metrics data' do
let(:projectA) { Ossert::Project.load_by_name(@a_project) }
let(:projectB) { Ossert::Project.load_by_name(@b_project) }
let(:projectC) { Ossert::Project.load_by_name(@c_project) }
let(:projectD) { Osser... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/fetch/twitter_spec.rb | Ruby | mit | 86 | master | 1,022 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert::Fetch::Twitter do
describe 'process' do
let(:credentials) { Ossert::Twitter::Credentials.default }
let(:fetcher) { described_class.new(project, credentials) }
let(:project) { Ossert::Project.load_by_name('sidekiq') }
let(:date) { D... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/metrics_averager_spec.rb | Ruby | mit | 86 | master | 989 | # frozen_string_literal: true
describe Ossert::Twitter::MetricsAverager do
let(:previous_date) { Date.new(2018, 3, 19) }
let(:previous_metrics) { { tweets_count: 5.0 } }
let(:average) do
described_class
.new(previous_date: previous_date, previous_metrics: previous_metrics)
.call(next_date: next_d... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/metrics_updater_spec.rb | Ruby | mit | 86 | master | 1,049 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert::Twitter::MetricsUpdater do
let!(:project) { ::Project.create(name: 'pp', github_name: 'pp/pp', rubygems_name: 'pp', reference: 'ClassA') }
let(:date) { Date.new(2018, 3, 20) }
let(:record) { ::TwitterMetrics.where(date: date.monday, project_id... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/metrics_collector_spec.rb | Ruby | mit | 86 | master | 1,474 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe Ossert::Twitter::MetricsCollector do
describe 'new' do
let(:collector) { described_class.new(tweets) }
let(:tweets) { json.map { |j| ::Twitter::Tweet.new(j) } }
let(:json) do
symbolize_keys!(JSON.par... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/tweets_fetcher_spec.rb | Ruby | mit | 86 | master | 1,116 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert::Twitter::TweetsFetcher do
describe 'call' do
let(:project) { double(github_alias: 'mperham/sidekiq') }
let(:fetcher) { described_class.new(project, Ossert::Twitter::Credentials.default) }
it 'works with 200 response' do
VCR.use_... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/search_results_validator_spec.rb | Ruby | mit | 86 | master | 573 | # frozen_string_literal: true
require 'spec_helper'
require 'json'
describe Ossert::Twitter::SearchResultsValidator do
describe 'call!' do
let(:validator) { described_class }
context 'valid twitter json' do
let(:json) { JSON.parse(File.read('spec/fixtures/twitter/valid.json')) }
it { expect { ... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/credentials_spec.rb | Ruby | mit | 86 | master | 1,491 | # frozen_string_literal: true
require 'spec_helper'
# rubocop:disable Metrics/BlockLength
describe Ossert::Twitter::Credentials do
describe 'consumer_key' do
let(:consumer_key) { described_class.consumer_key }
it 'loads consumer key from env variables' do
expect(consumer_key).to eq(
consumer_... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/twitter/tokens_rotator_spec.rb | Ruby | mit | 86 | master | 1,230 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert::Twitter::TokensRotator do
let(:default_token) { Ossert::Twitter::Credentials.default_access_token }
let(:extra_token) { Ossert::Twitter::Credentials.access_tokens[1] }
let(:next_token) { described_class.next_token }
it 'returns the first to... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/ossert/workers/fetch_twitter_spec.rb | Ruby | mit | 86 | master | 610 | # frozen_string_literal: true
require 'spec_helper'
describe Ossert::Workers::FetchTwitter do
it 'retries failed job 3 times' do
is_expected.to be_retryable 5
end
describe 'perform' do
context 'when rate limit' do
pending
end
end
describe 'retry_in' do
let(:defer_time) { Time.now + 1... |
github | ossert/ossert | https://github.com/ossert/ossert | spec/support/keys_symbolizer.rb | Ruby | mit | 86 | master | 378 | # frozen_string_literal: true
module KeysSymbolizer
def symbolize_keys!(object)
if object.is_a?(Array)
object.each_with_index do |val, index|
object[index] = symbolize_keys!(val)
end
elsif object.is_a?(Hash)
object.dup.each_key do |key|
object[key.to_sym] = symbolize_keys!(o... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/007_migrate_json_to_jsonb.rb | Ruby | mit | 86 | master | 326 | # frozen_string_literal: true
Sequel.migration do
up do
%w[agility_total_data
agility_quarters_data
community_total_data
community_quarters_data
meta_data].each do |column|
run "ALTER TABLE projects ALTER COLUMN #{column} SET DATA TYPE jsonb USING #{column}::jsonb;"
end
en... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/004_add_timestamps_to_projects.rb | Ruby | mit | 86 | master | 338 | # frozen_string_literal: true
Sequel.migration do
up do
run 'ALTER TABLE projects ADD COLUMN created_at TIMESTAMP DEFAULT NOW() NOT NULL;'
run 'ALTER TABLE projects ADD COLUMN updated_at TIMESTAMP DEFAULT NOW() NOT NULL;'
end
down do
drop_column :projects, :created_at
drop_column :projects, :upd... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/008_create_twitter_metrics.rb | Ruby | mit | 86 | master | 565 | # frozen_string_literal: true
Sequel.migration do
up do
METRIC_COLUMNS = %i[
tweets_count favorites_count replies_count
retweets_count coverage twitters_count
].freeze
create_table(:twitter_metrics) do
primary_key :id
foreign_key :project_id, :projects, null: false, on_delete: :c... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/005_create_classifiers.rb | Ruby | mit | 86 | master | 448 | # frozen_string_literal: true
Sequel.migration do
up do
extension :pg_json
create_table(:classifiers) do
primary_key :id
String :section, null: false
json :reference_values
end
run 'ALTER TABLE classifiers ADD COLUMN created_at TIMESTAMP DEFAULT NOW() NOT NULL;'
run 'ALTER TAB... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/001_create_projects.rb | Ruby | mit | 86 | master | 480 | # frozen_string_literal: true
Sequel.migration do
up do
extension :pg_json
create_table(:projects) do
primary_key :id
String :name, null: false
String :github_name, null: false
String :rubygems_name, null: false
String :reference, null: false
json :agility_total_data
... |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/002_create_exceptions.rb | Ruby | mit | 86 | master | 248 | # frozen_string_literal: true
Sequel.migration do
up do
create_table(:exceptions) do
primary_key :id
String :name, null: false
String :github_name, null: false
end
end
down do
drop_table(:exceptions)
end
end |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/003_add_meta_to_projects.rb | Ruby | mit | 86 | master | 220 | # frozen_string_literal: true
Sequel.migration do
up do
extension :pg_json
alter_table(:projects) do
add_column :meta_data, JSON
end
end
down do
drop_column :projects, :meta_data
end
end |
github | ossert/ossert | https://github.com/ossert/ossert | db/migrate/006_add_search_index_to_projects.rb | Ruby | mit | 86 | master | 277 | # frozen_string_literal: true
Sequel.migration do
up do
run 'CREATE EXTENSION IF NOT EXISTS pg_trgm'
run 'CREATE INDEX projects_name_search_index ON projects USING gist (name gist_trgm_ops)'
end
down do
run 'DROP INDEX projects_name_search_index'
end
end |
github | defunkt/gem-man | https://github.com/defunkt/gem-man | Rakefile | Ruby | mit | 86 | master | 634 | desc "Build the manual"
task :build_man do
sh "ron -br5 --organization=DEFUNKT --manual='RubyGems Manual' man/*.ron"
end
desc "Show the manual"
task :man => :build_man do
exec "man man/gem-man.1"
end
begin
require 'mg'
MG.new('gem-man.gemspec')
rescue LoadError
warn "gem install mg to get gem tasks"
end
de... |
github | defunkt/gem-man | https://github.com/defunkt/gem-man | gem-man.gemspec | Ruby | mit | 86 | master | 721 | Gem::Specification.new do |s|
s.name = "gem-man"
s.version = "0.3.0"
s.date = "2011-08-15"
s.summary = "View a gem's man page."
s.homepage = "https://github.com/defunkt/gem-man"
s.email = "chris@ozmm.org"
s.authors = [ "Chris Wan... |
github | defunkt/gem-man | https://github.com/defunkt/gem-man | lib/rubygems/gem/specification.rb | Ruby | mit | 86 | master | 533 | class Gem::Specification
##
# Returns the full path to installed gem's manual directory.
def man_dir
@man_dir ||= File.join(respond_to?(:gem_dir) ? gem_dir : full_gem_path, 'man')
end
##
# Does this specification include a manpage?
def has_manpage?(section = nil)
File.directory?(man_dir) && ma... |
github | defunkt/gem-man | https://github.com/defunkt/gem-man | lib/rubygems/commands/man_command.rb | Ruby | mit | 86 | master | 3,843 | # Much of this is stolen from the `open_gem` RubyGem's "read"
# command - thanks Adam!
#
# http://github.com/adamsanderson/open_gem/blob/dfddaa286e/lib/rubygems/commands/read_command.rb
class Gem::Commands::ManCommand < Gem::Command
include Gem::VersionOption
def initialize
super 'man', "Open a gem's manual",
... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | camcorder.gemspec | Ruby | mit | 86 | master | 921 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'camcorder/version'
Gem::Specification.new do |spec|
spec.name = "camcorder"
spec.version = Camcorder::VERSION
spec.authors = ["Gordon L. Hempton"]
spec.email ... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder.rb | Ruby | mit | 86 | master | 2,095 | require "camcorder/version"
require 'camcorder/errors'
require 'camcorder/proxy'
require 'camcorder/recorder'
require 'camcorder/configuration'
#
# Provides similar functionality as the VCR gem but works on arbitrary objects.
# This is useful for things like Net::IMAP and Net::SMTP which cannot be
# captured by VCR.
#... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/proxy.rb | Ruby | mit | 86 | master | 1,719 | module Camcorder
#
# Proxy which records all external methods
#
class Proxy
attr_reader :klass
attr_reader :instance
attr_reader :recorder
attr_reader :side_effects
def initialize(recorder, klass, *args)
@klass = klass
@init_args = args
@recorder = recorder
... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/rspec.rb | Ruby | mit | 86 | master | 1,035 | #
# Setup the camcorder before every test
#
RSpec.configure do |config|
recording_name_for = lambda do |metadata|
description = if metadata[:description].empty?
# we have an "it { is_expected.to be something }" block
metadata[:scoped_id]
else
... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/configuration.rb | Ruby | mit | 86 | master | 211 | module Camcorder
class Configuration
attr_accessor :recordings_dir
attr_accessor :verify_recordings
def initialize
@recordings_dir = ''
@verify_recordings = true
end
end
end |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/recorder.rb | Ruby | mit | 86 | master | 1,614 | require 'yaml'
require 'camcorder/recording'
module Camcorder
class Recorder
attr_reader :recordings
attr_reader :filename
def initialize(filename, verify_recordings: Camcorder.config.verify_recordings)
@filename = filename
@recordings = {}
@changed = false
@verify_recordings =... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/recording.rb | Ruby | mit | 86 | master | 792 | module Camcorder
class Recording
attr_reader :value
attr_reader :behavior
def initialize(&block)
@value = nil
@behavior = nil
end
def record(&block)
res = yield
# Make sure we store a copy of the result so future destructive mutations
# do not change... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | lib/camcorder/errors.rb | Ruby | mit | 86 | master | 1,220 | module Camcorder
class Error < StandardError; end
class RecordingError < Error
attr_reader :key
def initialize(key)
@key = key
end
def message
"Recording for key #{key} has changed"
end
end
class ProxyRecordingError < Error
attr_reader :klass, :name, :args, :side_eff... |
github | ghempton/camcorder | https://github.com/ghempton/camcorder | spec/camcorder_spec.rb | Ruby | mit | 86 | master | 1,617 | require 'spec_helper'
describe Camcorder do
describe 'constructor interception' do
before do
Camcorder.intercept_constructor(TestObject)
end
after do
Camcorder.deintercept_constructor(TestObject)
end
describe '.new' do
it 'should return a proxy' do
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.