coltrane 4.0.5 → 4.0.6

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
  SHA256:
3
- metadata.gz: 8412a5eacbab879b926a8754d15d5fd0e38be905c8d7352db107aad5d4598ab8
4
- data.tar.gz: 2f60c931dc63ca0dea2eee00be6c78b45ee8303d737af3ccc1eca93f567d7d32
3
+ metadata.gz: c3e26972df8988b780fba7a447408cfb7c5c80e2852ecc605bc2fe71bf056890
4
+ data.tar.gz: 4bf04233585e2c2a284e914444d9d293c068f5cd5b0e731ec398bf5bacfdf371
5
5
  SHA512:
6
- metadata.gz: 1fdd2e8aef21c73f2a7a127031ba1079c451a9cc5e85f3cb559818b97eee106a53d3098115814b8c8268abda85468b85c151f608032b36e86be8882d4b132918
7
- data.tar.gz: 62a50cb05ab3439d565f6714d0d0ffde2886c5b85409929cd535f80634e3303de98ec7e7ae5e5e26379180acbca10e48cc4062c854fe0c9bc203135cb7d22143
6
+ metadata.gz: c4962377b0bf4b64a956b6a02c9b3241b58386c06399f373e99401d50973403c9b1c97f21c0c6cf0848081d992305cba5d2f63cfac2bdb16f235eddc95e630ab
7
+ data.tar.gz: 2e2bdd93920af71911f1dd6a45077f5f116e975765d2cf46caeb4de0cd9a2369119fb22cb8e78429f5a1e2682cc6a515675d2e5722fdaa4b480612df20cffeac
data/.DS_Store CHANGED
Binary file
@@ -5,6 +5,9 @@
5
5
  - Fix chords so that they generate a barre and a non-barre version and prevent
6
6
  barre chords from picking notes before the barre.
7
7
 
8
+ ## [4.0.6]
9
+ - Change the CLI into a more intuitive one
10
+
8
11
  ## [4.0.0]
9
12
  - Includes totally revamped, easy to use command line interface.
10
13
 
data/Gemfile CHANGED
@@ -15,4 +15,4 @@ group :test do
15
15
  gem 'rubocop', require: false
16
16
  end
17
17
 
18
- gemspec
18
+ gemspec
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coltrane (4.0.5)
4
+ coltrane (4.0.6)
5
5
  activesupport (> 5.2)
6
- cli-ui (~> 1.1)
7
6
  color (~> 1.8)
8
7
  dry-monads (~> 0.4)
8
+ gambiarra (~> 0)
9
9
  paint (~> 2.0)
10
10
 
11
11
  GEM
@@ -31,6 +31,10 @@ GEM
31
31
  dry-core (~> 0.3, >= 0.3.3)
32
32
  dry-equalizer
33
33
  equatable (0.5.0)
34
+ gambiarra (0.0.1)
35
+ activesupport (> 5.2)
36
+ cli-ui (~> 1.1)
37
+ thor (= 0.20)
34
38
  hike (1.2.3)
35
39
  hitimes (1.2.6)
36
40
  i18n (1.1.1)
@@ -93,6 +97,7 @@ GEM
93
97
  sprockets (3.7.1)
94
98
  concurrent-ruby (~> 1.0)
95
99
  rack (> 1, < 3)
100
+ thor (0.20.0)
96
101
  thread_safe (0.3.6)
97
102
  tilt (2.0.8)
98
103
  timers (4.1.2)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'gambiarra' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("gambiarra", "gambiarra")
data/bin/thor CHANGED
@@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
15
15
  bundle_binstub = File.expand_path("../bundle", __FILE__)
16
16
 
17
17
  if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
19
  load(bundle_binstub)
20
20
  else
21
21
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
@@ -33,9 +33,9 @@ Gem::Specification.new do |spec|
33
33
  spec.require_paths = ["lib"]
34
34
 
35
35
  spec.add_runtime_dependency 'dry-monads', '~> 0.4'
36
+ spec.add_runtime_dependency 'gambiarra', '~> 0'
36
37
  spec.add_runtime_dependency 'paint', '~> 2.0'
37
38
  spec.add_runtime_dependency 'color', '~> 1.8'
38
- spec.add_runtime_dependency 'cli-ui', '~> 1.1'
39
39
  spec.add_runtime_dependency 'activesupport', '> 5.2'
40
40
  spec.add_development_dependency "bundler", '~> 1.14'
41
41
  spec.add_development_dependency "rake", '~> 10.0'
@@ -6,10 +6,8 @@ require 'coltrane/ui'
6
6
 
7
7
  module Coltrane
8
8
  module UI
9
- class App
10
- attr_reader :router
11
-
12
- def self.start(initial_route)
9
+ class App < Gambiarra::App
10
+ def setup
13
11
  if ENV['COLORTERM'] == 'truecolor'
14
12
  Paint.mode = 0xFFFFFF
15
13
  else
@@ -18,75 +16,6 @@ module Coltrane
18
16
  "Try something like iTerm2 (for macOS), VTE or Konsole (for linux) or Hyper" \
19
17
  " (for Windows) and you'll see the true magic!"
20
18
  end
21
-
22
- path, params = initial_route.split(' ').each_with_object([nil, {}]) do |segment, memo|
23
- if segment =~ /:/
24
- key, value = segment.split(':')
25
- memo[1].merge!([[key.to_sym, value.gsub('-', ' ')]].to_h)
26
- else
27
- memo[0] = [memo[0], segment].compact.join(' ')
28
- end
29
- end
30
-
31
- response = {path: (path || ''), **params}
32
- loop { response = app.flow(**response) }
33
- end
34
-
35
- def self.app
36
- @app ||= new
37
- end
38
-
39
- def initialize
40
- @router = Router.new
41
- end
42
-
43
- def ask_questions(questions)
44
- questions.map { |name, question| [name, ask_question(question)] }.to_h
45
- end
46
-
47
- def ask_question(question)
48
- CLI::UI::Prompt.ask(question[:statement], options: question[:options])
49
- end
50
-
51
- def navigation(params)
52
- return {} if params.empty?
53
- CLI::UI::Prompt.ask('What to do now?') do |h|
54
- params.each do |key, _value|
55
- h.option("Different #{key}") { params[key] = nil }
56
- end
57
- h.option("Go back") { params[:path] = '' }
58
- end
59
- params
60
- end
61
-
62
- def output(response)
63
- return unless response[:content]
64
- puts [
65
- nil,
66
- "-> coltrane #{router.url}",
67
- nil,
68
- response[:content],
69
- nil
70
- ]
71
- end
72
-
73
- def flow(response)
74
- raise 'Response is empty' unless response
75
- output(response)
76
- response.delete(:content)
77
- questions = response&.delete(:questions) || {}
78
- response.merge!(navigation(response)) unless response.has_key?(:path) || questions.any?
79
- response.merge!(ask_questions(questions)) if questions.any?
80
- exit if response[:path] == 'exit'
81
- router.get(**response.compact)
82
- rescue => e
83
- response.delete(:path)
84
- puts e
85
- retry
86
- end
87
-
88
- def exit
89
- Kernel.exit(0)
90
19
  end
91
20
  end
92
21
  end
Binary file
@@ -1,9 +1,8 @@
1
- require 'active_support/inflector'
2
1
  require 'paint'
3
2
  require 'color'
4
- require 'cli/ui' # shopify cli
5
3
 
6
- require 'coltrane'
4
+ require 'gambiarra'
7
5
  require 'coltrane/commands'
8
- require 'coltrane/ui/views'
9
- require 'coltrane/ui/router'
6
+
7
+ require File.expand_path('../ui/base_view', __FILE__)
8
+ views = Dir[File.expand_path('../ui/views/*', __FILE__)].map { |view| require(view) }
Binary file
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module UI
3
+ class BaseView < Gambiarra::View
4
+ def self.render(view)
5
+ Commands::Render.run(view.render)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class Chords < View
4
+ class Chords < BaseView
5
5
  questions({
6
6
  path: {
7
7
  statement: 'What do you need',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class CustomProgression < View
4
+ class CustomProgression < BaseView
5
5
  questions({
6
6
  progression_notation: {
7
7
  statement: 'What is the progression? (Ex: I-vi-IV-V)'
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindChordByNotes < View
4
+ class FindChordByNotes < BaseView
5
5
  questions({
6
6
  notes: { statement: 'Which Notes?' }
7
7
  })
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindCommonChordsInScales < View
4
+ class FindCommonChordsInScales < BaseView
5
5
  questions({
6
6
  first_scale: {
7
7
  statement: 'Choose the first scale',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindProgressionsFromChords < View
4
+ class FindProgressionsFromChords < BaseView
5
5
  questions chords: { statement: 'Type the chords? (Ex: CM EM GM)' }
6
6
 
7
7
  def render
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindScale < View
4
+ class FindScale < BaseView
5
5
  questions({
6
6
  path: {
7
7
  statement: 'How do you wanna search',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindScaleByChords < View
4
+ class FindScaleByChords < BaseView
5
5
  questions({
6
6
  chords: { statement: 'Which Chords?' }
7
7
  })
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class FindScaleByNotes < View
4
+ class FindScaleByNotes < BaseView
5
5
  questions({
6
6
  notes: { statement: 'Which Notes?' }
7
7
  })
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class Index < View
4
+ class Index < BaseView
5
5
  questions({
6
6
  path: {
7
7
  statement: "Welcome to Coltrane #{Coltrane::VERSION}",
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class Notes < View
4
+ class Notes < BaseView
5
5
  questions({
6
6
  notes: { statement: 'Which notes?' } ,
7
7
  representation: {
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class Progressions < View
4
+ class Progressions < BaseView
5
5
  questions({
6
6
  path: {
7
7
  statement: 'What do you need?',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class Scales < View
4
+ class Scales < BaseView
5
5
  questions({
6
6
  path: {
7
7
  statement: 'What do you need?',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class ShowChord < View
4
+ class ShowChord < BaseView
5
5
  questions({
6
6
  chord: { statement: 'Which chord?' },
7
7
  chord_representation: {
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class ShowProgression < View
4
+ class ShowProgression < BaseView
5
5
  questions({
6
6
  progression: {
7
7
  statement: 'What is the progression?',
@@ -1,7 +1,7 @@
1
1
  module Coltrane
2
2
  module UI
3
3
  module Views
4
- class ShowScale < View
4
+ class ShowScale < BaseView
5
5
  questions({
6
6
  scale: {
7
7
  statement: 'Which Scale?',
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coltrane
4
- VERSION = '4.0.5'
4
+ VERSION = '4.0.6'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coltrane
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.5
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Maciel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-17 00:00:00.000000000 Z
11
+ date: 2018-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-monads
@@ -25,47 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: paint
28
+ name: gambiarra
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: color
42
+ name: paint
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.8'
47
+ version: '2.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.8'
54
+ version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: cli-ui
56
+ name: color
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.1'
61
+ version: '1.8'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.1'
68
+ version: '1.8'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -142,6 +142,7 @@ files:
142
142
  - bin/console
143
143
  - bin/erubis
144
144
  - bin/flay
145
+ - bin/gambiarra
145
146
  - bin/gitlab
146
147
  - bin/guard
147
148
  - bin/htmldiff
@@ -258,8 +259,8 @@ files:
258
259
  - lib/coltrane/theory/voicing.rb
259
260
  - lib/coltrane/ui.rb
260
261
  - lib/coltrane/ui/.DS_Store
261
- - lib/coltrane/ui/router.rb
262
- - lib/coltrane/ui/views.rb
262
+ - lib/coltrane/ui/base_view.rb
263
+ - lib/coltrane/ui/views/.DS_Store
263
264
  - lib/coltrane/ui/views/chords.rb
264
265
  - lib/coltrane/ui/views/custom_progression.rb
265
266
  - lib/coltrane/ui/views/find_chord_by_notes.rb
@@ -276,7 +277,6 @@ files:
276
277
  - lib/coltrane/ui/views/show_chord.rb
277
278
  - lib/coltrane/ui/views/show_progression.rb
278
279
  - lib/coltrane/ui/views/show_scale.rb
279
- - lib/coltrane/ui/views/view.rb
280
280
  - lib/coltrane/version.rb
281
281
  - lib/core_ext.rb
282
282
  homepage: http://github.com/pedrozath/coltrane
@@ -300,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
300
  version: '0'
301
301
  requirements: []
302
302
  rubyforge_project:
303
- rubygems_version: 2.7.6
303
+ rubygems_version: 2.7.7
304
304
  signing_key:
305
305
  specification_version: 4
306
306
  summary: It deals with all sorts of calculations around music theory and allows for
@@ -1,86 +0,0 @@
1
- module Coltrane
2
- module UI
3
- class Router
4
- class Route
5
- attr_reader :path, :view, :last
6
- attr_accessor :params
7
-
8
- def initialize(path, to:, with: {})
9
- @path = path
10
- @view = to
11
- @params = with
12
- end
13
-
14
- def render(**other_params)
15
- view.render(**params, **other_params)
16
- end
17
- end
18
-
19
- class History
20
- attr_reader :routes
21
-
22
- def initialize
23
- @routes = []
24
- end
25
-
26
- def add(route)
27
- @routes << route
28
- end
29
-
30
- def previous
31
- routes[-2]&.path || ''
32
- end
33
-
34
- def current_route
35
- routes[-1]
36
- end
37
-
38
- def back
39
- routes.pop.render
40
- end
41
-
42
- def refresh(params={})
43
- current_route.render(params)
44
- end
45
- end
46
-
47
- attr_reader :path, :params, :routes, :history, :url
48
-
49
- def initialize
50
- @routes = []
51
- @history = History.new
52
-
53
- draw_route '', to: Coltrane::UI::Views::Index
54
- Views.constants.each do |view|
55
- draw_route view.to_s.underscore.humanize.downcase, to: "Coltrane::UI::Views::#{view}".constantize
56
- end
57
- end
58
-
59
- def get(**params)
60
- path = params.delete(:path)
61
- @url = build_url(path || history.current_route.path, **params)
62
- route = @routes.detect { |route| route.path == path }
63
- return history.refresh(params) unless route
64
- history.add(route)
65
- route.render(**params)
66
- end
67
-
68
- def build_url(path, params)
69
- [
70
- path,
71
- (params || {}).map do |k,v|
72
- [k,v.gsub(' ', '-')].join(':')
73
- end
74
- ].compact.join(' ')
75
- end
76
-
77
- def previous_path
78
- history.previous
79
- end
80
-
81
- def draw_route(*args, **keyword_args, &block)
82
- @routes << Route.new(*args, **keyword_args, &block)
83
- end
84
- end
85
- end
86
- end
@@ -1,4 +0,0 @@
1
- require 'coltrane/ui/views/view'
2
- Dir[File.expand_path('../views/*', __FILE__)].map do |f|
3
- require(f)
4
- end
@@ -1,48 +0,0 @@
1
- module Coltrane
2
- module UI
3
- module Views
4
- class View
5
- attr_reader :params, :path
6
-
7
- class << self
8
- def inherited(subclass)
9
- @questions ||= {}
10
- subclass.instance_variable_set(:@questions, @questions.deep_dup)
11
- end
12
-
13
- def questions(question_data)
14
- @questions.merge!(question_data)
15
- @questions.compact!
16
- end
17
-
18
- def set_path(value)
19
- @params[:path] = value
20
- end
21
-
22
- def render(**params)
23
- remaining_questions = @questions.slice(*(@questions.keys - params.keys))
24
- return { questions: remaining_questions, **params } if remaining_questions.any?
25
- view = new(**params)
26
- { content: Commands::Render.run(view.render), **params }
27
- end
28
- end
29
-
30
- def initialize(**params)
31
- @params = params
32
- end
33
-
34
- def output(object)
35
- self.class.output(object)
36
- end
37
-
38
- def go_to(path, **params)
39
- # App.router.set_next(path, **params) and return
40
- end
41
-
42
- def ensure_param(param_name, &block)
43
- @params[param_name] = block.call if @params[param_name].nil?
44
- end
45
- end
46
- end
47
- end
48
- end