profilepic 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d41ebabc80cb160ec234b527e6c1fc7d04ef28794a57fc7c1bba83fa9d357fc
4
- data.tar.gz: 83175dee4ce2769394a40aff87ad1358082c9a3f89522e918977577b69eaf0e2
3
+ metadata.gz: 0d9194ef8a921921733a83bef15c522456fd399d93e606e5d1e11e2252a2da80
4
+ data.tar.gz: 17e38b0c8108879aafe9313544a7dd97166024845017231658646fa4bd4840a8
5
5
  SHA512:
6
- metadata.gz: b47049d03f7a3d935b31e2e3d9682d02ba55e9bc0238b4b8a55b9b93d6cd84518e2384945acaf562de43a1661094657f3e2ffb3ef8ca51765ee567e631863b6a
7
- data.tar.gz: 2cd589f2713dfa6f007290566037b8956fe11b1f4010b358dcfd07dc5f1487a01ceb23cce0d2a9cc2cef92d1ebf63f211cedefd4286f736409e68dfcf05aa0bb
6
+ metadata.gz: f5ad1a98d1e65e7fa3f10c18226c474aa27a79802242b8eee7405444f6e2a3b5df9a313e3d91f2b5faba0358029377f175ac7bdc83431824938e633d9d4df961
7
+ data.tar.gz: dd1b25d565262e24fff04468f09fd60f933b0ad151a6e2628b4aa46efb7880e608713aebbfcfc56c9d9db472cd5f5552e202a79fa0aa7c530422f9e415a3d2b0
data/Manifest.txt CHANGED
@@ -5,20 +5,20 @@ Rakefile
5
5
  bin/profilepic
6
6
  lib/profilepic.rb
7
7
  lib/profilepic/builder.rb
8
- lib/profilepic/public/doge-24x24.csv
9
- lib/profilepic/public/doge-24x24.png
10
- lib/profilepic/public/marcs-24x24.csv
11
- lib/profilepic/public/marcs-24x24.png
8
+ lib/profilepic/config/doge.rb
9
+ lib/profilepic/config/marcs.rb
10
+ lib/profilepic/config/saudis.rb
11
+ lib/profilepic/config/yeoldepunks.rb
12
+ lib/profilepic/helper.rb
12
13
  lib/profilepic/public/spritesheet.js
13
14
  lib/profilepic/public/style.css
14
- lib/profilepic/public/yeoldepunks-24x24.csv
15
- lib/profilepic/public/yeoldepunks-24x24.png
16
15
  lib/profilepic/service.rb
17
16
  lib/profilepic/version.rb
18
17
  lib/profilepic/views/doge.erb
19
18
  lib/profilepic/views/index.erb
20
19
  lib/profilepic/views/layout.erb
21
20
  lib/profilepic/views/marcs.erb
22
- lib/profilepic/views/shared/_more_options.erb
21
+ lib/profilepic/views/more.erb
22
+ lib/profilepic/views/saudis.erb
23
23
  lib/profilepic/views/shared/_version.erb
24
24
  lib/profilepic/views/yeoldepunks.erb
data/README.md CHANGED
@@ -8,11 +8,44 @@
8
8
 
9
9
 
10
10
 
11
+ ## Command-Line Tool
11
12
 
12
- ## Usage
13
+ Use the command line tool named - surprise, surpirse - `profilepic`
14
+ to run a zero-config / out-of-the-box profile pic(ture) as a service. Type:
13
15
 
14
- ...
16
+ $ profilepic
15
17
 
