picturama 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- picturama (0.0.2)
4
+ picturama (0.0.3)
5
5
  mini_magick (~> 3.6.0)
6
6
  stringex (~> 2.0.2)
7
7
 
@@ -7,6 +7,7 @@ module Picturama
7
7
  @folder = args[:folder]
8
8
  @thumbnails = "#{args[:folder]}/thumbnails"
9
9
  @resized = "#{args[:folder]}/resized"
10
+ @info = "#{args[:folder]}/.info.yml"
10
11
  end
11
12
 
12
13
  def pictures(order = true)
@@ -29,11 +30,19 @@ module Picturama
29
30
  end
30
31
 
31
32
  def name
33
+ if info.nil?
34
+ name!
35
+ else
36
+ info['album']['title']
37
+ end
38
+ end
39
+
40
+ def name!
32
41
  folder.humanize
33
42
  end
34
43
 
35
44
  def slug
36
- name.to_url
45
+ name!.to_url
37
46
  end
38
47
 
39
48
  def count_pictures
@@ -65,6 +74,12 @@ module Picturama
65
74
  end
66
75
  end
67
76
 
77
+ def info
78
+ if File.exists?(@info)
79
+ YAML.load_file(@info)
80
+ end
81
+ end
82
+
68
83
  protected
69
84
 
70
85
  def generate_sorting(filter)
@@ -1,3 +1,3 @@
1
1
  module Picturama
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/rakefile CHANGED
@@ -54,4 +54,48 @@ namespace :url do
54
54
  end
55
55
  end
56
56
 
57
+ namespace :album do
58
+ desc "metadata handling for a given album"
59
+ namespace :metadata do
60
+ desc "generate metadata for an album in a given path"
61
+ task :generate do
62
+ puts ""
63
+ print "Type the album path: "
64
+ path = STDIN.gets.chomp
65
+ if File.directory?(path)
66
+ puts "Title:"
67
+ title = STDIN.gets.chomp
68
+ unless title.nil?
69
+ puts "Description (optional):"
70
+ description = STDIN.gets.chomp
71
+ puts "Author (optional):"
72
+ author = STDIN.gets.chomp
73
+ info = {"album" => {"title" => title, "description" => description, "author" => author}}
74
+ File.open("#{path}/.info.yml", 'w+') {|f| f.write(info.to_yaml) }
75
+ else
76
+ puts "Title cannot be empty. Run the task again"
77
+ end
78
+ else
79
+ puts "Sorry but #{path.inspect} entered is not a folder. Run the task again"
80
+ end
81
+ end
82
+
83
+ desc "retrieve metadata an album based on path"
84
+ task :check do
85
+ puts ""
86
+ print "Type the album path: "
87
+ path = STDIN.gets.chomp
88
+ info_file = "#{path}/.info.yml"
89
+ if File.directory?(path) && File.exists?(info_file)
90
+ data = YAML.load_file(info_file)['album']
91
+ puts "Title: #{data['title']}"
92
+ puts "Description: #{data['description']}"
93
+ puts "Author: #{data['author']}"
94
+ else
95
+ puts "Sorry but #{path.inspect} entered is not a folder. Run the task again"
96
+ end
97
+ end
98
+ end
99
+ end
100
+
57
101
  task :default
@@ -33,10 +33,15 @@ describe "For a given folder" do
33
33
  it "verifies the album name is correct based on folder name" do
34
34
  expected_album_name = "dummy album"
35
35
  expected_album_folder = "dummy-album"
36
- Picturama::albums(@target_exists_folder).first.name.should == expected_album_name
36
+ Picturama::albums(@target_exists_folder).first.name!.should == expected_album_name
37
37
  Picturama::albums(@target_exists_folder).first.folder.should == expected_album_folder
38
38
  Picturama::albums(@target_exists_folder).first.slug.should == expected_album_folder
39
39
  end
40
40
 
41
+ it "checks the album info from the .info.yml file" do
42
+ album_title_expected = 'some pictures here'
43
+ @album.info['album']['name'].should == album_title_expected
44
+ end
45
+
41
46
 
42
47
  end
@@ -0,0 +1,4 @@
1
+ album:
2
+ name: some pictures here
3
+ description: in this album there are some pictures
4
+ autor: David Silveira
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picturama
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-08 00:00:00.000000000 Z
12
+ date: 2013-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick
@@ -84,6 +84,7 @@ files:
84
84
  - rakefile
85
85
  - spec/album_spec.rb
86
86
  - spec/picture_spec.rb
87
+ - spec/pictures/.info.yml
87
88
  - spec/pictures/king.jpg
88
89
  - spec/pictures/quimby.gif
89
90
  - spec/pictures/vote-quimby.jpg
@@ -103,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
104
  version: '0'
104
105
  segments:
105
106
  - 0
106
- hash: -698139313
107
+ hash: 760458003
107
108
  required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  none: false
109
110
  requirements:
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  segments:
114
115
  - 0
115
- hash: -698139313
116
+ hash: 760458003
116
117
  requirements: []
117
118
  rubyforge_project:
118
119
  rubygems_version: 1.8.24