caravan 0.3.1 → 0.4.0.beta

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
  SHA1:
3
- metadata.gz: 21f5e8e75b19d676bb4530c970b37eceaa6cab66
4
- data.tar.gz: 10c5083012689210fe745b4ad9e5b7f13e35f217
3
+ metadata.gz: 9e2ece0ac4cc244e44066c307bd42ecc2783ce27
4
+ data.tar.gz: 4c43af6c423ad75213ee3e5d752753b2fa3e44dc
5
5
  SHA512:
6
- metadata.gz: eaf0c5a0d1d4adb039339b82072cf694b83508856e5378e5fb561c1df015212d3d04035a8f1da03f457d5aca4a3020ae59ca0c69c6ad8fa63eeed944bff43fc1
7
- data.tar.gz: f77c3c4033fd6146b1a748871bd164e9adf239a3417b865fa15e2c9a8f7160ff2f63385413602189510b92bebbb3c9e3223899f09b54e53068acdcb9179b3ad9
6
+ metadata.gz: e0b3518e2c18b8b232a77e1662d5a809e3c308cd74f47e809071193f6c0c2718b665eed0343f3f09672f904348e03724ce5f0e189966b35ce1ceeda3811fd5c1
7
+ data.tar.gz: f14925bf61bb43e1eee9edd1b3fd76cf4627fffd0a70310e889eac212d4abccd149112a9f348eda2fa8ec7c4de8b32af1c0fedc9780c9533f15ea58f5ad5c229
data/.gitignore CHANGED
@@ -42,7 +42,7 @@ build-iPhoneSimulator/
42
42
 
43
43
  # for a library or gem, you might want to ignore these files since the code is
44
44
  # intended to run in multiple environments; otherwise, check them in:
45
- # Gemfile.lock
45
+ Gemfile.lock
46
46
  # .ruby-version
47
47
  # .ruby-gemset
48
48
 
data/.travis.yml CHANGED
@@ -2,10 +2,8 @@ language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
4
  - 2.3.0
5
- env:
6
- - CODECLIMATE_REPO_TOKEN: b72ccd136db6874a3d5dd842c50c1dc0933a1f49a02c55ce8567ec7311600af3
7
5
  after_success:
8
- - bundle exec codeclimate-test-reporter
6
+ - CODECLIMATE_REPO_TOKEN=b72ccd136db6874a3d5dd842c50c1dc0933a1f49a02c55ce8567ec7311600af3 bundle exec codeclimate-test-reporter
9
7
  notifications:
10
8
  email: false
