colorly 0.0.1

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.
@@ -0,0 +1,27 @@
1
+ require 'chroma'
2
+
3
+ class String
4
+ def spin(*args)
5
+ paint.spin *args
6
+ end
7
+
8
+ def darken(*args)
9
+ paint.darken *args
10
+ end
11
+
12
+ def lighten(*args)
13
+ paint.lighten *args
14
+ end
15
+
16
+ def saturate(*args)
17
+ paint.saturate *args
18
+ end
19
+
20
+ def desaturate(*args)
21
+ paint.desaturate *args
22
+ end
23
+
24
+ def palette(*args)
25
+ paint.palette *args
26
+ end
27
+ end
@@ -0,0 +1,61 @@
1
+ module Colorly
2
+ class Script
3
+ attr_reader :script, :filename
4
+
5
+ def self.load(script_file)
6
+ raise ScriptNotFound, "Unable to load #{script_file}" unless File.exist? script_file
7
+ new File.read(script_file), filename: script_file
8
+ end
9
+
10
+ def initialize(script, filename: nil)
11
+ @script, @filename = script, filename
12
+ end
13
+
14
+ def run
15
+ instance_eval script
16
+ end
17
+
18
+ def output
19
+ @output ||= {}
20
+ end
21
+
22
+ def to_h
23
+ output.transform_values do |chroma_array|
24
+ chroma_array.map do |chroma|
25
+ chroma.to_hex
26
+ end
27
+ end
28
+ end
29
+
30
+ # DSL Methods
31
+
32
+ def title(title)
33
+ @current_title = title
34
+ end
35
+
36
+ def add(color)
37
+ if color.is_a? Array
38
+ color.each { |c| add c }
39
+ else
40
+ output[current_title] ||= []
41
+ @last = color.is_a?(String) ? color.paint : color
42
+ output[current_title] << last
43
+ end
44
+ end
45
+
46
+ def last
47
+ @last ||= 'red'.paint
48
+ end
49
+
50
+ def random
51
+ "#%06x" % (rand * 0xffffff)
52
+ end
53
+
54
+ private
55
+
56
+ def current_title
57
+ @current_title ||= "Untitled"
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,44 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>Colorly</title>
5
+ </head>
6
+ <body>
7
+ <style>
8
+ * { font-family: arial; font-size: 14px }
9
+
10
+ body { padding: 10px }
11
+ html { padding-bottom: 100px }
12
+
13
+ .color {
14
+ float: left;
15
+ width: 120px;
16
+ height: 120px;
17
+ padding: 10px 10px 10px 10px;
18
+ border: 2px solid white;
19
+ border-radius: 10px;
20
+ }
21
+
22
+ .dark { color: white }
23
+
24
+ h2 {
25
+ font-size: 20px;
26
+ margin: 0;
27
+ padding: 20px 0 5px 0;
28
+ clear: both;
29
+ }
30
+ </style>
31
+
32
+ <% output.each do |name, colors| %>
33
+ <h2><%= name %></h2>
34
+ <% colors.each do |color| %>
35
+ <% css_class = color.dark? ? 'dark color' : 'light color' %>
36
+ <div class='<%= css_class %>' style='background-color:<%= color.to_hex %>'>
37
+ <%= color.to_hex.upcase %><br>
38
+ <%= color.shade %><br>
39
+ <%= color.name %><br>
40
+ </div>
41
+ <% end %>
42
+ <% end %>
43
+ </body>
44
+ </html>
@@ -0,0 +1,3 @@
1
+ module Colorly
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Danny Ben Shitrit
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chroma
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colsole
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: filewatcher
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mister_bin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: requires
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
83
+ description: Command line for generating color palettes
84
+ email: db@dannyben.com
85
+ executables:
86
+ - colorly
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - README.md
91
+ - bin/colorly
92
+ - lib/colorly.rb
93
+ - lib/colorly/cli.rb
94
+ - lib/colorly/command.rb
95
+ - lib/colorly/exceptions.rb
96
+ - lib/colorly/extensions/chroma_color.rb
97
+ - lib/colorly/extensions/string.rb
98
+ - lib/colorly/script.rb
99
+ - lib/colorly/templates/html.erb
100
+ - lib/colorly/version.rb
101
+ homepage: https://github.com/dannyben/colorly
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ bug_tracker_uri: https://github.com/DannyBen/colorly/issues
106
+ source_code_uri: https://github.com/dannyben/colorly
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 2.4.0
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubygems_version: 3.2.16
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Colorly color palette CLI
126
+ test_files: []