Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Maciel committed Apr 28, 2017
1 parent 26c051c commit be9b34e
Show file tree
Hide file tree
Showing 20 changed files with 354 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true
source "https://rubygems.org"

gem 'rspec'
gem 'guard'
gem 'guard-rspec'
66 changes: 66 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
GEM
remote: https://rubygems.org/
specs:
coderay (1.1.1)
diff-lcs (1.3)
ffi (1.9.18)
formatador (0.2.5)
guard (2.14.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (~> 1.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.11)
method_source (0.8.2)
nenv (0.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
ruby_dep (1.5.0)
shellany (0.0.1)
slop (3.6.0)
thor (0.19.4)

PLATFORMS
ruby

DEPENDENCIES
guard
guard-rspec
rspec

BUNDLED WITH
1.14.6
70 changes: 70 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

# Note: The cmd option is now required due to the increasing number of ways
# rspec may be run, below are examples of the most common uses.
# * bundler: 'bundle exec rspec'
# * bundler binstubs: 'bin/rspec'
# * spring: 'bin/rspec' (This will use spring if running and you have
# installed the spring binstubs per the docs)
# * zeus: 'zeus rspec' (requires the server to be started separately)
# * 'just' rspec: 'rspec'

guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)

# Feel free to open issues for suggestions and improvements

# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)

# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)

# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)

watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller"),
rspec.spec.call("acceptance/#{m[1]}")
]
end

# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }

# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
end
end
Empty file added lib/cadence.rb
Empty file.
Empty file added lib/chord.rb
Empty file.
26 changes: 26 additions & 0 deletions lib/chords.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Chords
def initialize(chord_name=nil)
# @frets = frets
end

def to_s
# chord_name(frets)
end

def intervals

end

def chord_name
return @chord_name unless @chord_name.nil?
puts 'Cmaj7'
end
end

def main
puts 'Enter the chord name (ex: Maj7)'
puts Chords.new(gets).intervals
main
end

main
31 changes: 31 additions & 0 deletions lib/classic_scales.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class GuitarScale
def initialize(interval_sequence)
@interval_sequence = interval_sequence
end

def string_offsets
[0,5,10,15,19,24]
end

def print
puts render_strings
end

def render_strings
string_offsets.reverse.map do |offset|
render_string(offset)
end.join("\n")
end

def render_string(string_offset)
frets = @interval_sequence.to_frets(string_offset)
output = 24.times.map do |x|
render_fret frets.include?(x)
end.join(' ')
end

def render_fret(status)
status ? Paint['•', :red] : Paint['—', :black]
end

end
Empty file added lib/fret.rb
Empty file.
Empty file added lib/fretset.rb
Empty file.
22 changes: 22 additions & 0 deletions lib/interval_set.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class IntervalSet
def initialize(*intervals)
@intervals = intervals
@number_of_frets = 24
sum = @intervals.reduce(:+)
sum < 12 && @intervals << 12 - sum
end

def to_s
@intervals.to_s
end

def to_frets(offset=0)
frets = [-offset]
i = 0
while(frets.last < @number_of_frets) do
frets << frets.last + @intervals[i % @intervals.length]
i += 1
end
frets
end
end
20 changes: 20 additions & 0 deletions lib/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'paint'

def get_user_input(message)
puts message
gets
end

def get_intervals_from_user
get_user_input('Please type intervals divided by commas (,)')
.delete("\n").split(',').map(&:to_i)
end

def main
GuitarScale.new(
IntervalSequence.new(*get_intervals_from_user)
).print
main
end

main
Empty file added lib/mode.rb
Empty file.
Empty file added lib/note.rb
Empty file.
Empty file added lib/progression.rb
Empty file.
Empty file added lib/scale.rb
Empty file.
Empty file added lib/string.rb
Empty file.
76 changes: 0 additions & 76 deletions main.rb

This file was deleted.

8 changes: 8 additions & 0 deletions spec/lib/chords_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'
require '../../lib/chords'

RSpec.describe Chords do
it 'something' do
puts 'lol'
end
end
Loading

0 comments on commit be9b34e

Please sign in to comment.