teaas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e881463c35ff5a40a172a85494f34ed1825f5e7
4
+ data.tar.gz: 1640619a6f1fa74fc9065c3575c28bc69cc08c54
5
+ SHA512:
6
+ metadata.gz: b825bf9b0a945669e93102ee7d9cd365bd558eb2778679a788d405b7da1161d8b373fb018612519abc5f85654f31e8668488a6a7969f68b7cfe048ff4c085793
7
+ data.tar.gz: 8a133564f2c2edc087cb982d3f6705bd8e9abe8fb0fddb79edbe63cf5c8bdd0fa4632f5c323bad955644b00f2e814ba91917acdb7211541fcf021770a153eff6
@@ -0,0 +1,36 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ /.config
5
+ /coverage/
6
+ /InstalledFiles
7
+ /pkg/
8
+ /spec/reports/
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ Gemfile.lock
32
+ .ruby-version
33
+ .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.2"
4
+ - "1.9.3"
5
+ - "2.2.3"
6
+
7
+ script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Bill Rastello
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,77 @@
1
+ # teaas
2
+ ![Build status](https://api.travis-ci.org/wjr1985/teaas.svg?branch=master)
3
+ ## Total Emojis as a Service
4
+
5
+ Total Emojis as a Service (Teaas / TEAAS) is a lightweight library that wraps around [RMagick](https://github.com/rmagick/rmagick) and allows easy manipulation of emojis or emoji-like GIFs. Right now, it supports "Turbo"ing the emoji, or making it spin. This is a very early version, with more features and bug fixes to come in the future.
6
+
7
+ ## Requirements
8
+
9
+ - Ruby 1.9.2 or higher
10
+ - `rmagick` ~> 2.15.4. `rmagick` requires ImageMagick to be installed where this is running. Some free hosts (Heroku a notable example) have this installed already, while others may not. Additionally, the Ruby you're using needs to be able to compile C extensions.
11
+
12
+ ### "Turbo"ing / Turboize
13
+
14
+ "Turbo"ing or Turboize involves changing the GIF animation delay to 1 second, and adjusting the ticks per second to make the emoji speed up or slow down.
15
+
16
+ ### Spin
17
+
18
+ Spinning an image just takes the image that is input and makes it spin clockwise. It was intended for static images, however it does support spinning the last frame on an animated GIF.
19
+
20
+ **NOTE**: Spinning is buggy right now, and only works best on images that are square (32x32 for example). Images that are not square may return invalid results.
21
+
22
+ **NOTE**: Spinning removes any transparency from the image.
23
+
24
+ ## Documentation
25
+ Docs are in [YARD](http://yardoc.org/) format. To build the HTML docs, just `gem install yard` then run `yard`. If you'd rather not use YARD, you can just read the documentation for the methods in the source files.
26
+
27
+ # Example
28
+ If you're looking for a full example, I built a hacky, yet functional, example Heroku app [here](https://github.com/wjr1985/teaas_heroku_example).
29
+
30
+ If you're just interested in code snippets, check these out:
31
+
32
+ ## Turbo
33
+ ### From a file
34
+ ```ruby
35
+ image_path = "image.gif"
36
+
37
+ result = Teaas::Turbo.turbo_from_file(image_path, false)
38
+ // result contains an array of image blobs
39
+ ```
40
+
41
+ ### From a `Magick::ImageList`
42
+
43
+ ```ruby
44
+ image = Magick::ImageList.new
45
+
46
+ //populate image here
47
+
48
+ result = Teaas::Turbo.turbo(image, false)
49
+ // result contains an array of image blobs
50
+ ```
51
+
52
+ ## Spin
53
+ ### From a file
54
+ ```ruby
55
+ image_path = "image.gif"
56
+
57
+ spin_result = Teaas::Spin.spin_from_file(image_path)
58
+ final_result = Teaas::Turbo.turbo(spin_result, false)
59
+ // final_result contains an array of image blobs
60
+ ```
61
+
62
+ ### From a `Magick::ImageList`
63
+ ```ruby
64
+ image = Magick::ImageList.new
65
+
66
+ //populate image here
67
+
68
+ spin_result = Teaas::Spin.spin(image)
69
+ final_result = Teaas::Turbo.turbo(spin_result, false)
70
+ // final_result contains an array of image blobs
71
+ ```
72
+
73
+ # Questions / PRs, etc.
74
+ Feel free to open a GitHub issue or file a pull request if you have a question or would like something added.
75
+
76
+ # License
77
+ It's MIT. See the [LICENSE](https://github.com/wjr1985/teaas/blob/master/LICENSE) file.
@@ -0,0 +1,4 @@
1
+ require 'rmagick'
2
+
3
+ require 'teaas/spin.rb'
4
+ require 'teaas/turboize.rb'
@@ -0,0 +1,35 @@
1
+ module Teaas
2
+ class Spin
3
+
4
+ # Takes in an image, rotates it 90, 180, and 270 degrees, then returns an animated spinning image. Best when used with {Teaas::Turboize.turbo} to generate multiple rotation speeds.
5
+ #
6
+ # @param original_img [Magick::ImageList] The image to be rotated
7
+ # @return [Magick::ImageList] The spinning image
8
+ def self.spin(original_img)
9
+ spinny_image = Magick::ImageList.new
10
+ img = original_img.flatten_images
11
+ img.format = "gif"
12
+
13
+ spinny_image << img
14
+ spinny_image << img.rotate(90)
15
+ spinny_image << img.rotate(180)
16
+ spinny_image << img.rotate(270)
17
+
18
+ spinny_image
19
+ end
20
+
21
+ # Takes in a path to an image, rotates it 90, 180, and 270 degrees, then returns an animated spinning image. Best when used with {Teaas::Turboize.turbo} to generate multiple rotation speeds. This is a wrapper around {Teaas::Spin.spin}
22
+ #
23
+ # @param path [String] Path to the image to be spun
24
+ # @return [Magick::ImageList] The spinning image
25
+ def self.spin_from_file(path)
26
+ img = Magick::ImageList.new
27
+
28
+ # Grab the first element in array to prevent strange things when an
29
+ # animated image is submitted
30
+ img.read(path)[0]
31
+
32
+ spin(img)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,53 @@
1
+ module Teaas
2
+ class Turboize
3
+
4
+ # Takes in an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down.
5
+ #
6
+ # @param img [Magick::ImageList] The image to be turboized
7
+ # @param resize [Integer or Falsey] The size of the largest dimension (eg. 32) for the image, or falsey if no resizing should occur
8
+ # @param speeds [Array] An array of Integers that determines the ticks per second for the resulting animated image
9
+ # @return [Array] An array of image blobs that match each specified speed
10
+ def self.turbo(img, resize, speeds=[2, 5, 10, 20, 30, 40])
11
+ if resize
12
+ img = img.coalesce
13
+ img.each do |frame|
14
+ frame.change_geometry(resize) do |cols, rows, i|
15
+ i.resize!(cols, rows)
16
+ end
17
+ end
18
+ end
19
+
20
+ image_blobs = []
21
+ speeds.each do |turbo|
22
+ image_blobs << turboize_individual_image(img, turbo).to_blob
23
+ end
24
+
25
+ image_blobs
26
+ end
27
+
28
+ # Takes in a path to an image, a resize parameter, and optionally speeds, and returns an image or images that are sped up or slowed down. This method is just a wrapper around {Teaas::Turboize.turbo}
29
+ #
30
+ # @param path [String] The path to the image to be turboized
31
+ # @param resize Truthy if the image should be resized, falsey or nil if it should not
32
+ # @param speeds [Array] An array of Integers that determines the ticks per second for the resulting animated image
33
+ # @return [Array] An array of image blobs that match each specified speed
34
+ def self.turbo_from_file(path, resize, speeds=[2, 5, 10, 20, 30, 40])
35
+ img = Magick::ImageList.new
36
+ img.read(path)
37
+
38
+ turbo(img, resize, speeds)
39
+ end
40
+
41
+ # Takes in a `Magick::ImageList` and adjusts the GIF image delay, ticks per second, and iterations.
42
+ #
43
+ # @param img [Magick::ImageList]
44
+ # @param turbo [Integer] the ticks per second
45
+ # @return [Magick::ImageList]
46
+ def self.turboize_individual_image(img, turbo)
47
+ img.delay = 1
48
+ img.ticks_per_second = turbo
49
+ img.iterations = 0
50
+ img
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'teaas'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['MIT']
5
+ s.summary = "Total Emojis as a Service"
6
+ s.description = "Gem to manipulate emoji-sized images"
7
+ s.authors = ["Bill Rastello"]
8
+ s.email = 'github@billrastello.com'
9
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
10
+ s.homepage = 'https://www.github.com/wjr1985/teaas/'
11
+
12
+ s.add_runtime_dependency 'rmagick', '~> 2.15'
13
+ s.add_development_dependency 'rspec', '~> 3.4'
14
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teaas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bill Rastello
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rmagick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.15'
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.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
41
+ description: Gem to manipulate emoji-sized images
42
+ email: github@billrastello.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - ".travis.yml"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - lib/teaas.rb
53
+ - lib/teaas/spin.rb
54
+ - lib/teaas/turboize.rb
55
+ - teaas.gemspec
56
+ homepage: https://www.github.com/wjr1985/teaas/
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.6
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Total Emojis as a Service
80
+ test_files: []
81
+ has_rdoc: