img_return 2.1.0 → 3.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/img_return.rb +24 -37
  3. metadata +6 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f4a91ac9673bca6c21a4b4f7c901865a0cd227f3
4
- data.tar.gz: e8e0a7911411400a5d2e7d1fead5cf297babeaea
3
+ metadata.gz: a73614b0cf836df7786678c2ed9ddd55617afcd6
4
+ data.tar.gz: 5111b8e00614894df7190d9316486628b3f638ae
5
5
  SHA512:
6
- metadata.gz: 32a244d6dfb46938e9dcb5ae2ae1016bbe459c434e9ddaae946ad20f33735d37fedee9e3faaf6deffce623317ca35f9d413c09b97df6536dc60db46b5930097b
7
- data.tar.gz: c77034d54d82c18e38a48fd9c0fe78de6a63a6283e3b36d5f4f3021ac68f92285dd58c0fa7d767f58352023266c5e82a4d007e3b7524f21b17106b5f622a60bd
6
+ metadata.gz: b081520738b75f77a07f386499ebee27bc2bfa86793763e8685adc3391d03fb8d573141ab0f78e3ecaf574858699c4c39bb710e8b6525b7b72566d1d9b366df6
7
+ data.tar.gz: ddc28996e861de3ab6a4f18fd7490bafb3281349245682557f5a03232c4845f2e01b3df63bc8d13f05f6c7951bfad616bc39c22004bb1324ab2f373437f388e4
data/lib/img_return.rb CHANGED
@@ -1,52 +1,39 @@
1
1
  require "fileutils"
2
2
 
3
- module Return_Img
4
- def self.random(arry)
5
- random_img = Random.new
6
- ri = random_img.rand(0...arry.size)
7
- arry.each_index do |ei|
8
- @return_background_img = arry[ri] if ei == ri
9
- end
10
-
11
- return @return_background_img
3
+ # Pass in a single Array
4
+ def return_random_image(array)
5
+ random_image = Random.new
6
+ random_image = random_image.rand(0...array.size)
7
+ array.each_index do |index|
8
+ random_image = array[random_image] if index == random_image
12
9
  end
13
10
 
14
- def self.write(path, css_code)
15
- File.open("#{path}.css", 'w') do |fp|
16
- fp.puts(css_code)
17
- end
11
+ random_image
12
+ end
18
13
 
19
- return css_code
14
+ def write_css(output_path, css_code)
15
+ File.open("#{output_path}.css", 'w') do |file|
16
+ file.puts(css_code)
20
17
  end
18
+ end
21
19
 
22
- class Image
23
- def list(dir)
24
- images = []
25
- FileUtils.cd(dir) do
26
- Dir.entries(".").each do |en|
27
- images.push(en) if File.extname(en) == ".png" || File.extname(en) == ".jpg" || File.extname(en) == ".tiff"
28
- end
29
- end
30
-
31
- return images
32
- end
33
-
34
- def write(img_path, css_file_path)
35
- css_code = "body {
36
- background-image: url('#{img_path}');
20
+ def easy_write_css(input_path, output_path)
21
+ css_code = "body {
22
+ background-image: url('#{input_path}');
37
23
  background-repeat:no-repeat;
38
24
  background-size:cover;
39
25
  }"
40
26
 
41
- Return_Img.write(css_file_path, css_code)
42
- end
27
+ write_css(output_path, css_code)
28
+ end
43
29
 
44
- def self.render_color_style(element, style, css_filename_path)
45
- warn Kernel.caller.first + "render_color_style is a deprecated class method. Make your own with Return_Img.write()"
46
- css_color_code = "#{element} {
47
- background-color: #{style};
48
- }"
49
- Return_Img.write(css_filename_path, css_color_code)
30
+ def return_array_of_images(dir)
31
+ images = []
32
+ FileUtils.cd(dir) do
33
+ Dir.entries(".").each do |entry|
34
+ images.push(entry) if File.extname(entry) == ".png" || File.extname(entry) == ".jpg" || File.extname(entry) == ".gif"
50
35
  end
51
36
  end
37
+
38
+ images
52
39
  end
metadata CHANGED
@@ -1,48 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: img_return
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralph Desir
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '10.4'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '10.4'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.3'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.3'
41
- description: Return_Img is a gem designed to return random images and colors. This
42
- gem was created with the idea of returning a different image or color to a cascading
43
- style sheet. For the effect of having a different image return to the browser ever
44
- refresh or visit to the web page. Also in mind was the idea of expedition, by that
45
- I mean expediting a lot of the markup work (HTML/CSS) with this gems helper methods.
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: img_return is a gem designed to return random images. This gem was created
14
+ with the idea of using it to display a random image to a website.
46
15
  email: battleroundscool@gmail.com
47
16
  executables: []
48
17
  extensions: []
@@ -51,7 +20,7 @@ files:
51
20
  - lib/img_return.rb
52
21
  homepage: https://github.com/Mav7/img_return
53
22
  licenses:
54
- - GPLv2
23
+ - GPL-2.0
55
24
  metadata: {}
56
25
  post_install_message:
57
26
  rdoc_options: []
@@ -74,4 +43,3 @@ signing_key:
74
43
  specification_version: 4
75
44
  summary: Image return.
76
45
  test_files: []
77
- has_rdoc: