spectra 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
  SHA1:
3
- metadata.gz: a72b5bc2f151b552d46a573dddbb482420ca601a
4
- data.tar.gz: 657a78b5d037b17114d693826cc2d755c2678dff
3
+ metadata.gz: 7bfbb855908c014d2fb5bc287c3e3308a017749e
4
+ data.tar.gz: b54621293748e77c9b58218741de763508f08b22
5
5
  SHA512:
6
- metadata.gz: b6d7832fe91453953e6f956716739af6f2fa70205a3221c27acb16e9526ea8e16cd8936896c1f8e2a3bda090bd533438a78c636c1cd636724be51a6980708d64
7
- data.tar.gz: 27ab3a675820a9c4f8b0174fb88b463938494d14e8e860f320141d41638fd261b2042c5c06e18048ce940ba44109e8513ac23db725a94799dd1d3542a8462ddd
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 command-line utility and Ruby DSL that generates color palettes (.clr), Objective-C categories, and Swift extensions. Define a spectrum.rb file and then run spectra from the terminal. That's all there is to it.
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 |name, prefix|
25
- name.camelize(true) # SyntacticRogueRed
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 it's pretty pointless not to):
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.1'
53
+ gem 'spectra', '~> 0.1'
54
54
  ```
55
55
 
@@ -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)
@@ -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
@@ -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 |name, prefix|
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
@@ -90,7 +90,13 @@ end
90
90
 
91
91
  class Symbol
92
92
  def camelize(pascal)
93
- self.to_s.split('_').map.with_index do |component, index|
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
@@ -1,3 +1,3 @@
1
1
  module Spectra
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -45,7 +45,7 @@ module Spectra
45
45
  end
46
46
 
47
47
  def renamer
48
- @renamer ||= lambda { |name, prefix| "#{prefix}_#{name.camelize(false)}Color" }
48
+ @renamer ||= lambda { |color, prefix| "#{prefix}_#{color.name.camelize(false)}Color#{color.suffix}" }
49
49
  end
50
50
 
51
51
  ##
@@ -6,7 +6,7 @@ module Spectra
6
6
  class Palette < View
7
7
 
8
8
  def renamer
9
- @renamer || lambda { |name, prefix| name.camelize(true) }
9
+ @renamer || lambda { |color, prefix| color.name.camelize(true) + color.suffix }
10
10
  end
11
11
 
12
12
  ##
@@ -6,7 +6,7 @@ module Spectra
6
6
  class SwiftExtension < View
7
7
 
8
8
  def renamer
9
- @renamer || lambda { |name, prefix| name.camelize(true) }
9
+ @renamer || lambda { |color, prefix| color.name.camelize(true) + color.suffix }
10
10
  end
11
11
 
12
12
  ##
@@ -49,8 +49,8 @@ module Spectra
49
49
  end
50
50
  end
51
51
 
52
- def format_color_name(name)
53
- self.renamer.call(name, self.prefix)
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.name)
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
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-26 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler