Class: Ringo::Mingle

Inherits:
Object
  • Object
show all
Defined in:
lib/ringo/mingle.rb

Class Method Summary collapse

Class Method Details

.baseObject



50
51
52
# File 'lib/ringo/mingle.rb', line 50

def base
  "https://#{host}/api/v2/projects/#{project}".to_uri(username: user, password: password)
end

.configObject



9
10
11
# File 'lib/ringo/mingle.rb', line 9

def config
  @@config ||= YAML.load File.open('config/mingle.yml')
end

.get(url, params = {}) ⇒ Object



54
55
56
# File 'lib/ringo/mingle.rb', line 54

def get url, params={}
  Nokogiri::XML base[url].get(params).body
end

.hostObject



25
26
27
# File 'lib/ringo/mingle.rb', line 25

def host
  config['host']
end

.passwordObject



17
18
19
# File 'lib/ringo/mingle.rb', line 17

def password
  config['password']
end

.projectObject



21
22
23
# File 'lib/ringo/mingle.rb', line 21

def project
  config['project']
end

.storiesObject



29
30
31
32
# File 'lib/ringo/mingle.rb', line 29

def stories
  filter = {'view' => 'Story Wall'}
  Ringo::StoryCard.from_result get 'cards.xml', filter
end

.story(number) ⇒ Object



34
35
36
# File 'lib/ringo/mingle.rb', line 34

def story number
  Ringo::StoryCard.from_card get "cards/#{number}.xml"
end

.userObject



13
14
15
# File 'lib/ringo/mingle.rb', line 13

def user
  config['user']
end

.wallObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ringo/mingle.rb', line 38

def wall
  result = {}

  stories.each do |story|
    next unless STATUSES.include? story.status
    result[story.status] ||= []
    result[story.status] << story
  end

  result
end