img_return 1.0.7 → 1.0.9
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.
- checksums.yaml +4 -4
- data/lib/img_return.rb +19 -39
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f80f6a186f111a35e1d15fb08633d7405cd6c5a0
|
4
|
+
data.tar.gz: 8da6fddfae7c19e3c52343696491fe9b1512c821
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ce8b6cbfee10d9eae8fc5ed02d44c0b48e7b023c6c61ca206b533cf638c4cec7c2ece49b1bcd7fb243dbd4a44ee0f77f56e1932b075f4a968395995c4052e4f
|
7
|
+
data.tar.gz: 9c8ea5d2e606b7b0369fe996d56deb3794a049b45f602e0fd5ef01506aa0701974e55631926793a9f7807d78fb978ef0184d70272c7746389969e547a01c6a9a
|
data/lib/img_return.rb
CHANGED
@@ -1,64 +1,44 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
|
3
3
|
module Return_Img
|
4
|
-
|
5
|
-
# Gets array and returns one random element from the array.
|
6
|
-
def self.return_random(arry)
|
7
|
-
raise TypeError, "Argument must be an array." if arry.class != Array
|
4
|
+
def self.random(arry)
|
8
5
|
random_img = Random.new
|
9
|
-
ri = random_img.rand(0
|
6
|
+
ri = random_img.rand(0...arry.size)
|
10
7
|
arry.each_index{|ei|
|
11
8
|
@return_background_img = arry[ri] if ei == ri
|
12
9
|
}
|
13
10
|
return @return_background_img
|
14
11
|
end
|
15
|
-
def self.
|
16
|
-
raise TypeError, "First argument 'path' must be a String." if path.class != String
|
17
|
-
raise TypeError, "Second argument 'css_code' must be a String." if css_code.class != String
|
12
|
+
def self.write(path, css_code)
|
18
13
|
File.open("#{path}.css", 'w'){|fp|
|
19
14
|
fp.puts(css_code)
|
20
15
|
}
|
21
16
|
return css_code
|
22
17
|
end
|
23
|
-
class
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
33
|
-
else
|
34
|
-
FileUtils.cd("app/assets/images/#{dir}") do
|
35
|
-
Dir.entries(".").each{|en|
|
36
|
-
possible_background_images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
|
37
|
-
}
|
38
|
-
end
|
39
|
-
end
|
40
|
-
return possible_background_images
|
18
|
+
class Image
|
19
|
+
def list(dir)
|
20
|
+
images = []
|
21
|
+
FileUtils.cd(dir) do
|
22
|
+
Dir.entries(".").each{|en|
|
23
|
+
images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
|
24
|
+
}
|
25
|
+
end
|
26
|
+
return images
|
41
27
|
end
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
background_css_code = "body {
|
46
|
-
background-image: url('#{bg_img}');
|
28
|
+
def write(img_path, css_file_path)
|
29
|
+
css_code = "body {
|
30
|
+
background-image: url('#{img_path}');
|
47
31
|
background-repeat:no-repeat;
|
48
32
|
background-size:cover;
|
49
33
|
}"
|
50
|
-
Return_Img.
|
51
|
-
return background_css_code
|
34
|
+
Return_Img.write(css_file_path, css_code)
|
52
35
|
end
|
53
|
-
def self.render_color_style(element, style,
|
54
|
-
|
55
|
-
raise TypeError, "Second argument 'style' must be a String." if style.class != String
|
56
|
-
raise TypeError, "Third argument 'css_filename' must be a String." if css_filename.class != String
|
36
|
+
def self.render_color_style(element, style, css_filename_path)
|
37
|
+
warn Kernel.caller.first + "render_color_style is a deprecated class method. Make your own with Return_Img.write()"
|
57
38
|
css_color_code = "#{element} {
|
58
39
|
background-color: #{style};
|
59
40
|
}"
|
60
|
-
Return_Img.
|
61
|
-
return css_color_code
|
41
|
+
Return_Img.write(css_filename_path, css_color_code)
|
62
42
|
end
|
63
43
|
end
|
64
44
|
end
|
metadata
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: img_return
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph Desir
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description: img_return is a gem designed to return random images and colors. This
|
14
|
+
gem was created with the idea of returning a different image or color to a cascading
|
15
|
+
style sheet. For the effect of having a different image return to the browser ever
|
16
|
+
refresh or visit to the web page. Also in mind was the idea of expedition, by that
|
17
|
+
I mean expediting a lot of the markup work (HTML/CSS) with this gems helper methods.
|
14
18
|
email: battleroundscool@gmail.com
|
15
19
|
executables: []
|
16
20
|
extensions: []
|