Skip to content

Commit

Permalink
fix rubocop errors and depreceated aruba settings
Browse files Browse the repository at this point in the history
  • Loading branch information
tarebyte committed Nov 29, 2015
1 parent 2e1cca5 commit 89c95c0
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion lib/geo_pattern/color_generators/base_color_generator.rb
Expand Up @@ -32,7 +32,7 @@ def transform(color, seed)
new_color = ::Color::RGB.from_html(color).to_hsl
new_color.hue = new_color.hue - hue_offset

if (sat_offset % 2 == 0)
if sat_offset % 2 == 0
new_color.saturation = new_color.saturation + sat_offset
else
new_color.saturation = new_color.saturation - sat_offset
Expand Down
2 changes: 1 addition & 1 deletion lib/geo_pattern/geo_pattern_task.rb
Expand Up @@ -37,7 +37,7 @@ def initialize(opts = {})
def run_task(_verbose)
data.each do |path, string|
opts = {}
path = File.expand_path(path)
path = File.expand_path(path)

if string.is_a?(Hash)
input = string[:input]
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/pattern_generator.rb
Expand Up @@ -28,10 +28,10 @@ def initialize(string, generator: nil, patterns: nil, base_color: nil, color: ni

seed = Seed.new(string)

pattern_validator = PatternValidator.new
pattern_validator = PatternValidator.new
pattern_validator.validate(requested_patterns)

pattern_sieve = PatternSieve.new(requested_patterns, seed)
pattern_sieve = PatternSieve.new(requested_patterns, seed)

@background_generator = BackgroundGenerators::SolidGenerator.new(seed, color_preset)
@structure_generator = begin
Expand Down
2 changes: 1 addition & 1 deletion lib/geo_pattern/pattern_helpers.rb
Expand Up @@ -24,7 +24,7 @@ def html_to_rgb_for_string(seed, base_color)
base_color = ::Color::RGB.from_html(base_color).to_hsl
base_color.hue = base_color.hue - hue_offset

if (sat_offset % 2 == 0)
if sat_offset % 2 == 0
base_color.saturation = base_color.saturation + sat_offset
else
base_color.saturation = base_color.saturation - sat_offset
Expand Down
2 changes: 1 addition & 1 deletion lib/geo_pattern/structure_generators/chevrons_generator.rb
Expand Up @@ -33,7 +33,7 @@ def generate_structure
svg.group(chevron, styles.merge('transform' => "translate(#{x * chevron_width},#{y * chevron_height * 0.66 - chevron_height / 2})"))

# Add an extra row at the end that matches the first row, for tiling.
if (y == 0)
if y == 0
svg.group(chevron, styles.merge('transform' => "translate(#{x * chevron_width},#{6 * chevron_height * 0.66 - chevron_height / 2})"))
end
i += 1
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/structure_generators/diamonds_generator.rb
Expand Up @@ -35,13 +35,13 @@ def generate_structure
'transform' => "translate(#{x * diamond_width - diamond_width / 2 + dx}, #{diamond_height / 2 * y - diamond_height / 2})"))

# Add an extra one at top-right, for tiling.
if (x == 0)
if x == 0
svg.polyline(diamond, styles.merge(
'transform' => "translate(#{6 * diamond_width - diamond_width / 2 + dx}, #{diamond_height / 2 * y - diamond_height / 2})"))
end

# Add an extra row at the end that matches the first row, for tiling.
if (y == 0)
if y == 0
svg.polyline(diamond, styles.merge(
'transform' => "translate(#{x * diamond_width - diamond_width / 2 + dx}, #{diamond_height / 2 * 6 - diamond_height / 2})"))
end
Expand Down
8 changes: 4 additions & 4 deletions lib/geo_pattern/structure_generators/hexagons_generator.rb
Expand Up @@ -35,12 +35,12 @@ def generate_structure
svg.polyline(hex, styles.merge('transform' => "translate(#{x * side_length * 1.5 - hex_width / 2}, #{dy - hex_height / 2})"))

# Add an extra one at top-right, for tiling.
if (x == 0)
if x == 0
svg.polyline(hex, styles.merge('transform' => "translate(#{6 * side_length * 1.5 - hex_width / 2}, #{dy - hex_height / 2})"))
end

# Add an extra row at the end that matches the first row, for tiling.
if (y == 0)
if y == 0
dy = x % 2 == 0 ? 6 * hex_height : 6 * hex_height + hex_height / 2
svg.polyline(hex, styles.merge('transform' => "translate(#{x * side_length * 1.5 - hex_width / 2}, #{dy - hex_height / 2})"))
end
Expand All @@ -56,8 +56,8 @@ def generate_structure
svg
end

def build_hexagon_shape(sideLength)
c = sideLength
def build_hexagon_shape(side_length)
c = side_length
a = c / 2
b = Math.sin(60 * Math::PI / 180) * c
"0,#{b},#{a},0,#{a + c},0,#{2 * c},#{b},#{a + c},#{2 * b},#{a},#{2 * b},0,#{b}"
Expand Down
Expand Up @@ -31,12 +31,12 @@ def generate_structure
svg.circle(x * radius, y * radius, radius, styles)

# Add an extra one at top-right, for tiling.
if (x == 0)
if x == 0
svg.circle(6 * radius, y * radius, radius, styles)
end

# Add an extra row at the end that matches the first row, for tiling.
if (y == 0)
if y == 0
svg.circle(x * radius, 6 * radius, radius, styles)
end

Expand Down
Expand Up @@ -33,11 +33,11 @@ def generate_structure
svg.circle(x * ring_size, y * ring_size, ring_size - stroke_width / 2, styles)

# Add an extra one at top-right, for tiling.
if (x == 0)
if x == 0
svg.circle(6 * ring_size, y * ring_size, ring_size - stroke_width / 2, styles)
end

if (y == 0)
if y == 0
svg.circle(x * ring_size, 6 * ring_size, ring_size - stroke_width / 2, styles)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/geo_pattern/structure_generators/plaid_generator.rb
Expand Up @@ -10,7 +10,7 @@ def generate_structure
# horizontal stripes
i = 0
18.times do
space = hex_val(i, 1)
space = hex_val(i, 1)
local_height += space + 5

val = hex_val(i + 1, 1)
Expand Down
4 changes: 2 additions & 2 deletions lib/geo_pattern/structure_generators/plus_signs_generator.rb
Expand Up @@ -35,13 +35,13 @@ def generate_structure
'transform' => "translate(#{x * plus_size - x * square_size + dx * square_size - square_size},#{y * plus_size - y * square_size - plus_size / 2})"))

# Add an extra column on the right for tiling.
if (x == 0)
if x == 0
svg.group(plus_shape, styles.merge(
'transform' => "translate(#{4 * plus_size - x * square_size + dx * square_size - square_size},#{y * plus_size - y * square_size - plus_size / 2})"))
end

# Add an extra row on the bottom that matches the first row, for tiling.
if (y == 0)
if y == 0
svg.group(plus_shape, styles.merge(
'transform' => "translate(#{x * plus_size - x * square_size + dx * square_size - square_size},#{4 * plus_size - y * square_size - plus_size / 2})"))
end
Expand Down
Expand Up @@ -41,7 +41,7 @@ def generate_structure
'transform' => "translate(#{x * side_length * 0.5 - side_length / 2}, #{triangle_height * y}) rotate(#{rotation}, #{side_length / 2}, #{triangle_height / 2})"))

# Add an extra one at top-right, for tiling.
if (x == 0)
if x == 0
svg.polyline(triangle, styles.merge(
'transform' => "translate(#{6 * side_length * 0.5 - side_length / 2}, #{triangle_height * y}) rotate(#{rotation}, #{side_length / 2}, #{triangle_height / 2})"))
end
Expand Down
6 changes: 3 additions & 3 deletions lib/geo_pattern/structure_generators/xes_generator.rb
Expand Up @@ -33,20 +33,20 @@ def generate_structure
'transform' => "translate(#{x * x_size / 2 - x_size / 2},#{dy - y * x_size / 2}) rotate(45, #{x_size / 2}, #{x_size / 2})"))

# Add an extra column on the right for tiling.
if (x == 0)
if x == 0
svg.group(x_shape, styles.merge(
'transform' => "translate(#{6 * x_size / 2 - x_size / 2},#{dy - y * x_size / 2}) rotate(45, #{x_size / 2}, #{x_size / 2})"))
end

# Add an extra row on the bottom that matches the first row, for tiling.
if (y == 0)
if y == 0
dy = x % 2 == 0 ? 6 * x_size - x_size / 2 : 6 * x_size - x_size / 2 + x_size / 4
svg.group(x_shape, styles.merge(
'transform' => "translate(#{x * x_size / 2 - x_size / 2},#{dy - 6 * x_size / 2}) rotate(45, #{x_size / 2}, #{x_size / 2})"))
end

# These can hang off the bottom, so put a row at the top for tiling.
if (y == 5)
if y == 5
svg.group(x_shape, styles.merge(
'transform' => "translate(#{x * x_size / 2 - x_size / 2},#{dy - 11 * x_size / 2}) rotate(45, #{x_size / 2}, #{x_size / 2})"))
end
Expand Down
2 changes: 1 addition & 1 deletion spec/background_generators/solid_generator_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'

RSpec.describe BackgroundGenerators::SolidGenerator do
subject(:generator) { described_class.new(seed, preset) }
subject(:generator) { described_class.new(seed, preset) }

let(:seed) { instance_double('GeoPattern::Seed') }
let(:preset) { instance_double('GeoPattern::ColorPreset') }
Expand Down
2 changes: 1 addition & 1 deletion spec/support/aruba.rb
Expand Up @@ -18,7 +18,7 @@ def dirs
c.include SpecHelper::Aruba

c.before :each do
clean_current_dir
setup_aruba
restore_env
end
end
4 changes: 2 additions & 2 deletions spec/support/shared_examples/pattern.rb
Expand Up @@ -8,7 +8,7 @@
end

it { expect(pattern.structure).to be_name name }
it { check_binary_file_content(file_name, fixtures_path("generated_patterns/#{name}.svg")) }
it { expect(file_name).to have_same_file_content_like("%/generated_patterns/#{name}.svg") }
end

RSpec.shared_examples 'an invalid pattern' do |chosen_pattern|
Expand All @@ -27,5 +27,5 @@
end

it { expect(pattern.structure).to be_name name }
it { check_binary_file_content(file_name, fixtures_path("generated_patterns/#{name}.svg")) }
it { expect(file_name).to have_same_file_content_like("%/generated_patterns/#{name}.svg") }
end

0 comments on commit 89c95c0

Please sign in to comment.