Class: Datapimp::Sources::Pivotal

Inherits:
Base
  • Object
show all
Defined in:
lib/datapimp/sources/pivotal.rb

Instance Attribute Summary

Attributes inherited from Base

#format, #name, #options, #path, #processed, #raw, #refreshed_at, #scopes, #slug_column

Instance Method Summary collapse

Methods inherited from Base

#age, #compute_properties, #data, #ensure_valid_options!, #fetch, #file, #fresh_on_server?, #has_scope?, #jsonify, #max_age, #need_to_refresh?, #path_to_file, #persisted?, #preprocess, #process, #processors, #refresh, #refresh!, #refresh_if_stale?, requires, #save_to_disk, #scope, #select, #stale?

Constructor Details

#initialize(args, options) ⇒ Pivotal

Returns a new instance of Pivotal.



3
4
5
6
7
8
9
10
# File 'lib/datapimp/sources/pivotal.rb', line 3

def initialize(args, options)
  @project_id = args.shift
  @story_id   = args.shift
  @options    = options.to_mash

  require 'pivotal-tracker' unless defined?(PivotalTracker)
  PivotalTracker::Client.token = Datapimp.config.pivotal_access_token
end

Instance Method Details

#allObject



12
13
14
15
16
# File 'lib/datapimp/sources/pivotal.rb', line 12

def all
  %w(user_activity project_activity project_stories).each_with_object({}) do |slice, memo|
    memo[slice] = send(slice)
  end
end

#project_activityObject



26
27
28
# File 'lib/datapimp/sources/pivotal.rb', line 26

def project_activity
  project.activities.all(limit_params).map {|a| jsonify(a) }
end

#project_storiesObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/datapimp/sources/pivotal.rb', line 30

def project_stories
  stories = project.stories.all(limit_params)

  # add notes for each story and convert the objects to hashes
  stories.map do |story|
    story_hash = jsonify(story)
    story_hash[:notes] = story.notes.all(limit_params).map {|a| jsonify(a) }
    story_hash
  end
end

#project_story_notesObject



41
42
43
44
# File 'lib/datapimp/sources/pivotal.rb', line 41

def project_story_notes
  notes = project.stories.find(@story_id).notes.all(limit_params)
  notes.map {|a| jsonify(a) }
end

#to_sObject



18
19
20
# File 'lib/datapimp/sources/pivotal.rb', line 18

def to_s
  all
end

#user_activityObject



22
23
24
# File 'lib/datapimp/sources/pivotal.rb', line 22

def user_activity
  @_user_activity ||= PivotalTracker::Activity.all(nil, limit_params).map {|a| jsonify(a) }
end