18
+ That will start-up a (local loopback) web server / service running on port 3000.
19
+ Open-up up the index page in your browser to get started e.g. <http://localhost:3000/>.
20
+
21
+ That's it.
22
+
23
+
24
+
25
+
26
+
27
+
28
+ ## Usage in Your Scripts And/Or (Web) Apps
29
+
30
+ Yes, you can. The [`ProfilepicService` class](lib/profilepic/service.rb) is a "plain-vanilla" rack (web) app (powered by the [sinatra gem / library](https://github.com/sinatra/sinatra)). To run the app "standalone" use:
31
+
32
+ ``` ruby
33
+ require 'profilepic'
34
+
35
+ # start-up the ProfilepicService (rack) app, that is, the profile pic(ure) as a service,
36
+ # using the WEBrick server running on port 3000 using the local loopback host e.g. 127.0.0.1
37
+ Rack::Handler::WEBrick.run ProfilepicService, :Port => 3000, :Host => '127.0.0.1'
38
+ ```
39
+
40
+ Or mount the rack (web) app in your own scripts or web framework/library of choice.
41
+
42
+
43
+
44
+ ## Install
45
+
46
+ Just install the gem:
47
+
48
+ $ gem install profilepic
16
49
 
17
50
 
18
51
 
@@ -13,13 +13,8 @@ class ImageReq ## (Generate) Image Request
13
13
  name = _norm_key( params[:t] || 'punk' )
14
14
  attributes = _parse_attributes( params[:attributes] || '' )
15
15
 
16
- zoom = _parse_zoom( params[:z] || '1' )
17
- background = _norm_key( params[:bg] || 'none' )
18
-
19
16
  new( name: name,
20
- attributes: attributes,
21
- zoom: zoom,
22
- background: background )
17
+ attributes: attributes )
23
18
  end
24
19
 
25
20
  def self.build_marc( params )
@@ -27,59 +22,35 @@ class ImageReq ## (Generate) Image Request
27
22
  pp params
28
23
 
29
24
  name = 'marc'
30
- archetype = _norm_key( params[:t] || 'marc' )
31
- more_attributes = _parse_attributes( params[:attributes] || '' )
32
-
33
- eyes = _norm_key( params[:eyes] || 'none' )
34
- face = _norm_key( params[:face] || 'none' )
35
- beard = _norm_key( params[:beard] || 'none' )
36
- hair = _norm_key( params[:hair] || 'none' )
37
- headwear = _norm_key( params[:headwear] || 'none' )
38
- eyewear = _norm_key( params[:eyewear] || 'none' )
39
- mouth = _norm_key( params[:mouth] || 'none' )
40
-
41
- zoom = _parse_zoom( params[:z] || '1' )
42
- background = _norm_key( params[:bg] || 'none' )
43
-
44
- attributes = [archetype]
45
- attributes << eyes if eyes != 'none'
46
- attributes << face if face != 'none'
47
- attributes << hair if hair != 'none'
48
- attributes << beard if beard != 'none'
49
- attributes << headwear if headwear != 'none'
50
- attributes << eyewear if eyewear != 'none'
51
- attributes << mouth if mouth != 'none'
25
+ attributes = _build_attributes( params, MARC )
52
26
 
53
27
  new( name: name,
54
- attributes: attributes + more_attributes,
55
- zoom: zoom,
56
- background: background )
28
+ attributes: attributes )
57
29
  end
58
30
 
59
- def self.build_doge( params )
31
+
32
+ def self.build_saudi( params )
60
33
  puts "==> image request params:"
61
34
  pp params
62
35
 
63
- name = 'doge'
64
- archetype = _norm_key( params[:t] || 'classic' )
65
- more_attributes = _parse_attributes( params[:attributes] || '' )
36
+ name = 'saudi'
37
+ attributes = _build_attributes( params, SAUDI )
38
+
39
+ new( name: name,
40
+ attributes: attributes )
41
+ end
42
+
66
43
 
67
- hair = _norm_key( params[:hair] || 'none' )
68
- headwear = _norm_key( params[:headwear] || 'none' )
69
- eyewear = _norm_key( params[:eyewear] || 'none' )
44
+ def self.build_doge( params )
45
+ puts "==> image request params:"
46
+ pp params
70
47
 
71
- zoom = _parse_zoom( params[:z] || '1' )
72
- background = _norm_key( params[:bg] || 'none' )
48
+ name = 'doge'
73
49
 
74
- attributes = [archetype]
75
- attributes << hair if hair != 'none'
76
- attributes << headwear if headwear != 'none'
77
- attributes << eyewear if eyewear != 'none'
50
+ attributes = _build_attributes( params, DOGE )
78
51
 
79
52
  new( name: name,
80
- attributes: attributes + more_attributes,
81
- zoom: zoom,
82
- background: background )
53
+ attributes: attributes )
83
54
  end
84
55
 
85
56
 
@@ -88,70 +59,37 @@ class ImageReq ## (Generate) Image Request
88
59
  pp params
89
60
 
90
61
  name = 'yeoldepunk'
