sga_paperclippolymorph 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -1,6 +1,9 @@
1
1
  module LocusFocus
2
+
2
3
  module Acts #:nodoc: all
4
+
3
5
  module PolymorphicPaperclip
6
+
4
7
  def self.included(base)
5
8
  base.extend ClassMethods
6
9
  end
@@ -59,9 +62,32 @@ module LocusFocus
59
62
  attr_accessor :data
60
63
 
61
64
  include LocusFocus::Acts::PolymorphicPaperclip::InstanceMethods
65
+
66
+ include LocusFocus::Acts::PolymorphicPaperclip::ExtentionMethods if options[:with_extention]
67
+
68
+ end
69
+
70
+ end
71
+
72
+ module ExtentionMethods
73
+
74
+ require 'fileutils'
75
+
76
+ def after_save
77
+ super
78
+ FileUtils.cp assets[0].path, asset_path(true)
79
+ end
80
+
81
+ def asset_path create_dir=false
82
+ assets_dir = File.join RAILS_ROOT, 'public', 'system', 'assets'
83
+ (FileUtils.mkdir_p assets_dir unless File.exists?(assets_dir)) if create_dir
84
+ File.join assets_dir, "#{self.wid}.sgf"
62
85
  end
86
+
63
87
  end
88
+
64
89
  module InstanceMethods
90
+
65
91
  def after_save
66
92
  super
67
93
  Asset.transaction do
@@ -90,6 +116,7 @@ module LocusFocus
90
116
  assets(true) # implicit reloading
91
117
  end
92
118
  end
119
+
93
120
  def override_default_styles?(filename)
94
121
  if !acts_as_polymorphic_paperclip_options[:styles].nil?
95
122
  normalised_styles = {}
@@ -107,7 +134,11 @@ module LocusFocus
107
134
  return false
108
135
  end
109
136
  end
137
+
110
138
  end
139
+
111
140
  end
141
+
112
142
  end
113
- end
143
+
144
+ end
data/lib/sga/asset.rb CHANGED
@@ -56,7 +56,6 @@ class Asset < ActiveRecord::Base
56
56
  end
57
57
 
58
58
  def file_md5sum
59
- #path = File.join RAILS_ROOT, 'public', self.url_without_random
60
59
  IO.popen("md5sum #{path} | awk '{print $1}'"){|f| f.gets.strip}
61
60
  end
62
61
 
@@ -0,0 +1,60 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{sga_paperclippolymorph}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["tim.teng"]
12
+ s.date = %q{2010-05-31}
13
+ s.description = %q{gem version of paperclippolymorph for sga company}
14
+ s.email = %q{tim.rubist@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "generators/polymorphic_paperclip/USAGE",
27
+ "generators/polymorphic_paperclip/polymorphic_paperclip_generator.rb",
28
+ "generators/polymorphic_paperclip/templates/migration.rb",
29
+ "lib/sga/acts_as_polymorphic_paperclip.rb",
30
+ "lib/sga/asset.rb",
31
+ "lib/sga/attaching.rb",
32
+ "lib/sga_paperclippolymorph.rb",
33
+ "sga_paperclippolymorph.gemspec",
34
+ "test/helper.rb",
35
+ "test/test_sga_paperclippolymorph.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/tteng/sga_paperclippolymorph}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.3.6}
41
+ s.summary = %q{gem version of paperclippolymorph for sga company}
42
+ s.test_files = [
43
+ "test/test_sga_paperclippolymorph.rb",
44
+ "test/helper.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
+ s.specification_version = 3
50
+
51
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
52
+ s.add_runtime_dependency(%q<paperclip>, [">= 2.3.1.1"])
53
+ else
54
+ s.add_dependency(%q<paperclip>, [">= 2.3.1.1"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<paperclip>, [">= 2.3.1.1"])
58
+ end
59
+ end
60
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - tim.teng
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-07 00:00:00 +08:00
17
+ date: 2010-05-31 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ files:
55
55
  - lib/sga/asset.rb
56
56
  - lib/sga/attaching.rb
57
57
  - lib/sga_paperclippolymorph.rb
58
+ - sga_paperclippolymorph.gemspec
58
59
  - test/helper.rb
59
60
  - test/test_sga_paperclippolymorph.rb
60
61
  has_rdoc: true