Skip to content

Commit

Permalink
Merge 8be0970 into f5e1a09
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Pikesley committed Jan 24, 2016
2 parents f5e1a09 + 8be0970 commit 31f7d2d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 2 deletions.
24 changes: 23 additions & 1 deletion lib/funkdata/fetcher.rb
Expand Up @@ -80,9 +80,31 @@ def self.method_missing method_name
end
end

thing
cleaned_thing = []
thing.each do |t|
clean = {}
field_orderer(t.keys).each do |k|
clean[k] = t[k] if t[k]
end
cleaned_thing.push clean
end

cleaned_thing
end
end

def self.field_orderer fields
fields.delete 'id'
prime_fields = [
'title',
'date',
'url',
'license'
]

remainder = fields - prime_fields
prime_fields + remainder
end
end
end

Expand Down
46 changes: 46 additions & 0 deletions spec/funkdata/cleaned_data_spec.rb
@@ -0,0 +1,46 @@
module Funkdata
describe Fetcher do
it 'presents the data in a consistent order', :vcr do
expect(described_class.get_pictures[3]).to eq (
{
'title' => 'Raw Funk Maharishi',
'date' => '2015-02-18',
'url' => 'https://www.flickr.com/photos/cluttercup/16393865760/',
'license' => {
'type' => 'Attribution-NonCommercial',
'url' => 'https://creativecommons.org/licenses/by-nc/2.0/'
},
'photographer' => {
'name' => 'jane',
'website' => 'https://www.flickr.com/photos/cluttercup'
}
}
)

expect(described_class.get_sounds[0]).to eq (
{
'title' => 'Slinky',
'date' => '2015-11-25',
'url' => 'http://soundcloud.com/rawfunkmaharishi/slinky-2',
'license' => {
'type' => 'Attribution-NonCommercial-ShareAlike',
'url' => 'http://creativecommons.org/licenses/by-nc-sa/4.0/'
},
'location' => 'Rogue Studios',
'engineer' => 'Alessio'
}
)

expect(described_class.get_videos[0]).to eq (
{
'title' => 'Vilamendhoo 2015',
'url' => 'https://vimeo.com/141292006',
'license' => {
'type' => 'Attribution-NonCommercial-ShareAlike',
'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/'
}
}
)
end
end
end
2 changes: 1 addition & 1 deletion spec/funkdata/videos_data_spec.rb
Expand Up @@ -3,7 +3,7 @@ module Funkdata
context 'video data' do
it 'lists the videos', :vcr do
expect(described_class.get_videos).to be_an Array
expect(described_class.get_videos.first['id']).to eq 141292006
expect(described_class.get_videos.first['url']).to eq 'https://vimeo.com/141292006'
end
end
end
Expand Down

0 comments on commit 31f7d2d

Please sign in to comment.