lib/changelog.rb in overview-0.0.5.pre.22 vs lib/changelog.rb in overview-0.0.6.pre.24

- old
+ new

@@ -1,8 +1,8 @@ module Changelog - require 'httparty' + require 'typhoeus' require 'json' require 'octokit' require 'formatador' require 'pp' require 'yaml' @@ -13,11 +13,11 @@ require 'api_cache' require 'moneta' require 'faraday-http-cache' =begin TODO: - +*** This is now completed broken **** More than I can comprehend... Keep all incoming data in original format, so that it can be reproccessed. e.g. Make calls. Store Data. Retrieve data. Process data. Display data. Deploy. Mark sprint.ly items as deployed if complete. This will eventually be in a separate script. Sprint.ly status Compelete refactor into a modern ruby CLI app. @@ -31,13 +31,11 @@ class Base def initialize @logger = Logging.logger[self] @logger.add_appenders \ Logging.appenders.stdout, - Logging.appenders.file('overview.log') - @logger.level = :info - + Logging.appenders.file("#{self.class.name}.log") APICache.store = Moneta.new(:YAML, :file => "#{self.class.name}_cache") APICache.logger.level = Logger::DEBUG #Caching for octokit #store = Moneta.new(:YAML, :file => 'changelog_octokit.cache') @@ -97,85 +95,12 @@ def display end end - class Item - def initialize(title, id, description, sha, date, source, type=nil, status=nil, author=nil, environments=nil) - type ||="NA" - status ||="UNKNOWN" - author ||="UNKNOWN" - environments ||= [] - @title = title.delete("\n") - @description = description - @sha = sha - @date = date - @id = id - @source = source - @type = type - @status = status - @author = author - @environments = environments - end - def inspect - "<#{@source} #{@type.upcase} ##{@id} : #{self.status} : #{@title}>" - end - def title - return @title - end - - def date - return @date - end - - def type - return @type - end - - def author - return @author - end - - def environments - return @environments.any? ? @environments : nil - end - - def sha - return @sha - end - - def id - return @id - end - - def status - return @status.nil? ? "NA" : @status.upcase - end - - def source - return @source - end - - def sprintly? - return self.source.upcase == "SPRINT.LY" - end - - def complete? - return %w(COMPLETED ACCEPTED).include?(self.status) - end - - def built? - return self.environments.join.scan(/#(\d+)/).any? unless self.environments.nil? - end - - def released? - return self.environments.join.scan(/v(\d+)/).any? unless self.environments.nil? - end - end - class Log < Base def githubReleaseStatus(release=nil) case when release.nil? status = "NA" @@ -281,26 +206,26 @@ return sprintlyIds, crashlyticsIds end def crashlyticsItem(title, id, sha, date, author) #puts " " + item["type"].capitalize + " " + item["number"].to_s + ": " + item["title"] - return Item.new(title, id, "NA", sha, date, "Crashlytics", "crash", nil, author) + return SprintlyItem.new(title, id, "NA", sha, date, "Crashlytics", "crash", nil, author) end #TODO - consider returning sprint.ly story rather than task #TODO - cache raw response, not item def sprintlyItem(id, sha, date, author) url = "https://sprint.ly/api/products/" + @product_id + "/items/" + id + ".json" APICache.get(url, :timeout => 30, :fail => []) do response = HTTParty.get(url, :basic_auth => @auth) item = JSON.parse(response.body) - Item.new(item["title"], item["number"], item["description"], sha, date, "Sprint.ly", item["type"], item["status"], author, item["deployed_to"]) + SprintlyItem.new(item["title"], item["number"], item["description"], sha, date, "Sprint.ly", item["type"], item["status"], author, item["deployed_to"]) end end def commitItem(commit) APICache.get(commit.sha, :fail => []) do - Item.new(commit.commit.message.lines.first, commit.sha[0..6], commit.commit.message, commit.sha, commit.commit.author.date, "Github", "commit", "NA", commit.commit.author.name) + SprintlyItem.new(commit.commit.message.lines.first, commit.sha[0..6], commit.commit.message, commit.sha, commit.commit.author.date, "Github", "commit", "NA", commit.commit.author.name) end end \ No newline at end of file