papercrop 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of papercrop might be problematic. Click here for more details.
- data/README.md +4 -2
- data/lib/assets/javascripts/papercrop.js +6 -2
- data/spec/integration/papercrop_js_spec.rb +24 -3
- data/spec/integration/papercrop_spec.rb +0 -5
- data/spec/spec_helper.rb +12 -0
- metadata +81 -19
data/README.md
CHANGED
@@ -46,11 +46,13 @@ Both helpers accept a :width option to customize their dimensions. The preview b
|
|
46
46
|
<%= f.submit 'Save' %>
|
47
47
|
<% end %>
|
48
48
|
|
49
|
-
Regardless of the width, the preview box and the cropping area will have the aspect ratio defined in the model (1:1 by default)
|
49
|
+
Regardless of the width, the preview box and the cropping area will have the aspect ratio defined in the model (1:1 by default)
|
50
|
+
|
51
|
+
If you're rendering it on ajax ensure to call init_papercrop() in js after loading the crop form to make things work properly.
|
50
52
|
|
51
53
|
That's all!
|
52
54
|
|
53
|
-
|
55
|
+
### Credits and resources
|
54
56
|
* [Thoughtbot's Paperclip](https://github.com/thoughtbot/paperclip/)
|
55
57
|
* [Deep Liquid's JCrop](http://deepliquid.com/content/Jcrop.html)
|
56
58
|
* And Ryan Bates' [Railscast#182](http://railscasts.com/episodes/182-cropping-images/), which has inspired this gem
|
@@ -1,6 +1,6 @@
|
|
1
1
|
var jcrop_api;
|
2
2
|
|
3
|
-
|
3
|
+
var init_papercrop = function() {
|
4
4
|
$(document).ready(function() {
|
5
5
|
$('div[id$=_cropbox]').each(function() {
|
6
6
|
var aspect, attachment, preview, update_crop;
|
@@ -40,4 +40,8 @@ var jcrop_api;
|
|
40
40
|
}, function(){ jcrop_api = this; });
|
41
41
|
});
|
42
42
|
});
|
43
|
-
}
|
43
|
+
}
|
44
|
+
|
45
|
+
$(document).ready(function() {
|
46
|
+
init_papercrop();
|
47
|
+
});
|
@@ -2,12 +2,28 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "Image crop with JS", :js => true do
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
it "crops an image with javascript" do
|
6
|
+
visit landscapes_path
|
7
|
+
|
8
|
+
click_link "New Landscape"
|
9
|
+
|
10
|
+
fill_in "Name", :with => "Mountains"
|
11
|
+
find("#landscape_picture").native.send_keys(File.expand_path("../../../test_app/test/fixtures/matterhorn.jpg", __FILE__))
|
12
|
+
click_button "Create Landscape"
|
13
|
+
|
14
|
+
sleep 2
|
15
|
+
page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
|
16
|
+
page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
|
17
|
+
page.execute_script('if ($("#picture_crop_w").val() == "399"){$("#picture_crop_w").val("400")}')
|
18
|
+
|
19
|
+
click_button "Crop image"
|
20
|
+
|
21
|
+
sleep 1
|
22
|
+
compare_images(CROPPED_IMG_PATH, Landscape.last.picture.path(:medium)).should eq(0.0)
|
7
23
|
end
|
8
24
|
|
9
25
|
|
10
|
-
it "crops an image
|
26
|
+
it "crops an image by ajax call" do
|
11
27
|
visit landscapes_path
|
12
28
|
|
13
29
|
click_link "New Landscape"
|
@@ -16,6 +32,11 @@ describe "Image crop with JS", :js => true do
|
|
16
32
|
find("#landscape_picture").native.send_keys(File.expand_path("../../../test_app/test/fixtures/matterhorn.jpg", __FILE__))
|
17
33
|
click_button "Create Landscape"
|
18
34
|
|
35
|
+
click_button "Crop image"
|
36
|
+
click_link "Back"
|
37
|
+
|
38
|
+
click_link "Crop"
|
39
|
+
|
19
40
|
sleep 2
|
20
41
|
page.execute_script("jcrop_api.setSelect([300, 200, 700, 500])")
|
21
42
|
page.execute_script('if ($("#picture_crop_y").val() == "199"){$("#picture_crop_y").val("200")}')
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,7 @@ ENV["RAILS_ENV"] = 'test'
|
|
3
3
|
require File.expand_path("../../test_app/config/environment", __FILE__)
|
4
4
|
require 'rspec/rails'
|
5
5
|
require 'rspec/autorun'
|
6
|
+
require 'database_cleaner'
|
6
7
|
|
7
8
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
9
|
# in spec/support/ and its subdirectories.
|
@@ -38,4 +39,15 @@ RSpec.configure do |config|
|
|
38
39
|
# the seed, which is printed after each run.
|
39
40
|
# --seed 1234
|
40
41
|
config.order = "random"
|
42
|
+
|
43
|
+
|
44
|
+
config.before(:suite) do
|
45
|
+
DatabaseCleaner.strategy = :transaction
|
46
|
+
DatabaseCleaner.clean_with(:truncation)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
config.after(:each) do
|
51
|
+
DatabaseCleaner.clean
|
52
|
+
end
|
41
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papercrop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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-
|
12
|
+
date: 2012-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: jquery-rails
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: paperclip
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '3.1'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec-rails
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '2.0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: capybara
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: 1.1.1
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.1.1
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rmagick
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: sass
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,10 +117,31 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: sqlite3
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: database_cleaner
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
94
145
|
none: false
|
95
146
|
requirements:
|
96
147
|
- - ! '>='
|
@@ -98,7 +149,12 @@ dependencies:
|
|
98
149
|
version: '0'
|
99
150
|
type: :development
|
100
151
|
prerelease: false
|
101
|
-
version_requirements:
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
102
158
|
description: An easy extension for Paperclip to crop your image uploads using jCrop
|
103
159
|
email: rsantamaria.dev@gmail.com
|
104
160
|
executables: []
|
@@ -136,15 +192,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
136
192
|
- - ! '>='
|
137
193
|
- !ruby/object:Gem::Version
|
138
194
|
version: '0'
|
195
|
+
segments:
|
196
|
+
- 0
|
197
|
+
hash: 1413706832105900597
|
139
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
199
|
none: false
|
141
200
|
requirements:
|
142
201
|
- - ! '>='
|
143
202
|
- !ruby/object:Gem::Version
|
144
203
|
version: '0'
|
204
|
+
segments:
|
205
|
+
- 0
|
206
|
+
hash: 1413706832105900597
|
145
207
|
requirements: []
|
146
208
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.8.
|
209
|
+
rubygems_version: 1.8.24
|
148
210
|
signing_key:
|
149
211
|
specification_version: 3
|
150
212
|
summary: Paperclip extension for cropping images
|