91
- archetype = _norm_key( params[:t] || 'male 3' )
92
-
93
- hair = _norm_key( params[:hair] || 'none' )
94
- beard = _norm_key( params[:beard] || 'none' )
95
- eyes = _norm_key( params[:eyes] || 'none' )
96
- eyewear = _norm_key( params[:eyewear] || 'none' )
97
- blemish = _norm_key( params[:blemish] || 'none' )
98
- nose = _norm_key( params[:nose] || 'none' )
99
- mouth = _norm_key( params[:mouth] || 'none' )
100
- mouthprop = _norm_key( params[:mouthprop] || 'none' )
101
- earring = _norm_key( params[:earring] || 'none' )
102
- headwear = _norm_key( params[:headwear] || 'none' )
103
- neck = _norm_key( params[:neck] || 'none' )
104
-
105
- zoom = _parse_zoom( params[:z] || '1' )
106
- background = _norm_key( params[:bg] || 'none' )
107
-
108
- attributes = [archetype]
109
- attributes << hair if hair != 'none'
110
- attributes << blemish if blemish != 'none'
111
- attributes << beard if beard != 'none'
112
- attributes << eyes if eyes != 'none'
113
- attributes << eyewear if eyewear != 'none'
114
- attributes << nose if nose != 'none'
115
- attributes << mouth if mouth != 'none'
116
- attributes << mouthprop if mouthprop != 'none'
117
- attributes << earring if earring != 'none'
118
- attributes << headwear if headwear != 'none'
119
- attributes << neck if neck != 'none'
62
+
63
+ attributes = _build_attributes( params, YEOLDEPUNK )
120
64
 
121
65
  new( name: name,
122
- attributes: attributes,
123
- zoom: zoom,
124
- background: background )
66
+ attributes: attributes )
125
67
  end
126
68
 
127
69
 
128
70
 
129
71
  attr_reader :name,
130
- :attributes,
131
- :zoom,
132
- :background
133
- def initialize( name:, attributes:, zoom:, background: )
72
+ :attributes
73
+ def initialize( name:, attributes: )
134
74
  @name = name
135
75
  @attributes = attributes
136
- @zoom = zoom
137
- @background = background
138
76
  end
139
77
 
140
78
  def image
141
- img = Original::Image.fabricate( @name, *@attributes )
142
- img = img.background( @background ) if @background != 'none'
143
- img = img.zoom( @zoom ) if [2,3,4,5,6,7,8,9,10,20].include?( @zoom )
144
- img
79
+ ## check - cache / memoize image - why? why not?
80
+ Original::Image.fabricate( @name, *@attributes )
145
81
  end
146
82
 
83
+ def image_blob() image.to_blob; end
84
+ alias_method :blob, :image_blob ## keep (shortcut) alias - why? why not?
85
+
147
86
  def image_key
148
- @key ||= begin
149
- key = "#{@name}#{Time.now.to_i}"
150
- key << "@#{@zoom}x" if [2,3,4,5,6,7,8,9,10,20].include?( @zoom )
151
- key
152
- end
87
+ @key ||= "#{@name}#{Time.now.to_i}"
153
88
  @key
154
89
  end
90
+ alias_method :key, :image_key ## keep (shortcut) alias - why? why not?
91
+
92
+
155
93
 
156
94
  #####
157
95
  # (static) helpers
@@ -160,6 +98,28 @@ def self._norm_key( str )
160
98
  str.downcase.strip
161
99
  end
162
100
 
101
+ def self._build_attributes( params, spec )
102
+ attributes = []
103
+ spec.each do |name,h|
104
+
105
+ value = params[name]
106
+
107
+ if value.nil? || value.empty?
108
+ required = h[:none] == true ## check if value is required or optional
109
+ if required
110
+ raise ArgumentError, "required attribute/param >#{name}< missing"
111
+ else
112
+ next ## skip optional attributes
113
+ end
114
+ else
115
+ key = _norm_key( value )
116
+ attributes << key if key != 'none'
117
+ end
118
+ end
119
+ attributes
120
+ end
121
+
122
+
163
123
  def self._parse_attributes( str )
164
124
  # convert attributes to array
165
125
  ## allow various separators
@@ -169,9 +129,5 @@ def self._parse_attributes( str )
169
129
  attributes
170
130
  end
171
131
 
172
- def self._parse_zoom( str )
173
- str.strip.to_i( 10 )
174
- end
175
-
176
- end
132
+ end # class ImageReq - (Generate) Image Request
177
133
 
@@ -0,0 +1,52 @@
1
+
2
+ DOGE = {
3
+ t: {
4
+ legend: 'Select a doge shiba inu base (archetype)',
5
+ options: [
6
+ 'Classic',
7
+ 'Dark',
8
+ 'Zombie',
9
+ 'Alien',
10
+ ]
11
+ },
12
+
13
+ hair: {
14
+ legend: 'Select hair',
15
+ none: true,
16
+ options: [
17
+ 'Crazy Hair',
18
+ ],
19
+ },
20
+
21
+ headwear: {
22
+ legend: 'Select headwear',
23
+ none: true,
24
+ options: [
25
+ 'Beanie',
26
+ 'Cap',
27
+ 'Cap Forward',
28
+ 'Cowboy Hat',
29
+ 'Fedora',
30
+ 'Knitted Cap',
31
+ 'Top Hat',
32
+ 'Bandana',
33
+ 'Headband',
34
+ 'Tiara',
35
+ ]
36
+ },
37
+
38
+ eyewear: {
39
+ legend: 'Select eyewear',
40
+ none: true,
41
+ options: [
42
+ '3D Glasses',
43
+ 'Big Shades',
44
+ 'Classic Shades',
45
+ 'Regular Shades',
46
+ 'Small Shades',
47
+ 'Nerd Glasses',
48
+ 'Eye Patch',
49
+ ]
50
+ }
51
+ }
52
+
@@ -0,0 +1,163 @@
1
+
2
+ MARC = {
3
+
4
+ t: {
5
+ legend: 'Select a marc base (archetype)',
6
+ options: [
7
+ 'Marc',
8
+ 'Marc Mid',
9
+ 'Marc Dark',
10
+ 'Marc Albino',
11
+ 'Marc Golden',
12
+ 'Mad Lad',
13
+ 'Zombie',
14
+ 'Ape',
15
+ 'Ape Golden',
16
+ 'Ape Pink',
17
+ 'Alien',
18
+ 'Alien Green',
19
+ 'Devil',
20
+ 'Orc',
21
+ 'Skeleton',
22
+ 'Bot'],
23
+ },
24
+
25
+ eyes: {
26
+ legend: 'Select eyes (extras)',
27
+ none: true,
28
+ options: [
29
+ 'Blue Eyes',
30
+ 'Green Eyes',
31
+ ],
32
+ },
33
+
34
+ face: {
35
+ legend: 'Select face (extras)',
36
+ none: true,
37
+ options: [
38
+ 'Blue Eye Shadow',
39
+ 'Green Eye Shadow',
40
+ 'Purple Eye Shadow',
41
+ 'Clown Eyes Blue',
42
+ 'Clown Eyes Green',
43
+ 'Bagner',
44
+ 'Marc Tyson',
45
+ 'Tears',
46
+ ],
47
+ },
48
+
49
+ beard: {
50
+ legend: 'Select beard',
51
+ none: true,
52
+ options: [
53
+ 'Big Beard White',
54
+ 'Big Beard',
55
+ 'Chinstrap',
56
+ 'Front Beard',
57
+ 'Front Beard Dark',
58
+ 'Full Mustache',
59
+ 'Full Mustache Dark',
60
+ 'Goat',
61
+ 'Goat Dark',
62
+ 'Handlebar',
63
+ 'Luxurious Beard',
64
+ 'Mustache',
65
+ 'Mutton Chop',
66
+ 'Normal Beard',
67
+ 'Normal Beard Black',
68
+ 'Shadow Beard',
69
+ 'Soul Patch',
70
+ ],
71
+ },
72
+
73
+ hair: {
74
+ legend: 'Select hair',
75
+ none: true,
76
+ options: [
77
+ 'Blonde Bob',
78
+ 'Chad',
79
+ 'Clown Hair',
80
+ 'Crazy White Hair',
81
+ 'Crazy Hair',
82
+ 'Frumpy Hair',
83
+ 'Marc Three',
84
+ 'Purple Hair',
85
+ 'Stringy Hair',
86
+ 'Vampire Hair',
87
+ 'Wild Blonde Hair',
88
+ 'Wild Hair',
89
+ ],
90
+ },
91
+
92
+ headwear: {
93
+ legend: 'Select headwear',
94
+ none: true,
95
+ options: [
96
+ 'Bandana',
97
+ 'Beanie',
98
+ 'Bunny Ears',
99
+ 'Cap',
100
+ 'Skull Cap',
101
+ 'Cap Forward',
102
+ 'Police Cap',
103
+ 'Cowboy Hat',
104
+ 'Do Rag',
105
+ 'Fast Food',
106
+ 'Marcdonalds',
107
+ 'Fedora',
108
+ 'Headband',
109
+ 'Roaring Headband',
110
+ 'Hoodie',
111
+ 'Purple Hoodie',
112
+ 'Knitted Cap',
113
+ 'Laurels',
114
+ 'Shemagh',
115
+ 'Tassle Hat',
116
+ 'Tiarra',
117
+ 'Top Hat',
118
+ 'Uncle Sam',
119
+ 'Viking',
120
+ 'Welding Goggles',
121
+ ],
122
+ },
123
+
124
+ eyewear: {
125
+ legend: 'Select eyewear',
126
+ none: true,
127
+ options: [
128
+ '3D Glasses',
129
+ 'Aviators',
130
+ 'Big Shades',
131
+ 'Classic Shades',
132
+ 'Deal With It',
133
+ 'Glasses',
134
+ 'Gold Glasses',
135
+ 'Horned-Rim Glasses',
136
+ 'Monocle',
137
+ 'Nerd Glasses',
138
+ 'Pink Shades',
139
+ 'Polarized',
140
+ 'Polarized White',
141
+ 'Regular Shades',
142
+ 'Small Shades',
143
+ 'VR Headset',
144
+ 'Eye Mask',
145
+ 'Eye Patch',
146
+ 'Lasers'],
147
+ },
148
+
149
+ mouth: {
150
+ legend: 'Select mouth prop',
151
+ none: true,
152
+ options: [
153
+ 'Cigar',
154
+ 'Cigarette',
155
+ 'Hookah',
156
+ 'Pipe',
157
+ 'Vape',
158
+ 'Medical Mask',
159
+ 'Bubble Gum' ],
160
+ },
161
+ }
162
+
163
+
@@ -0,0 +1,106 @@
1
+
2
+ SAUDI = {
3
+
4
+ t: {
5
+ legend: 'Select a saudi/sheik base (archetype)',
6
+ options: [
7
+ 'Light 1',
8
+ 'Light 2',
9
+ 'Medium 1',
10
+ 'Medium 2',
11
+ 'Dark 1',
12
+ 'Dark 2',
13
+ ],
14
+ },
15
+
16
+ headwear: {
17
+ legend: 'Select headwear',
18
+ none: true,
19
+ options: [
20
+ 'White Shemagh',
21
+ 'White Shemagh Agal',
22
+ 'White Shemagh Gold Agal',
23
+ 'White Shemagh Stylish Gold Agal',
24
+ 'White Shemagh Crown',
25
+ 'Brown Shemagh Agal',
26
+ 'Brown Shemagh Crown',
27
+ 'Red Shemagh',
28
+ 'Red Shemagh Agal',
29
+ 'Red Shemagh Crown',
30
+ ],
31
+ },
32
+
33
+
34
+ beard: {
35
+ legend: 'Select beard',
36
+ none: true,
37
+ options: [
38
+ 'messy white beard',
39
+ 'short white beard',
40
+ 'normal white beard',
41
+ 'luxurious white beard',
42
+ 'short grey beard',
43
+ 'messy brown beard',
44
+ 'normal brown beard',
45
+ 'luxurious brown beard',
46
+ 'shadow beard',
47
+ 'shadow beard mustache',
48
+ 'light beard',
49
+ 'mustache',
50
+ 'stylish mustache',
51
+ 'sideburns',
52
+ 'sideburns mustache',
53
+ 'normal beard',
54
+ 'normal brown beard mustache',
55
+ 'luxurious beard',
56
+ ],
57
+ },
58
+
59
+
60
+ eyewear: {
61
+ legend: 'Select eyewear',
62
+ none: true,
63
+ options: [
64
+ 'horn rimmed glasses',
65
+ 'rimless glasses',
66
+ 'nerd glasses',
67
+ 'stylish nerd glasses',
68
+ 'classic shades',
69
+ 'classic green shades',
70
+ 'classic gold shades',
71
+ 'regular pixel shades',
72
+ 'regular reflective shades',
73
+ 'big green shades',
74
+ 'big pixel shades',
75
+ 'big purple shades',
76
+ 'big shades',
77
+ 'small shades',
78
+ 'regular shades',
79
+ 'round shades',
80
+ 'big round shades',
81
+ 'square reflective shades',
82
+ 'square shades',
83
+ '3d glasses',
84
+ 'vr',
85
+ 'laser eyes',
86
+ 'max bidding',
87
+
88
+ ],
89
+ },
90
+
91
+ mouth: {
92
+ legend: 'Select mouth prop',
93
+ none: true,
94
+ options: [
95
+ 'cigarette',
96
+ 'shadowless cigarette',
97
+ 'miswak',
98
+ 'vape',
99
+ 'shadowless vape',
100
+ 'cigar',
101
+ 'pearwood pipe',
102
+ 'rosewood pipe',
103
+ 'bubble gum',
104
+ ],
105
+ },
106
+ }