11
9
  slack: navyblue-team:ioO5diAGc5WUQVDKc5BH1UbE
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # [Caravan](https://crispgm.github.io/caravan/)
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/caravan.svg)](https://badge.fury.io/rb/Caravan)
3
+ [![Gem Version](https://badge.fury.io/rb/caravan.svg)](https://badge.fury.io/rb/caravan)
4
+ [![](https://api.travis-ci.org/crispgm/gsm.svg)](https://travis-ci.org/crispgm/caravan)
4
5
  [![Code Climate](https://codeclimate.com/github/crispgm/caravan/badges/gpa.svg)](https://codeclimate.com/github/crispgm/caravan)
5
6
  [![Test Coverage](https://codeclimate.com/github/crispgm/caravan/badges/coverage.svg)](https://codeclimate.com/github/crispgm/caravan/coverage)
6
7
 
7
- (WIP) Simple watcher and deployer.
8
+ Simple watcher and deployer.
9
+
10
+ The background is when you are developing in your local workspace and the program only runs in specific runtime. You have to setup by yourself to make the program run and debug on runtime folders or ,remote machines. Caravan is designed for solving such kind of problems by watching the file changes, and deploy them automatically to the its destination.
8
11
 
9
12
  ## Installation
10
13
 
@@ -24,6 +27,15 @@ Example:
24
27
  $ caravan -s /path/to/project/. -d /path/to/deploy -m shell
25
28
  ```
26
29
 
30
+ ## Plan
31
+
32
+ - [x] Basic watching and deploying
33
+ - [x] Exclude watching unwanted files
34
+ - [x] `caravan.yml` for project-specialized configuration
35
+ - [ ] Watch and deploy only the changed file instead of the whole folder
36
+ - [ ] Callback for deployment
37
+ - [ ] Multiple deployment configurations
38
+
27
39
  ## LICENSE
28
40
 
29
41
  [MIT](/LICENSE)
data/_config.yml ADDED
@@ -0,0 +1,3 @@
1
+ theme: jekyll-theme-modernist
2
+ exclude:
3
+ - Gemfile
data/exe/caravan CHANGED
@@ -23,7 +23,11 @@ option_parser = OptionParser.new do |opts|
23
23
  end
24
24
 
25
25
  opts.on("-i IGNORE_FILES", "--ignore IGNORE_FILES", "Ignore files") do |value|
26
- options[:ignore] = value || "\.(git|svn)$"
26
+ if options.key?(:ignore)
27
+ options[:ignore] << value
28
+ else
29
+ options[:ignore] = [value]
30
+ end
27
31
  end
28
32
 
29
33
  options[:debug] = false
@@ -35,8 +39,13 @@ option_parser = OptionParser.new do |opts|
35
39
  puts Caravan::VERSION
36
40
  exit
37
41
  end
38
- end.parse!(ARGV)
42
+ end
43
+
44
+ if ARGV.size == 1 && ARGV[0] == "init"
45
+ Caravan.dump_default_conf
46
+ end
39
47
 
48
+ option_parser.parse!(ARGV)
40
49
  if options.key?(:src) && options.key?(:dst)
41
- Caravan.start(options)
50
+ Caravan.start(options)
42
51
  end
data/lib/caravan.rb CHANGED
@@ -15,53 +15,67 @@ DEFAULT_CONFIG_NAME = "caravan.yml".freeze
15
15
  module Caravan
16
16
  class << self
17
17
  def start(options)
18
- src_path = options[:src]
19
- target_path = options[:dst]
20
- mode = options[:mode]
21
- ignores = options[:ignore]
22
- debug = options[:debug]
18
+ merged_conf = Caravan::Config.merge(options, process_conf(options[:src]))
19
+ src_path = merged_conf["src"]
20
+ target_path = merged_conf["dst"]
21
+ deploy_mode = merged_conf["deploy_mode"]
22
+ ignores = merged_conf["exclude"]
23
+ debug = merged_conf["debug"]
23
24
 
24
- deployer = Deploy.create_deployer(mode)
25
+ Caravan::Config.pretty_puts(merged_conf)
26
+
27
+ deployer = Caravan::Deploy.create_deployer(deploy_mode)
25
28
  deployer.debug = true if debug
26
29
  if deployer.nil?
27
30
  exit -1
28
31
  end
29
32
 
30
- # process_conf
31
-
32
- listener = Listen.to(src_path) do |modified, added, removed|
33
- unless (modified.empty? && added.empty? && removed.empty?)
34
- (added + modified + removed).each do |change|
35
- Message.info("#{change} was changed.")
36
- end
37
-
38
- deployer.run(src_path, target_path)
39
- end
33
+ listener = create_listener(deployer, src_path, target_path)
34
+ ignores.each do |item|
35
+ listener.ignore(Regexp.compile(item))
40
36
  end
41
37
 
42
- listener.ignore(ignores)
43
-
44
- Message.success("Starting to watch #{src_path}...")
38
+ Caravan::Message.success("Starting to watch #{src_path}...")
45
39
  deployer.run(src_path, target_path)
46
40
  listener.start
47
41
 
48
42
  trap("INT") do
49
43
  listener.stop
50
- Message.success("\tHalting watching.")
44
+ Caravan::Message.success("\tHalting watching.")
51
45
  exit 0
52
46
  end
53
47
 
54
48
  sleep_forever
55
49
  end
56
50
 
57
- def process_conf
58
- Message.success("Reading configuration...")
59
- conf = Caravan::Config.from(DEFAULT_CONFIG_NAME)
60
- Config.pretty_puts(conf)
51
+ def create_listener(deployer, src_path, target_path)
52
+ Listen.to(src_path) do |modified, added, removed|
53
+ unless (modified.empty? && added.empty? && removed.empty?)
54
+ (added + modified + removed).each do |change|
55
+ Caravan::Message.info("#{change} was changed.")
56
+ end
57
+
58
+ deployer.run(src_path, target_path)
59
+ end
60
+ end
61
+ end
62
+
63
+ def process_conf(src_path)
64
+ Caravan::Message.success("Reading configuration...")
65
+ user_config_path = File.join(File.expand_path(src_path), DEFAULT_CONFIG_NAME)
66
+ conf = Caravan::Config.from(user_config_path)
67
+ conf
61
68
  end
62
69
 
63
70
  def sleep_forever
64
71
  loop { sleep 1000 }
65
72
  end
73
+
74
+ def dump_default_conf
75
+ user_config_path = File.join(File.expand_path("."), DEFAULT_CONFIG_NAME)
76
+ default_conf = Caravan::Config.default_conf
77
+
78
+ Caravan::Config.dump(user_config_path, default_conf)
79
+ end
66
80
  end
67
81
  end
@@ -3,6 +3,7 @@ require "yaml"
3
3
  module Caravan
4
4
  class Config < Hash
5
5
  DEFAULT_CONFIG = {
6
+ "debug" => false,
6
7
  "deploy_mode" => "rsync_local",
7
8
  "incremental" => true,
8
9
  "exclude" => %w(
@@ -19,20 +20,33 @@ module Caravan
19
20
  if File.exist?(user_config_path)
20
21
  YAML.load_file(user_config_path)
21
22
  else
22
- dump_conf(user_config_path, default_conf)
23
- default_conf
23
+ Caravan::Message.warning("User configuration [caravan.yml] not found.")
24
+ Caravan::Message.warning("Use `caravan init` to generate.")
25
+ default_conf.dup
24
26
  end
25
27
  end
26
28
 
27
- def dump_conf(user_config_path, user_config)
29
+ def dump(user_config_path, user_config)
28
30
  File.open(user_config_path, "w") do |f|
29
31
  f.write(user_config.to_yaml)
30
32
  end
31
33
  end
32
34
 
35
+ def merge(options, conf)
36
+ merged_conf = conf
37
+ merged_conf["src"] = options[:src]
38
+
39
+ merged_conf["dst"] = options[:dst] if options.key?(:dst)
40
+ merged_conf["debug"] = options[:debug] if options.key?(:debug)
41
+ merged_conf["deploy_mode"] = options[:mode] if options.key?(:mode)
42
+ merged_conf["exclude"] = options[:ignore] if options.key?(:ignore)
43
+
44
+ merged_conf
45
+ end
46
+
33
47
  def pretty_puts(conf)
34
48
  conf.each do |k, v|
35
- Message.info(" => #{k}: #{v}")
49
+ Caravan::Message.info("=> #{k}: #{v}")
36
50
  end
37
51
  end
38
52
  end
@@ -3,7 +3,7 @@ require "colorize"
3
3
  module Caravan
4
4
  module Deploy
5
5
  class << self
6
- def create_deployer(method = 'shell')
6
+ def create_deployer(method = "shell")
7
7
  case method
8
8
  when "shell"
9
9
  return Caravan::DeployMethods::Shell.new
@@ -1,3 +1,3 @@
1
1
  module Caravan
2
- VERSION = "0.3.1".freeze
2
+ VERSION = "0.4.0.beta".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caravan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Zhang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-28 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen
@@ -120,12 +120,11 @@ files:
120
120
  - ".travis.yml"
121
121
  - CODE_OF_CONDUCT.md
122
122
  - Gemfile
123
- - Gemfile.lock
124
123
  - LICENSE
125
124
  - README.md
126
125
  - Rakefile
126
+ - _config.yml
127
127
  - caravan.gemspec
128
- - docs/_config.yml
129
128
  - exe/caravan
130
129
  - lib/caravan.rb
131
130
  - lib/caravan/command.rb
@@ -152,9 +151,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
151
  version: '0'
153
152
  required_rubygems_version: !ruby/object:Gem::Requirement
154
153
  requirements:
155
- - - ">="
154
+ - - ">"
156
155
  - !ruby/object:Gem::Version
157
- version: '0'
156
+ version: 1.3.1
158
157
  requirements: []
159
158
  rubyforge_project:
160
159
  rubygems_version: 2.6.11
data/Gemfile.lock DELETED
@@ -1,46 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- Caravan (0.3.0)
5
- colorize
6
- listen
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- codeclimate-test-reporter (1.0.8)
12
- simplecov (<= 0.13)
13
- colorize (0.8.1)
14
- docile (1.1.5)
15
- ffi (1.9.18)
16
- json (2.1.0)
17
- listen (3.1.5)
18
- rb-fsevent (~> 0.9, >= 0.9.4)
19
- rb-inotify (~> 0.9, >= 0.9.7)
20
- ruby_dep (~> 1.2)
21
- minitest (5.10.3)
22
- rake (10.5.0)
23
- rb-fsevent (0.10.2)
24
- rb-inotify (0.9.10)
25
- ffi (>= 0.5.0, < 2)
26
- ruby_dep (1.5.0)
27
- shoulda-context (1.2.2)
28
- simplecov (0.13.0)
29
- docile (~> 1.1.0)
30
- json (>= 1.8, < 3)
31
- simplecov-html (~> 0.10.0)
32
- simplecov-html (0.10.2)
33
-
34
- PLATFORMS
35
- ruby
36
-
37
- DEPENDENCIES
38
- Caravan!
39
- bundler (~> 1.15)
40
- codeclimate-test-reporter (~> 1.0.0)
41
- minitest (~> 5.0)
42
- rake (~> 10.0)
43
- shoulda-context
44
-
45
- BUNDLED WITH
46
- 1.15.4
data/docs/_config.yml DELETED
@@ -1 +0,0 @@
1
- theme: jekyll-theme-modernist