Skip to content

Commit

Permalink
Moving the monkey patch stuff into its own gem.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgore committed Apr 9, 2013
1 parent c521e1b commit ed8215a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 43 deletions.
5 changes: 3 additions & 2 deletions btce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@

Gem::Specification.new do |s|
s.name = 'btce'
s.version = '0.0.2'
s.date = '2013-04-08'
s.version = '0.1.0'
s.date = '2013-04-09'
s.summary = "A simple library to interface with the API for btc-e.com in Ruby."
s.description = "A simple library to interface with the API for btc-e.com in Ruby."
s.authors = ['Christopher Mark Gore']
s.email = '[email protected]'
s.files = ['lib/btce.rb']
s.homepage = 'https://github.com/cgore/ruby-btce'
s.add_dependency 'monkey-patch'
end
Binary file added gem-builds/btce-0.1.0.gem
Binary file not shown.
18 changes: 1 addition & 17 deletions lib/btce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,13 @@
# POSSIBILITY OF SUCH DAMAGE.

require 'json'
require 'monkey-patch'
require 'net/http'
require 'net/https'
require 'openssl'
require 'uri'
require 'yaml'

class String
def camelcase_to_snakecase
self.gsub(/::/, '/')
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
.tr("-", "_")
.downcase
end

def valid_json?
JSON.parse self
return true
rescue JSON::ParserError
return false
end
end

module Btce
class API
BTCE_DOMAIN = "btc-e.com"
Expand Down
24 changes: 0 additions & 24 deletions spec/btce_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,6 @@
require 'btce'
include Btce

describe String do
describe :camelcase_to_snakecase do
it "correctly handles capitalization at the front" do
"Test".camelcase_to_snakecase
.should == "test"
end

it "correctly handles capitalization in the middle" do
"thisIsATest".camelcase_to_snakecase
.should == "this_is_a_test"
end
end

describe :valid_json? do
it "returns true if it is valid json" do
"[1,2,3]".should be_valid_json
end

it "returns false if it is invalid json" do
"blarg".should_not be_valid_json
end
end
end

describe API do
describe :KEY do
it "contains the key entry" do
Expand Down

0 comments on commit ed8215a

Please sign in to comment.