divide 0.1.2 → 0.1.3

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: 678c35e63c08b2bdc34ce6555ba2229ba92a155a
4
- data.tar.gz: 3c585343af64d9c2cf868e61c00a6bc902ce6d60
3
+ metadata.gz: a512929f2f51c821651729499f439bcadda9fcfd
4
+ data.tar.gz: 7d08b96c59baca380ed17ae956003679fcfbd1d2
5
5
  SHA512:
6
- metadata.gz: fa3c9bf15bf71dc747e29f1628e348d77694485f79f27a126de4a5676e14d368eb77ec650beed49edcb57b76b7d7bfb5f7425c94e62dde83793522494b4a4ea6
7
- data.tar.gz: 42d1b2f90d05c3adcb16684bce08b4546c12807f2719b12b678714dd2ad08becf93aa5176d974d124082e142c75203a6d99fa1b842382adb15ca4217c71c07d1
6
+ metadata.gz: b1ce6bd4737fb526789730cbd9693917149c8878714a37f4c794a004c8ac364894aefc5af85f6725e4dfebe778af22bfb44092dd37b704b6f1f3c8e692db97a5
7
+ data.tar.gz: 3aa4ee48ea7f797dc79b399988710558ad2c429d275b1a60fa60a676b8b47e263822f405f19ca31914bd4c1d2b774d75d6c0585140c9aaee8a53e891916d5e07
data/README.md CHANGED
@@ -57,6 +57,9 @@ $ divide
57
57
  ```
58
58
 
59
59
  ## Changelog
60
+ ### 0.1.3
61
+ - Add :from option
62
+
60
63
  ### 0.1.2
61
64
  - Ignore `.env` file comments
62
65
 
data/bin/divide CHANGED
@@ -3,4 +3,4 @@
3
3
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
4
 
5
5
  require 'divide'
6
- Divide::CLI.new(ARGV)
6
+ Divide::CLI.new(ARGV.dup)
@@ -1,12 +1,36 @@
1
1
  module Divide
2
2
  class CLI
3
3
  attr_reader :options, :flags
4
- OPTIONS = %w(--tabs)
4
+ OPTIONS = %w(--tabs? --no-new-tab? --from)
5
5
 
6
6
  def initialize(argv=[])
7
7
  @options = {}
8
- OPTIONS.each { |option| @options[option.sub('--', '').to_sym] = argv.include?(option) }
9
- @flags = (argv - OPTIONS).each_slice(2).to_a
8
+ OPTIONS.each do |option|
9
+ is_boolean = option =~ /\?$/
10
+ option_name = option.sub('--', '')
11
+
12
+ if is_boolean
13
+ option.sub!(/\?$/, '')
14
+ option_name.sub!(/\?$/, '')
15
+
16
+ @options[option_name.to_sym] = argv.include?(option)
17
+ argv.delete(option)
18
+ elsif argv.include?(option)
19
+ value_index = argv.index(option) + 1
20
+
21
+ @options[option_name.to_sym] = argv[value_index]
22
+ argv.delete_at(value_index)
23
+ argv.delete(option)
24
+ end
25
+ end
26
+
27
+ if from = @options[:from]
28
+ @options[:from] = "#{Dir.pwd}/#{from}"
29
+ else
30
+ @options[:from] = Dir.pwd
31
+ end
32
+
33
+ @flags = (argv).each_slice(2).to_a
10
34
 
11
35
  show_version if argv.grep(/^-v|--version$/).any?
12
36
  show_help if argv.grep(/^-h|--help$/).any?
@@ -69,7 +93,7 @@ module Divide
69
93
  end
70
94
 
71
95
  def extractor
72
- @extractor ||= Extractor.new(@flags)
96
+ @extractor ||= Extractor.new(@flags, @options)
73
97
  end
74
98
  end
75
99
  end
@@ -4,24 +4,25 @@ module Divide
4
4
  class Extractor
5
5
  DEFAULT_ENV = { 'PORT' => '5000' }.merge(ENV)
6
6
 
7
- def initialize(options=[])
7
+ def initialize(flags = [], options = {})
8
+ @flags = flags
8
9
  @options = options
9
10
 
10
11
  overwrite_env_variables
11
- overwrite_options
12
+ overwrite_flags
12
13
  escape_double_quotes
13
14
  end
14
15
 
15
16
  def procfile_content
16
- @procfile_content ||= File.read('./Procfile') rescue ''
17
+ @procfile_content ||= File.read("#{@options[:from]}/Procfile") rescue ''
17
18
  end
18
19
 
19
20
  def env_content
20
- @env_content ||= File.read('./.env') rescue ''
21
+ @env_content ||= File.read("#{@options[:from]}/.env") rescue ''
21
22
  end
22
23
 
23
- def overwrite_options
24
- @options.each do |option|
24
+ def overwrite_flags
25
+ @flags.each do |option|
25
26
  next if option.length < 2
26
27
 
27
28
  key = option[0]
@@ -35,7 +35,7 @@ module Divide
35
35
  end
36
36
 
37
37
  def go_to_current_directory
38
- do_script "cd #{Dir.pwd}"
38
+ do_script "cd #{@options[:from]}"
39
39
  end
40
40
 
41
41
  def keystroke(key)
@@ -62,7 +62,8 @@ module Divide
62
62
 
63
63
  scripts = commands.map { |c| do_script(c) }
64
64
  scripts_with_new_tabs = insert_between(scripts, open_new_tab_in_current_directory).flatten
65
- scripts_with_new_tabs << open_new_tab_in_current_directory
65
+ scripts_with_new_tabs.unshift(open_new_tab_in_current_directory) unless @options[:from] == Dir.pwd
66
+ scripts_with_new_tabs.push(open_new_tab_in_current_directory) unless @options[:'no-new-tab']
66
67
 
67
68
  bridge.apple_script(scripts_with_new_tabs)
68
69
  end
@@ -1,3 +1,3 @@
1
1
  module Divide
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Etienne Lemay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-12 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake