startling 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10286b9e25378a5e77ad448005d7961668606845
4
- data.tar.gz: 0327fb164ccba036d2042bf5bd3a25a985926c2f
3
+ metadata.gz: f8ebd457be41e100906ba33b538480973d89730b
4
+ data.tar.gz: dfba30c257a91102ca69b3b75ec5b4a74aecc234
5
5
  SHA512:
6
- metadata.gz: cbca7e8dd625bd5b54bb7a193e05be0539dcc903305f25f34962fb04f4daccaa42e55c0a5b024d96f71701d908472de68b59826f66ce3fb41b93bf321e75c805
7
- data.tar.gz: 67262bda0568f2c4f1f21c0927a90c8ce3e62536067043159172d3bb468ddde869f02bb50d98bbffabd370da4e97915d46945f26373818c44bcf0771f373c910
6
+ metadata.gz: 26f56b3a79cd2fd4e2ef22bc61266b2cae468248e221a75b982a3bdb57ba7d12e3818eeb8448bad34dd5002efe9aa24613ba2073c6aba45584db1bd6896f32ee
7
+ data.tar.gz: 2b6378cc90dd4ad98a3af97af04ac3b2317cb831e3dbccb3ebc6ab041ca3fbc3354b2fd08b09c0b182cfc2938f6939509d3c5a38cfe61a4ffd2108c311e5662d
@@ -10,7 +10,7 @@ Example:
10
10
  $ start 12345 my branch name
11
11
  USE
12
12
  def self.parse
13
- options = {story_id: nil, branch_name: nil}
13
+ options = {story_id: nil, branch_name: nil, verbose: false}
14
14
  parser = OptionParser.new do |opts|
15
15
  opts.banner = USAGE
16
16
 
@@ -22,6 +22,10 @@ USE
22
22
  options[:branch_name] = branch
23
23
  end
24
24
 
25
+ opts.on('-v', '--verbose', 'Verbose logging') do
26
+ options[:verbose] = true
27
+ end
28
+
25
29
  Startling.cli_options.each do |user_opt|
26
30
  options.merge!(user_opt.sym => nil)
27
31
  opts.on(user_opt.abbr_switch, user_opt.long_switch, user_opt.description) do |value|
@@ -11,18 +11,18 @@ module Startling
11
11
  RUN = "run"
12
12
 
13
13
  def self.run(attrs={})
14
- load_configuration
15
-
16
14
  options = Startling::CliOptions.parse
17
15
  options.merge!(attrs)
18
16
  options.merge({argv: ARGV, args: ARGV})
19
17
 
20
- load_commands
21
- load_handlers
22
18
  super(options)
23
19
  end
24
20
 
25
21
  def execute
22
+ load_configuration
23
+ load_commands
24
+ load_handlers
25
+
26
26
  command_args = cli_options.merge(git: git)
27
27
 
28
28
  check_for_local_mods
@@ -1,7 +1,9 @@
1
+ require 'logger'
2
+
1
3
  module Startling
2
4
  module Commands
3
5
  class Base
4
- attr_reader :cli_options
6
+ attr_reader :cli_options, :logger
5
7
 
6
8
  def self.run(attrs={})
7
9
  new(attrs).execute
@@ -13,32 +15,36 @@ module Startling
13
15
  self.class.__send__(:attr_reader, attr)
14
16
  instance_variable_set("@#{attr}", value)
15
17
  end
18
+
19
+ @logger = Logger.new(STDOUT)
20
+ @logger.formatter = -> (severity, datetime, progname, msg) { "#{msg}\n" }
21
+ @logger.level = (attrs[:verbose]) ? Logger::DEBUG : Logger::INFO
16
22
  end
17
23
 
18
24
  def execute
19
25
  raise NotImplementedError
20
26
  end
21
27
 
22
- def self.load_configuration
28
+ def load_configuration
23
29
  loaded_configuration_path = Startling::Configuration.load_configuration
24
30
  if loaded_configuration_path
25
- puts "Loading configuration #{loaded_configuration_path}"
31
+ logger.debug "Loading configuration #{loaded_configuration_path}"
26
32
  else
27
- puts "Using default configuration"
33
+ logger.debug "Using default configuration"
28
34
  end
29
35
  end
30
36
 
31
- def self.load_commands
37
+ def load_commands
32
38
  loaded_commands_path = Startling::Configuration.load_commands
33
39
  if loaded_commands_path
34
- puts "Loading commands #{loaded_commands_path}"
40
+ logger.debug "Loading commands #{loaded_commands_path}"
35
41
  end
36
42
  end
37
43
 
38
- def self.load_handlers
44
+ def load_handlers
39
45
  loaded_handlers_path = Startling::Configuration.load_handlers
40
46
  if loaded_handlers_path
41
- puts "Loading handlers #{loaded_handlers_path}"
47
+ logger.debug "Loading handlers #{loaded_handlers_path}"
42
48
  end
43
49
  end
44
50
 
@@ -61,13 +67,13 @@ module Startling
61
67
  end
62
68
 
63
69
  def print_name_error_message(name, path)
64
- puts "Error loading #{to_camel_case(name.to_s)}. Is it defined in #{path}?"
70
+ logger.fatal "Error loading #{to_camel_case(name.to_s)}. Is it defined in #{path}?"
65
71
  end
66
72
 
67
73
  def print_args(context)
68
- puts "== Instance vars from #{context} ==>"
74
+ logger.debug "== Instance vars from #{context} ==>"
69
75
  instance_variables.each do |var|
70
- puts "#{var}: #{instance_variable_get(var)}"
76
+ logger.debug "#{var}: #{instance_variable_get(var)}"
71
77
  end
72
78
  end
73
79
 
@@ -8,7 +8,7 @@ module Startling
8
8
  def execute
9
9
  return if git.status.empty?
10
10
 
11
- puts "Local modifications detected, please stash or something."
11
+ logger.fatal "Local modifications detected, please stash or something."
12
12
  system("git status -s")
13
13
  exit 1
14
14
  end
@@ -10,7 +10,7 @@ module Startling
10
10
  using ColorizeString
11
11
 
12
12
  def execute
13
- puts "Checking WIP..."
13
+ logger.info "Checking WIP..."
14
14
  wip = Work.in_progress
15
15
  if wip.count >= Startling.wip_limit
16
16
  WorkPrinter.new.print wip
@@ -17,7 +17,7 @@ module Startling
17
17
  end
18
18
 
19
19
  def create_branch
20
- puts "Creating branch #{branch_name}..."
20
+ logger.info "Creating branch #{branch_name}..."
21
21
  git.create_remote_branch(branch_name, base_branch: "origin/#{default_branch}")
22
22
  end
23
23
 
@@ -14,7 +14,7 @@ module Startling
14
14
  end
15
15
 
16
16
  def open_pull_request
17
- puts "Opening pull request..."
17
+ logger.info "Opening pull request..."
18
18
 
19
19
  if git.current_branch_has_no_commits?
20
20
  git.create_empty_commit(pull_request_handler.commit_message)
@@ -25,7 +25,7 @@ module Startling
25
25
  pull_request = repo.open_pull_request title: pull_request_handler.title,
26
26
  body: pull_request_handler.body, branch: @branch_name
27
27
 
28
- puts pull_request.url if pull_request
28
+ logger.info pull_request.url if pull_request
29
29
 
30
30
  pull_request
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module Startling
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -58,7 +58,7 @@ CONFIG
58
58
 
59
59
  File.open('startlingfile.rb', 'w') { |file| file.write(local_configuration) }
60
60
 
61
- Startling::Commands::Base.load_configuration
61
+ Startling::Configuration.load_configuration
62
62
 
63
63
  test_repo_path = "tmp/test_repo"
64
64
  FileUtils.mkdir_p "tmp"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Jensen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-22 00:00:00.000000000 Z
13
+ date: 2016-02-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler