kreegerator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,20 +1,23 @@
1
1
  # Kreegerator
2
2
 
3
- A set of generators for various projects I work on.
3
+ A set of generators and batch processors for various projects I work on.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Install it as a gem!
8
8
 
9
- gem 'kreegerator'
9
+ gem install kreegerator
10
10
 
11
- And then execute:
11
+ Then run the command to see which functions are available.
12
12
 
13
- $ bundle
13
+ Tasks:
14
+ kreegerator help [TASK] # Describe available tasks or one specific task
15
+ kreegerator ios TEMPLATE CLASS_NAME # fire off an iOS generator
16
+ kreegerator retina ACTION GLOB # handles image adjustments for retina displays
14
17
 
15
- Or install it yourself as:
18
+ To see subfunctions...
16
19
 
17
- $ gem install kreegerator
20
+ kreegerator [TASK] list
18
21
 
19
22
  ## Usage
20
23
 
@@ -22,8 +22,8 @@ class Kreegerator::CLI < Thor
22
22
  end
23
23
 
24
24
  desc 'retina ACTION GLOB', 'handles image adjustments for retina displays'
25
- method_option :pngnq, desc: 'Runs the files through pngnq as well.', type: :integer
26
- def retina(method_name, glob)
25
+ method_option :pngnq, desc: 'Runs the files through pngnq as well.'
26
+ def retina(method_name, glob=nil)
27
27
  if Kreegerator::Retina.respond_to?(method_name.to_sym)
28
28
  if method_name == 'list'
29
29
  Kreegerator::Retina.send(method_name.to_sym)
@@ -4,35 +4,37 @@ require 'erb'
4
4
  # This module uses the amazing Tilt library to give the ability to render
5
5
  # a template in the `lib/filemover/templates` directory to any including
6
6
  # class.
7
- module Kreegerator::Renderable
7
+ module Kreegerator
8
+ module Renderable
8
9
 
9
- # Accepts path to a template relative to `lib/filemover/templates` along
10
- # with a hash and renders a template using the amazing and magical Tilt.
11
- #
12
- # @param [String] template the relative path to the template, from
13
- # `lib/filemover/templates`.
14
- # @param [Hash] data the hash of values to render. The keys will be sent
15
- # to the template as instance variables `@like_this`.
16
- def render(template, data)
10
+ # Accepts path to a template relative to `lib/filemover/templates` along
11
+ # with a hash and renders a template using the amazing and magical Tilt.
12
+ #
13
+ # @param [String] template the relative path to the template, from
14
+ # `lib/filemover/templates`.
15
+ # @param [Hash] data the hash of values to render. The keys will be sent
16
+ # to the template as instance variables `@like_this`.
17
+ def render(template, data)
17
18
 
18
- # META! Assign instance variables to self using the hash passed in.
19
- data.each { |key, value| instance_variable_set "@#{key}", value }
19
+ # META! Assign instance variables to self using the hash passed in.
20
+ data.each { |key, value| instance_variable_set "@#{key}", value }
20
21
 
21
- # Get the absolute template location relative to our template basepath.
22
- template_location = File.join(template_path, template)
22
+ # Get the absolute template location relative to our template basepath.
23
+ template_location = File.join(template_path, template)
23
24
 
24
- # Let Tilt do the rest. Also pass in `self` as that's the reference to
25
- # the object that holds our new, metaprogrammed `@instance_variables`.
26
- Tilt.new(template_location).render(self)
27
- end
25
+ # Let Tilt do the rest. Also pass in `self` as that's the reference to
26
+ # the object that holds our new, metaprogrammed `@instance_variables`.
27
+ Tilt.new(template_location).render(self)
28
+ end
28
29
 
29
- protected
30
+ protected
30
31
 
31
- # A helper that provides the absolute path to `Filemover`'s master template
32
- # directory at `lib/filemover/templates`.
33
- #
34
- # @return [String] the absolute path of the `templates` directory.
35
- def template_path
36
- File.expand_path('../../../templates', __FILE__)
32
+ # A helper that provides the absolute path to `Filemover`'s master template
33
+ # directory at `lib/filemover/templates`.
34
+ #
35
+ # @return [String] the absolute path of the `templates` directory.
36
+ def template_path
37
+ File.expand_path('../../../templates', __FILE__)
38
+ end
37
39
  end
38
40
  end
@@ -1,4 +1,4 @@
1
- require 'FileUtils'
1
+ require 'fileutils'
2
2
  require 'mini_magick'
3
3
 
4
4
  class Kreegerator::Retina
@@ -10,6 +10,10 @@ class Kreegerator::Retina
10
10
  end
11
11
 
12
12
  def downscale(glob, opts)
13
+ if glob.nil?
14
+ puts "You must specify a file match glob (like 'tmp/*.png') or I won't know what to do!"
15
+ return
16
+ end
13
17
  Dir[glob].select { |f| f =~ /\.png\Z/i }.each do |file|
14
18
  puts "Downscaling #{file}."
15
19
  scale_image file, 0.5, true
@@ -31,7 +35,7 @@ class Kreegerator::Retina
31
35
  def crunch_image(file, colors)
32
36
  puts "Crunching image #{file}."
33
37
  cmd = "pngnq #{file} -f -s 1"
34
- cmd << " -n #{colors}" unless colors.nil?
38
+ cmd << " -n #{colors.to_i}" unless colors.nil?
35
39
  system cmd
36
40
  end
37
41
 
@@ -1,3 +1,3 @@
1
1
  module Kreegerator
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kreegerator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -112,7 +112,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
112
  version: '0'
113
113
  segments:
114
114
  - 0
115
- hash: 721120211358296094
115
+ hash: -197103691425396573
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  segments:
123
123
  - 0
124
- hash: 721120211358296094
124
+ hash: -197103691425396573
125
125
  requirements: []
126
126
  rubyforge_project:
127
127
  rubygems_version: 1.8.23