Skip to content

Commit

Permalink
Moving Version::Checker class into it's own file. Less intrusive
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Bridges committed Aug 13, 2012
1 parent dba7e63 commit d14b333
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
1 change: 1 addition & 0 deletions lib/dotify/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

require 'dotify'
require 'dotify/cli/listing'
require 'dotify/version/checker'

module Dotify
module CLI
Expand Down
27 changes: 0 additions & 27 deletions lib/dotify/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,5 @@ def latest
Checker.latest
end

# The Checkup class is responsible for
# reaching out to Rubygems.org and retrieving
# the latest gem version.
class Checker

class << self
attr_reader :result, :resp
end

def self.check_latest_release!
@result = latest == Version.build.level
end

def self.latest
fetch.map { |v| v['number'] }.max
end

private

def self.fetch
require 'multi_json'
@resp = Net::HTTP.get('rubygems.org', '/api/v1/versions/dotify.json')
MultiJson.load(@resp)
end

end
end

end
30 changes: 30 additions & 0 deletions lib/dotify/version/checker.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Dotify
class Version
# The Checkup class is responsible for
# reaching out to Rubygems.org and retrieving
# the latest gem version.
class Checker

class << self
attr_reader :result, :resp
end

def self.check_latest_release!
@result = latest == Version.build.level
end

def self.latest
fetch.map { |v| v['number'] }.max
end

private

def self.fetch
require 'multi_json'
@resp = Net::HTTP.get('rubygems.org', '/api/v1/versions/dotify.json')
MultiJson.load(@resp)
end

end
end
end

0 comments on commit d14b333

Please sign in to comment.