From 50b052a9bd3507c39639e72fb4fe1f26b6492051 Mon Sep 17 00:00:00 2001 From: booboy Date: Fri, 1 Feb 2019 22:19:36 -0600 Subject: [PATCH] made elastic search helper better and made pastebinner pack json --- Gemfile | 4 +- Rakefile | 6 +- bin/console | 7 +- bin/pastebinner | 18 +- lib/elastic_search_helper.rb | 64 ++---- lib/examples/examples.rb | 6 +- lib/exceptions.rb | 17 +- lib/pastebinner.rb | 357 +++++++++++++++---------------- lib/pastebinner/exceptions.rb | 8 +- lib/pastebinner/option_parser.rb | 14 +- lib/pastebinner/version.rb | 2 +- pastebinner.gemspec | 39 ++-- spec/pastebinner_spec.rb | 4 +- spec/spec_helper.rb | 6 +- 14 files changed, 256 insertions(+), 296 deletions(-) mode change 100644 => 100755 lib/examples/examples.rb diff --git a/Gemfile b/Gemfile index 7462a8e..69c1897 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ -source "https://rubygems.org" +source 'https://rubygems.org' -git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } +git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in pastebinner.gemspec gemspec diff --git a/Rakefile b/Rakefile index b7e9ed5..4c774a2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,6 @@ -require "bundler/gem_tasks" -require "rspec/core/rake_task" +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec diff --git a/bin/console b/bin/console index 4171496..e2f9975 100755 --- a/bin/console +++ b/bin/console @@ -1,11 +1,12 @@ #!/usr/bin/env ruby -require "../lib/pastebinner" +require '../lib/pastebinner' +require '../lib/elastic_search_helper' # You can add fixtures and/or initialization code here to make experimenting # with your gem easier. You can also use a different console, if you like. # (If you use this, don't forget to add pry to your Gemfile!) -require "pry" -pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) +require 'pry' +pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) binding.pry diff --git a/bin/pastebinner b/bin/pastebinner index 4ba5b19..8524acd 100755 --- a/bin/pastebinner +++ b/bin/pastebinner @@ -4,19 +4,19 @@ require '../lib/pastebinner/option_parser' require 'pry' # setup our object and grab a session key -pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) +pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) # pass in the Pastebinner.new client. # will download all of the raw pastes from the public scrape results into each own file in data dir. def download_pastes(pb) pub_pastes = pb.scrape_public_pastes keys = pb.get_unique_paste_keys(pub_pastes) - data_dir = "../data/" - filename = "pastebin_paste_key" + data_dir = '../data/' + filename = 'pastebin_paste_key' binding.pry keys.map do |id| if File.exist?(data_dir + filename + "_#{id}") - puts "#{id} already exists on your filesystem, skipping..." + puts "#{id} already exists on your filesystem, skipping..." else File.write(data_dir + filename + "_#{id}", pb.raw_paste_data(id)) end @@ -27,7 +27,7 @@ options = OptionParser.parse! if options[:s] puts pb.scrape_public_pastes -elsif options[:r] and options[:k] +elsif options[:r] && options[:k] key = options[:k] puts pb.raw_paste_data(key) elsif options[:t] @@ -36,13 +36,13 @@ elsif options[:g] r = pb.scrape_public_pastes puts pb.get_unique_paste_keys(r) elsif options[:d] - puts "Downloading paste data into the data directory..." + puts 'Downloading paste data into the data directory...' download_pastes(pb) - puts "Complete." + puts 'Complete.' elsif options[:k] puts '-k or --key= requires -r,--raw' exit else options = false - puts 'please provide arguments' - exit + puts 'please provide arguments' + exit end diff --git a/lib/elastic_search_helper.rb b/lib/elastic_search_helper.rb index 343f823..b74b071 100644 --- a/lib/elastic_search_helper.rb +++ b/lib/elastic_search_helper.rb @@ -1,53 +1,33 @@ -require 'elasticsearch' - class ElasticSearchHelper - attr_accessor :server_uri, :index - - def initialize(server_uri, index) + attr_accessor :server_uri, :index, :pastebinner, :doctype + DEFAULT_METHOD = :post + + def initialize(server_uri, index, doctype='_doc') @server_uri = server_uri @index = index + @doctype = doctype + @pastebinner = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) end - # will build an array of 50 pastes to ship to es - def build_json_array(pb, keys) - json_for_es = keys.map do |k| - pb.encode_json(pb.raw_paste_data(k), pb.raw_paste_metadata(k)) - end - end - - def puts_to_es(payload, increment_num) - header = { 'Content-type': 'application/json' } + def create_index response = RestClient::Request.execute( method: :put, - url: "#{server_uri}/#{index}/#{index}s/#{increment_num}", - headers: header, - payload: payload) + url: "#{server_uri}/#{index}") end - def data_mappings - # metadata mappings - # send a PUT - { - "mappings": { - "_doc": { - "properties": { - "type": { "type": "keyword" }, - "paste_metadata": { "type": "nested" }, - "properties": { - "scrape_url": { "type": "string" }, - "full_url": { "type": "string" }, - "date": { "type": "string" }, - "size": { "type": "string" }, - "expire": { "type": "string" }, - "title": { "type": "string" }, - "syntax": { "type": "string" }, - "user": { "type": "string" }, - "hits": { "type": "string" } - } - "paste_text": { "type": "string" } - } - } - } - } + def json_to_es(paste_json, method=nil) + header = { 'Content-type': 'application/json' } + response = RestClient::Request.execute( + method: method ||= DEFAULT_METHOD, + url: "#{server_uri}/#{index}/#{doctype}", + headers: header, + payload: paste_json) end + + def json_to_es_bulk(array_of_paste_json) + array_of_paste_json.each do |paste_json| + self.to_es(paste_json) + end + end + end diff --git a/lib/examples/examples.rb b/lib/examples/examples.rb old mode 100644 new mode 100755 index 50cc827..7a6e63e --- a/lib/examples/examples.rb +++ b/lib/examples/examples.rb @@ -8,20 +8,20 @@ require '../pastebinner' #### INITIAL STEPS # setup our object and grab a session key -pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) +pb = Pastebinner.new(ENV['pastebin_api_key'], ENV['pastebin_username'], ENV['pastebin_password']) api_dev_key = ENV['pastebin_api_key'] #### CREATE PASTE # prepare some sample paste data to send paste_data = 'this is a test paste two two two.' # prepare our paste params -params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data } +params = { "api_dev_key": api_dev_key, "api_option": 'paste', "api_paste_code": paste_data } puts pb.create_paste(params) #### SCRAPE PUBLIC PASTES puts pb.scrape_public_pastes -#### SCRAPING - WHITELISTED IP ONLY +#### SCRAPING - WHITELISTED IP ONLY #### SCRAPE RAW PASTE DATA OF A PASTE KEY puts pb.raw_paste_data('Gkb4ukK9') diff --git a/lib/exceptions.rb b/lib/exceptions.rb index 74d3c51..9cb5050 100644 --- a/lib/exceptions.rb +++ b/lib/exceptions.rb @@ -1,16 +1,13 @@ -module PastebinnerError - +module PastebinnerError class ArgumentError < StandardError - def message - "Invalid argument" - end + def message + 'Invalid argument' + end end class ConfigError < StandardError - def message - "Invalid configuration" - end + def message + 'Invalid configuration' + end end - end - diff --git a/lib/pastebinner.rb b/lib/pastebinner.rb index e79da4f..96ee432 100755 --- a/lib/pastebinner.rb +++ b/lib/pastebinner.rb @@ -6,202 +6,189 @@ require 'rest-client' require 'json' class Pastebinner - attr_accessor :api_dev_key, :username, :password + attr_accessor :api_dev_key, :username, :password - def initialize(api_dev_key, username, password) - @api_dev_key = api_dev_key - @username = username - @password = password - @base_api_url = 'https://pastebin.com/api' - @scraping_api_url = 'https://scrape.pastebin.com' + def initialize(api_dev_key, username, password) + @api_dev_key = api_dev_key + @username = username + @password = password + @base_api_url = 'https://pastebin.com/api' + @scraping_api_url = 'https://scrape.pastebin.com' + end + + # this should be a hash of { endpoint_name: '/url_endpoint.php'} + ENDPOINTS = { login: '/api_login.php', + post: '/api_post.php', + raw: '/api_raw.php', + scraping: '/api_scraping.php', + scrape_item: '/api_scrape_item.php', + scrape_item_meta: '/api_scrape_item_meta.php' }.freeze + + # basic example hash for creating a paste: + # params = { 'api_dev_key': @api_dev_key, 'api_option': 'paste'. 'api_paste_code': paste_data} + + # required params: + # api_dev_key - your unique developer api key + # api_option - set as paste, this will indicate you want to create a new paste + # api_paste_code - this is the text that will be written inside of your paste + + # optional params: + # api_user_key - this parameter is part of the login system, which is explained further down the page + # api_paste_name - this will be the name / title of your paste + # api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page + # api_paste_private - this makes a paste public, unlisted, or private, public = 0, unlisted = 1, private = 2 + # api_paste_expire_date - this sets the expiration date of your paste, the values are explained further down the page + + # example - params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data } + def create_paste(params) + execute_query(:api_post, params) + end + + def api_user_key + # returns a user session key that can be used as the api_user_key param + @api_user_key ||= RestClient::Request.execute( + method: :post, + url: @base_api_url + ENDPOINTS[:login], + payload: { 'api_dev_key': @api_dev_key, + 'api_user_name': @username, + 'api_user_password': @password } + ) + end + + def list_user_pastes + params = { 'api_dev_key': api_dev_key, + 'api_user_key': api_user_key, + 'api_results_limit': '100', + 'api_option': 'list' } + execute_query(:api_post, params) + end + + def list_trending_pastes + params = { 'api_dev_key': api_dev_key, + 'api_option': 'trends' } + execute_query(:api_post, params) + end + + def list_raw_user_paste(api_paste_key) + params = { 'api_dev_key': api_dev_key, + 'api_user_key': api_user_key, + 'api_paste_key': api_paste_key, + 'api_option': 'show_paste' } + execute_query(:api_post, params) + end + + # api_paste_key = this is the unique key of the paste data you want to delete. + def delete_user_paste(api_paste_key) + params = { 'api_dev_key': api_dev_key, + 'api_user_key': api_user_key, + 'api_paste_key': api_paste_key, + 'api_option': 'delete' } + execute_query(:api_post, params) + end + + def get_user_info + params = { 'api_dev_key': api_dev_key } + end + + def api_post(params) + response = RestClient::Request.execute( + method: :post, + url: @base_api_url + ENDPOINTS[:post], + payload: params + ) + end + + # params is optional for now. to query specific language ?lang=ruby as an example + def scrape_public_pastes(_params = nil) + response = RestClient::Request.execute( + method: :get, + url: @scraping_api_url + ENDPOINTS[:scraping] + ) + end + + # will extract just the keys from recent public pastes + def get_unique_paste_keys(public_pastes) + pp = JSON.parse(public_pastes) + pp.map { |p| p['key'] } + end + + def raw_paste_data(unique_paste_key) + response = RestClient::Request.execute( + method: :get, + url: @scraping_api_url + ENDPOINTS[:scrape_item] + "?i=#{unique_paste_key}" + ) + end + + def raw_paste_metadata(unique_paste_key) + response = RestClient::Request.execute( + method: :get, + url: @scraping_api_url + ENDPOINTS[:scrape_item_meta] + "?i=#{unique_paste_key}" + ) + response + end + + ##### PREPARING THE PASTES FOR SERIALIZATION FOR ES CONFORMING TO PER INDEX SEARCHING + ##### SEE - https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_custom_type_field + + def hash_pastes(keys) + keys.map do |key| + raw_paste = self.raw_paste_data(key).body + raw_paste_metadata = self.raw_paste_metadata(key).body + hash = self.hash_paste(raw_paste, raw_paste_metadata) end + end - # this should be a hash of { endpoint_name: '/url_endpoint.php'} - ENDPOINTS = { :login => '/api_login.php', - :post => '/api_post.php', - :raw => '/api_raw.php', - :scraping => '/api_scraping.php', - :scrape_item => '/api_scrape_item.php', - :scrape_item_meta => '/api_scrape_item_meta.php' } - - # basic example hash for creating a paste: - # params = { 'api_dev_key': @api_dev_key, 'api_option': 'paste'. 'api_paste_code': paste_data} - - # required params: - # api_dev_key - your unique developer api key - # api_option - set as paste, this will indicate you want to create a new paste - # api_paste_code - this is the text that will be written inside of your paste - - # optional params: - # api_user_key - this parameter is part of the login system, which is explained further down the page - # api_paste_name - this will be the name / title of your paste - # api_paste_format - this will be the syntax highlighting value, which is explained in detail further down the page - # api_paste_private - this makes a paste public, unlisted, or private, public = 0, unlisted = 1, private = 2 - # api_paste_expire_date - this sets the expiration date of your paste, the values are explained further down the page - - # example - params = { "api_dev_key": api_dev_key, "api_option": "paste", "api_paste_code": paste_data } - def create_paste(params) - execute_query(:api_post, params) + def json_pastes(keys) + self.hash_pastes(keys).map do |paste_hash| + paste_hash.to_json end + end - def api_user_key - # returns a user session key that can be used as the api_user_key param - @api_user_key ||= RestClient::Request.execute({ - method: :post, - url: @base_api_url + ENDPOINTS[:login], - payload: { 'api_dev_key': @api_dev_key, - 'api_user_name': @username, - 'api_user_password': @password }}) - end + def hash_paste(raw_paste_data, raw_paste_metadata) + { "paste_metadata": raw_paste_metadata, + "paste_text": raw_paste_data } + end - def list_user_pastes - params = { 'api_dev_key': api_dev_key, - 'api_user_key': api_user_key, - 'api_results_limit': '100', - 'api_option': 'list' - } - execute_query(:api_post, params) - end + def json_paste(raw_paste_data, raw_paste_metadata) + self.hash_paste(raw_paste_data, raw_paste_metadata).to_json + end - def list_trending_pastes - params = { 'api_dev_key': api_dev_key, - 'api_option': 'trends' - } - execute_query(:api_post, params) - end - - def list_raw_user_paste(api_paste_key) - params = { 'api_dev_key': api_dev_key, - 'api_user_key': api_user_key, - 'api_paste_key': api_paste_key, - 'api_option': 'show_paste' - } - execute_query(:api_post, params) - end - - # api_paste_key = this is the unique key of the paste data you want to delete. - def delete_user_paste(api_paste_key) - params = { 'api_dev_key': api_dev_key, - 'api_user_key': api_user_key, - 'api_paste_key': api_paste_key, - 'api_option': 'delete' - } - execute_query(:api_post, params) - end - - def get_user_info - params = { 'api_dev_key': api_dev_key, - } - end - - def api_post(params) - response = RestClient::Request.execute( - method: :post, - url: @base_api_url + ENDPOINTS[:post], - payload: params) - end - - # params is optional for now. to query specific language ?lang=ruby as an example - def scrape_public_pastes(params = nil) - response = RestClient::Request.execute( - method: :get, - url: @scraping_api_url + ENDPOINTS[:scraping]) - end - - # will extract just the keys from recent public pastes - def get_unique_paste_keys(public_pastes) - pp = JSON.parse(public_pastes) - pp.map {|p| p['key']} - end - - def raw_paste_data(unique_paste_key) - response = RestClient::Request.execute( - method: :get, - url: @scraping_api_url + ENDPOINTS[:scrape_item] + "?i=#{unique_paste_key}") - end - - def raw_paste_metadata(unique_paste_key) - response = RestClient::Request.execute( - method: :get, - url: @scraping_api_url + ENDPOINTS[:scrape_item_meta] + "?i=#{unique_paste_key}") - response - end - - ##### PREPARING THE PASTES FOR SERIALIZATION FOR ES CONFORMING TO PER INDEX SEARCHING - ##### SEE - https://www.elastic.co/guide/en/elasticsearch/reference/current/removal-of-types.html#_custom_type_field - - def http_to_es(es_uri, payload, method) - header = { 'Content-type': 'application/json' } - response = RestClient::Request.execute( - method: method, - url: es_uri, - headers: header, - payload: payload) - end - - def create_index_es(es_uri, index) - response = RestClient::Request.execute( - method: :put, - url: es_uri + index) - end - - def hash_pastes(keys) - keys.map do |key| - raw_paste = self.raw_paste_data(key).body - raw_paste_metadata = self.raw_paste_metadata(key).body - hash = self.hash_paste(raw_paste, raw_paste_metadata) - end - end - - def hash_paste(raw_paste_data, raw_paste_metadata) - { "paste_metadata": raw_paste_metadata, - "paste_text": raw_paste_data } - end - - def send_es_bulk(esi_uri, json_data) - method = :post - json_data.each do |payload| - self.http_to_es(esi_uri, payload, method) - end - end - - def data_mappings + def data_mappings # metadata mappings # send a PUT - { - "mappings": { - "_doc": { - "properties": { - "type": { "type": "keyword" }, - "paste_metadata": { "type": "nested" }, - "properties": [ { - "scrape_url": { "type": "string" }, - "full_url": { "type": "string" }, - "date": { "type": "string" }, - "size": { "type": "string" }, - "expire": { "type": "string" }, - "title": { "type": "string" }, - "syntax": { "type": "string" }, - "user": { "type": "string" }, - "hits": { "type": "string" } - } ], - "paste_text": { "type": "string" } - } + { + "mappings": { + "_doc": { + "properties": { + "type": { "type": 'keyword' }, + "paste_metadata": { "type": 'nested' }, + "properties": [{ + "scrape_url": { "type": 'string' }, + "full_url": { "type": 'string' }, + "date": { "type": 'string' }, + "size": { "type": 'string' }, + "expire": { "type": 'string' }, + "title": { "type": 'string' }, + "syntax": { "type": 'string' }, + "user": { "type": 'string' }, + "hits": { "type": 'string' } + }], + "paste_text": { "type": 'string' } } } } - end + } + end - # keep this method private so we are not letting anyone run any method in our program - private - # this will be the main way to execute any of these methods. this has the exception handling taken care of. - def execute_query(selector, *args) - begin - send(selector, *args) - rescue RestClient::ExceptionWithResponse => e - puts e.message - end - end - # make my own exception class - # inherit ruby standard error class + # keep this method private so we are not letting anyone run any method in our program + private + + # this will be the main way to execute any of these methods. this has the exception handling taken care of. + def execute_query(selector, *args) + send(selector, *args) + rescue RestClient::ExceptionWithResponse => e + puts e.message + end + # make my own exception class + # inherit ruby standard error class end diff --git a/lib/pastebinner/exceptions.rb b/lib/pastebinner/exceptions.rb index 53c2ede..bdc50bb 100644 --- a/lib/pastebinner/exceptions.rb +++ b/lib/pastebinner/exceptions.rb @@ -1,9 +1,5 @@ class PastebinnerError < StandardError - - def InvalidArgument - end - - def ConfigError - end + def InvalidArgument; end + def ConfigError; end end diff --git a/lib/pastebinner/option_parser.rb b/lib/pastebinner/option_parser.rb index 2974fd5..ab3c741 100644 --- a/lib/pastebinner/option_parser.rb +++ b/lib/pastebinner/option_parser.rb @@ -6,22 +6,22 @@ class OptionParser OptParse.new do |opts| opts.default_argv = argv - opts.banner = "Usage: pastebinner [options]" + opts.banner = 'Usage: pastebinner [options]' - opts.on('-h', '--help', 'Show this help messae') do || + opts.on('-h', '--help', 'Show this help messae') do puts opts exit end - opts.on('-s', '--scrape_public', 'Scrape public pastes') do |s| + opts.on('-s', '--scrape_public', 'Scrape public pastes') do |_s| options[:s] = true end - opts.on('-r', '--raw', 'Raw paste. Requires --key passed with a valid key') do |r| + opts.on('-r', '--raw', 'Raw paste. Requires --key passed with a valid key') do |_r| options[:r] = true end - opts.on('-g', '--get_keys', 'Get unique paste keys from public pastes') do |g| + opts.on('-g', '--get_keys', 'Get unique paste keys from public pastes') do |_g| options[:g] = true end @@ -29,11 +29,11 @@ class OptionParser options[:k] = k end - opts.on('-d', '--download', 'Download all public pastes to data directory') do |d| + opts.on('-d', '--download', 'Download all public pastes to data directory') do |_d| options[:d] = true end - opts.on('-t', '--trending', 'Trending pastes') do |t| + opts.on('-t', '--trending', 'Trending pastes') do |_t| options[:t] = true end opts.parse! diff --git a/lib/pastebinner/version.rb b/lib/pastebinner/version.rb index 3849134..322decb 100644 --- a/lib/pastebinner/version.rb +++ b/lib/pastebinner/version.rb @@ -1,3 +1,3 @@ module Pastebinner - VERSION = "0.1.0" + VERSION = '0.1.0'.freeze end diff --git a/pastebinner.gemspec b/pastebinner.gemspec index 43bfa05..26c129a 100644 --- a/pastebinner.gemspec +++ b/pastebinner.gemspec @@ -1,40 +1,39 @@ -lib = File.expand_path("../lib", __FILE__) +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) -require "pastebinner/version" +require 'pastebinner/version' Gem::Specification.new do |spec| - spec.name = "pastebinner" + spec.name = 'pastebinner' spec.version = Pastebinner::VERSION - spec.authors = ["Brendan McDevitt"] - spec.email = ["brendan@mcdevitt.tech"] + spec.authors = ['Brendan McDevitt'] + spec.email = ['brendan@mcdevitt.tech'] - spec.summary = "A ruby client library for interacting with the pastebin API." - spec.homepage = "https://git.mcdevitt.tech/bpmcdevitt/pastebinner" + spec.summary = 'A ruby client library for interacting with the pastebin API.' + spec.homepage = 'https://git.mcdevitt.tech/bpmcdevitt/pastebinner' # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host' # to allow pushing to a single host or delete this section to allow pushing to any host. if spec.respond_to?(:metadata) - spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'" + spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'" else - raise "RubyGems 2.0 or newer is required to protect against " \ - "public gem pushes." + raise 'RubyGems 2.0 or newer is required to protect against ' \ + 'public gem pushes.' end # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end - spec.bindir = "bin" + spec.bindir = 'bin' spec.executables = ['pastebinner'] - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler", "~> 2.0" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_runtime_dependency "rest-client", "~> 2.0" - spec.add_runtime_dependency "json", "~> 2.0" - spec.add_runtime_dependency "pry", "~> 0.11" + spec.add_development_dependency 'bundler', '~> 2.0' + spec.add_development_dependency 'rake', '~> 10.0' + spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_runtime_dependency 'json', '~> 2.0' + spec.add_runtime_dependency 'pry', '~> 0.11' + spec.add_runtime_dependency 'rest-client', '~> 2.0' end - diff --git a/spec/pastebinner_spec.rb b/spec/pastebinner_spec.rb index 7e30863..5fe36c0 100644 --- a/spec/pastebinner_spec.rb +++ b/spec/pastebinner_spec.rb @@ -1,9 +1,9 @@ RSpec.describe Pastebinner do - it "has a version number" do + it 'has a version number' do expect(Pastebinner::VERSION).not_to be nil end - it "does something useful" do + it 'does something useful' do expect(false).to eq(true) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d409a8f..24e64b9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,9 @@ -require "bundler/setup" -require "pastebinner" +require 'bundler/setup' +require 'pastebinner' RSpec.configure do |config| # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" + config.example_status_persistence_file_path = '.rspec_status' # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching!