spectra 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/lib/spectra/commands.rb +1 -1
- data/lib/spectra/models/color.rb +11 -2
- data/lib/spectra/template.rb +2 -2
- data/lib/spectra/utilities.rb +7 -1
- data/lib/spectra/version.rb +1 -1
- data/lib/spectra/views/objc_category.rb +1 -1
- data/lib/spectra/views/palette.rb +1 -1
- data/lib/spectra/views/swift_extension.rb +1 -1
- data/lib/spectra/views/view.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bfbb855908c014d2fb5bc287c3e3308a017749e
|
4
|
+
data.tar.gz: b54621293748e77c9b58218741de763508f08b22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b41b802b67693a38069e7bd63d3d50320411b60f1633a2fd8f8709aa30e8e4055b5ab81057a7639baec3af4ce43a7806d93442adc7ee9e10bc268d3da8ed16
|
7
|
+
data.tar.gz: 039eab67a118b693505d4d60e2ae1e27afcbf80c479a3b5301cc3c85da259453d6570f8b504abb72777f6c91487012de4aeee1b71f7646f64733c531434a0798
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ Spectra
|
|
2
2
|
========
|
3
3
|
Keep app-specific colors in-sync across all your tools with a single specification!
|
4
4
|
|
5
|
-
Spectra is a
|
5
|
+
Spectra is a Ruby DSL for generating color palettes (.clr), Objective-C categories, and Swift extensions. Define a spectrum.rb file, run `spectra generate`, and your color files synchronize!
|
6
6
|
|
7
7
|
## Using the DSL: spectrum.rb
|
8
8
|
|
@@ -21,15 +21,15 @@ formats :palette, :swift
|
|
21
21
|
format :objc, 'path/to/categories'
|
22
22
|
|
23
23
|
## if you want to customize the method/color names
|
24
|
-
format :swift, 'path/to/extensions' do |
|
25
|
-
name.camelize(true) #
|
24
|
+
format :swift, 'path/to/extensions' do |color, prefix|
|
25
|
+
color.name.camelize(true) + color.suffix # CoolBlue2
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
29
|
-
Specifying colors (optional, but
|
29
|
+
Specifying colors (*technically* optional, but hey...):
|
30
30
|
```ruby
|
31
31
|
color :red, (components 255, 0, 130)
|
32
|
-
color :gray, (hex 0xEEEEEE 0.6)
|
32
|
+
color :gray, (hex 0xEEEEEE, 0.6)
|
33
33
|
color :white, (white 1.0)
|
34
34
|
color :overlay (components 0.8, 0.7, 0.2, 0.75)
|
35
35
|
|
@@ -50,6 +50,6 @@ gem install spectra
|
|
50
50
|
|
51
51
|
Or `bundler`:
|
52
52
|
```ruby
|
53
|
-
gem 'spectra', '~> 0.1
|
53
|
+
gem 'spectra', '~> 0.1'
|
54
54
|
```
|
55
55
|
|
data/lib/spectra/commands.rb
CHANGED
@@ -7,10 +7,10 @@ module Spectra
|
|
7
7
|
class Command < CLAide::Command
|
8
8
|
|
9
9
|
self.abstract_command = true
|
10
|
-
self.default_subcommand = 'generate'
|
11
10
|
|
12
11
|
self.command = 'spectra'
|
13
12
|
self.summary = 'Serializes colors into a variety of filetypes using a convenient ruby DSL'
|
13
|
+
self.version = VERSION
|
14
14
|
|
15
15
|
def initialize(argv)
|
16
16
|
Spectra.logger.parse_argv(argv)
|
data/lib/spectra/models/color.rb
CHANGED
@@ -5,13 +5,22 @@ module Spectra
|
|
5
5
|
|
6
6
|
class Color
|
7
7
|
|
8
|
-
attr_accessor :name, :components
|
8
|
+
attr_accessor :name, :suffix, :components
|
9
9
|
|
10
10
|
def initialize(name, components)
|
11
|
-
self.name = name
|
11
|
+
self.name, self.suffix = self.parse_name(name)
|
12
12
|
self.components = components
|
13
13
|
end
|
14
14
|
|
15
|
+
def parse_name(name)
|
16
|
+
name_parts = name.to_s.split(/(\d+)/)
|
17
|
+
return name_parts.first, name_parts[1] || ''
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
## Forwarding
|
22
|
+
##
|
23
|
+
|
15
24
|
def respond_to?(name)
|
16
25
|
super || Components.valid?(name)
|
17
26
|
end
|
data/lib/spectra/template.rb
CHANGED
@@ -7,8 +7,8 @@ format :palette
|
|
7
7
|
format :objc, 'path/to/categories'
|
8
8
|
|
9
9
|
## customize the name generation for a specific format
|
10
|
-
# format :objc do |
|
11
|
-
# name.camelize(true)
|
10
|
+
# format :objc do |color, prefix|
|
11
|
+
# color.name.camelize(true) + color.suffix
|
12
12
|
# end
|
13
13
|
|
14
14
|
## specify the colors to generate
|
data/lib/spectra/utilities.rb
CHANGED
@@ -90,7 +90,13 @@ end
|
|
90
90
|
|
91
91
|
class Symbol
|
92
92
|
def camelize(pascal)
|
93
|
-
self.to_s.
|
93
|
+
self.to_s.camelize(pascal)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
class String
|
98
|
+
def camelize(pascal)
|
99
|
+
self.split('_').map.with_index do |component, index|
|
94
100
|
!pascal && index == 0 ? component : component.capitalize
|
95
101
|
end.join('')
|
96
102
|
end
|
data/lib/spectra/version.rb
CHANGED
data/lib/spectra/views/view.rb
CHANGED
@@ -49,8 +49,8 @@ module Spectra
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
def format_color_name(
|
53
|
-
self.renamer.call(
|
52
|
+
def format_color_name(color)
|
53
|
+
self.renamer.call(color, self.prefix)
|
54
54
|
end
|
55
55
|
|
56
56
|
def format_color_value(value)
|
@@ -93,7 +93,7 @@ module Spectra
|
|
93
93
|
##
|
94
94
|
|
95
95
|
def name
|
96
|
-
self.format(:name, self.color
|
96
|
+
self.format(:name, self.color)
|
97
97
|
end
|
98
98
|
|
99
99
|
def grayscale?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ty Cobb
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|