esp-commons 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,27 +1,36 @@
1
- class EspCommons::Image < APISmith::Smash
2
- property :url
3
- property :description
4
- property :thumbnail
1
+ require 'active_attr'
5
2
 
6
- property :vfs_url
7
- property :id, :transformer => :to_i
8
- property :width, :transformer => :to_i
9
- property :height, :transformer => :to_i
10
- property :filename
3
+ class EspCommons::Image
4
+ include ActiveAttr::Attributes
5
+ include ActiveAttr::MassAssignment
6
+ include ActiveAttr::QueryAttributes
7
+ include ActiveAttr::TypecastedAttributes
8
+
9
+ attribute :url
10
+ attribute :description
11
+ attribute :thumbnail
12
+
13
+ attribute :vfs_url
14
+ attribute :id, :type => Integer
15
+ attribute :width, :type => Integer
16
+ attribute :height, :type => Integer
17
+ attribute :crop, :type => Boolean
18
+ attribute :filename
11
19
 
12
20
 
13
21
  attr_writer :aspect_ratio
14
22
 
15
23
  def parse_url
16
24
  self.tap do | image |
17
- image.vfs_url, image.id, image.width, image.height, image.filename = url.match(%r{(.*)/files/(\d+)/(?:(\d+)-(\d+)/)?(.*)})[1..-1]
25
+ image.vfs_url, image.id, image.width, image.height, image.crop, image.filename =
26
+ url.match(%r{(.*)/files/(\d+)/(?:(\d+)-(\d+)(\!)?/)?(.*)})[1..-1]
18
27
  end
19
28
  end
20
29
 
21
30
  def build_url
22
31
  self.tap do | image |
23
32
  if image?
24
- image.url = "#{vfs_url}/files/#{image.id}/#{image.width}-#{image.height}/#{image.filename}"
33
+ image.url = "#{vfs_url}/files/#{image.id}/#{image.width}-#{image.height}#{image.crop ? '!' : ''}/#{image.filename}"
25
34
  else
26
35
  image.url = "#{vfs_url}/files/#{image.id}/#{image.filename}"
27
36
  end
@@ -29,15 +38,7 @@ class EspCommons::Image < APISmith::Smash
29
38
  end
30
39
 
31
40
  def image?
32
- width && height
33
- end
34
-
35
- def width?
36
- width && width > 0
37
- end
38
-
39
- def height?
40
- height && height > 0
41
+ width? && height?
41
42
  end
42
43
 
43
44
  def aspect_ratio
@@ -52,10 +53,12 @@ class EspCommons::Image < APISmith::Smash
52
53
  self.width = new_width
53
54
  else
54
55
  self.width = self.height = 100 if !width? && !height?
55
- if height >= new_height
56
- self.height = new_height
57
- else
58
- self.width = new_width
56
+ unless crop
57
+ if height >= new_height
58
+ self.height = new_height
59
+ else
60
+ self.width = new_width
61
+ end
59
62
  end
60
63
  end
61
64
  self
@@ -1,6 +1,5 @@
1
1
  require 'airbrake'
2
2
  require 'configliere'
3
- require 'api_smith'
4
3
 
5
4
  module EspCommons
6
5
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module EspCommons
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -2,10 +2,14 @@
2
2
 
3
3
  PROJECT=$(basename $(dirname $(dirname $(realpath $0))))
4
4
 
5
- git checkout
5
+ git checkout Gemfile.lock
6
6
  git pull
7
7
  bundle --path .bundle --binstubs --clean
8
8
  bin/rake db:migrate
9
9
  if [ -f /usr/local/etc/rc.d/esp-${PROJECT} ]; then
10
10
  /usr/local/etc/rc.d/esp-${PROJECT} restart
11
11
  fi
12
+ bin/rake assets:precompile
13
+ if [ -f /usr/local/etc/rc.d/esp-${PROJECT} ]; then
14
+ /usr/local/etc/rc.d/esp-${PROJECT} restart
15
+ fi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esp-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-11 00:00:00.000000000 Z
12
+ date: 2012-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: airbrake
16
- requirement: &20883040 !ruby/object:Gem::Requirement
16
+ requirement: &6507580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20883040
24
+ version_requirements: *6507580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: configliere
27
- requirement: &20880880 !ruby/object:Gem::Requirement
27
+ requirement: &6506780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20880880
35
+ version_requirements: *6506780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rails
38
- requirement: &20880000 !ruby/object:Gem::Requirement
38
+ requirement: &6506180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,21 +43,21 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *20880000
46
+ version_requirements: *6506180
47
47
  - !ruby/object:Gem::Dependency
48
- name: api_smith
49
- requirement: &20878320 !ruby/object:Gem::Requirement
48
+ name: active_attr
49
+ requirement: &6505380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.5.0.alpha.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *20878320
57
+ version_requirements: *6505380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: unicorn
60
- requirement: &20892220 !ruby/object:Gem::Requirement
60
+ requirement: &6504600 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *20892220
68
+ version_requirements: *6504600
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
- requirement: &20890760 !ruby/object:Gem::Requirement
71
+ requirement: &6503700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *20890760
79
+ version_requirements: *6503700
80
80
  description: Description of EspCommons.
81
81
  email:
82
82
  - mail@openteam.ru
@@ -86,17 +86,17 @@ extra_rdoc_files: []
86
86
  files:
87
87
  - app/models/esp_commons/image.rb
88
88
  - config/initializers/sunspot.rb
89
- - config/locales/commons.ru.yml
90
- - config/locales/datetime.ru.yml
91
89
  - config/unicorn.rb
90
+ - config/locales/datetime.ru.yml
91
+ - config/locales/commons.ru.yml
92
+ - lib/generators/esp_commons/install/install_generator.rb
93
+ - lib/generators/esp_commons/install/script/update_site
94
+ - lib/generators/esp_commons/install/script/start_site
95
+ - lib/generators/esp_commons/install/config/schedule.rb
96
+ - lib/generators/esp_commons/install/config/unicorn.rb
92
97
  - lib/esp-commons/engine.rb
93
98
  - lib/esp-commons/version.rb
94
99
  - lib/esp-commons.rb
95
- - lib/generators/esp_commons/install/config/schedule.rb
96
- - lib/generators/esp_commons/install/config/unicorn.rb
97
- - lib/generators/esp_commons/install/install_generator.rb
98
- - lib/generators/esp_commons/install/script/start_site
99
- - lib/generators/esp_commons/install/script/update_site
100
100
  - MIT-LICENSE
101
101
  - Rakefile
102
102
  - README.rdoc
@@ -114,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  segments:
116
116
  - 0
117
- hash: -3363018066665106858
117
+ hash: 1048902172365005320
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
@@ -123,10 +123,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  segments:
125
125
  - 0
126
- hash: -3363018066665106858
126
+ hash: 1048902172365005320
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 1.8.16
129
+ rubygems_version: 1.8.15
130
130
  signing_key:
131
131
  specification_version: 3
132
132
  summary: Summary of EspCommons.