canoe 0.3.3.2 → 0.3.3.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
  SHA256:
3
- metadata.gz: 74d6ddb337f4f8d2b52f18e5f6d3f2925211481dd5ad139ba555675bf434d356
4
- data.tar.gz: 9828b9850dc35c90ba98a93f3b63a53df1ac102ba0c3c5ae41716f1f670e702d
3
+ metadata.gz: e7002afc65c5738fb7929e1b81cc491b9d7a7196b2ada01f3b6f580ccfe25133
4
+ data.tar.gz: 48632ed95d610599712de7f84fbfb8108c1195d9460cf1a96b8b22cccb59891c
5
5
  SHA512:
6
- metadata.gz: bbd6271cff5a4a5c6342918b9b9c1420216016d185a8979d7d177ce78a3e01e26d4984dc69c90aec0706824fd14e6be0dd9cfb1fb612988bad9412241e16326f
7
- data.tar.gz: 0e39977c7d620b0cc5b8fc55ab9e6b79049c9ca01534e75ef2f856d5fd2005e56102337aeb19e34800d948058e83c6e74af54e51bf6f646fe61edbd002e14c40
6
+ metadata.gz: fa9c3ccf050acd66acd89bdc4b7f4fc280c68e926be7d027cfbb44cecf9f89b51aa7b61b44269f6f7d4a2c2524f4b67e65ba507a074824bba7018940dfb19d82
7
+ data.tar.gz: 23f4cd1c8e5bb9e57d8bda28974366d7486efca3a5d7c275c1042a27a7c039dd80e699d792330417647a72b3615ba164aba502c7e16097a549fd16b41fc45135
data/lib/canoe.rb CHANGED
@@ -3,20 +3,11 @@ require_relative 'cmd'
3
3
  require_relative 'source_files'
4
4
 
5
5
  module Canoe
6
+ ##
7
+ # Main class for building a canoe project
6
8
  class Builder
7
9
  def initialize
8
- options = ['new',
9
- 'add',
10
- 'build',
11
- 'generate',
12
- 'make',
13
- 'run',
14
- 'dep',
15
- 'clean',
16
- 'version',
17
- 'help',
18
- 'update',
19
- 'test']
10
+ options = %w[new add build generate make run dep clean version help update test]
20
11
  @cmd = CmdParser.new options
21
12
  end
22
13
 
data/lib/dependence.rb CHANGED
@@ -1,19 +1,17 @@
1
1
  require_relative 'source_files'
2
2
  require_relative 'util'
3
- ##
4
- # class DepAnalyzer
5
- # This class is the key component of canoe, which offers file dependency analysis functionality.
6
- # A DepAnalyzer takes a directory as input, sources files and corresponding header files in this
7
- # directory should have same name, e.g. test.cpp and test.hpp.
8
- # DepAnalyzer would read every source file and recursively process user header files included in this source file to
9
- # find out all user header files this source file depends on.
10
- # Based on dependencies built in previous stage, DepAnalyzer determines which files should be recompiled and return
11
- # these files to caller.
12
- #
13
- # Dependencies could be written to a file to avoid wasting time parsing all files, Depanalyzer would read from
14
- # this file to construct dependencies. But if sources files included new headers or included headers are revmoed,
15
- # Depanalyzer should rebuild the whole dependencies.
16
3
  module Canoe
4
+ ##
5
+ # This class is the key component of canoe, which offers file dependency analysis functionality.
6
+ #
7
+ # A DepAnalyzer takes a directory as input, sources files and corresponding header files in this
8
+ # directory should have same name, e.g. test.cpp and test.hpp. DepAnalyzer would read every source file and
9
+ # recursively process user header files included in this source file to find out all user header files this
10
+ # source file depends on. Based on dependencies built in previous stage, DepAnalyzer determines which files
11
+ # should be recompiled and return these files to caller. Dependencies could be written to a file to avoid
12
+ # wasting time parsing all files, Depanalyzer would read from this file to construct dependencies. But if
13
+ # sources files included new headers or included headers are revmoed, Depanalyzer should rebuild the whole
14
+ # dependencies.
17
15
  class DepAnalyzer
18
16
  include Err
19
17
  include SystemCommand
data/lib/source_files.rb CHANGED
@@ -13,13 +13,11 @@ class SourceFiles
13
13
  @files = []
14
14
  Dir.each_child(dir) do |f|
15
15
  file = "#{dir}/#{f}"
16
- if File.file? file
17
- if block_given?
18
- @files << file.to_s if yield(f)
19
- else
20
- @files << file.to_s
21
- end
22
- end
16
+ next unless File.file?(file)
17
+
18
+ add = true
19
+ add = yield(f) if block_given?
20
+ @files << file.to_s if add
23
21
  end
24
22
 
25
23
  @files
@@ -32,13 +30,11 @@ class SourceFiles
32
30
  file = "#{dir}/#{f}"
33
31
  # we don't handle symlinks
34
32
  if File.file? file
35
- if block_given?
36
- @files << "#{file}" if yield(f)
37
- else
38
- @files << "#{file}"
39
- end
33
+ add = true
34
+ add = yield(f) if block_given?
35
+ @files << file if add
40
36
  elsif File.directory? file
41
- get_all_helper("#{file}", &block)
37
+ get_all_helper(file, &block)
42
38
  end
43
39
  end
44
40
  end
data/lib/util.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # Many useful classes to record compiling progress, change file's name and issueing system commands
1
2
  require_relative 'coloring'
2
3
 
3
4
  require 'English'
@@ -59,6 +60,8 @@ module Canoe
59
60
  end
60
61
  end
61
62
 
63
+ ##
64
+ # issueing system commands by accepting a command string
62
65
  module SystemCommand
63
66
  def issue_command(cmd_str)
64
67
  puts cmd_str
@@ -72,7 +75,9 @@ module Canoe
72
75
  status
73
76
  end
74
77
  end
75
-
78
+
79
+ ##
80
+ # Colorized error messages with abortion
76
81
  module Err
77
82
  def warn_on_err(err)
78
83
  puts <<~ERR
data/lib/workspace/add.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Canoe
2
+ # WorkSpace implementation
2
3
  class WorkSpace
3
4
  def add(args)
4
5
  args.each do |i|
@@ -90,7 +90,7 @@ module Canoe
90
90
 
91
91
  files.each do |f|
92
92
  o = file_to_obj(f)
93
- flag = false unless compile f, o
93
+ flag &= compile f, o
94
94
  end
95
95
 
96
96
  abort_on_err("Compiling errors encountered") unless flag;
@@ -2,7 +2,7 @@ module Canoe
2
2
  class WorkSpace
3
3
  def self.version
4
4
  puts <<~VER
5
- canoe v0.3.3.2
5
+ canoe v0.3.3.3
6
6
  For features in this version, please visit https://github.com/Dicridon/canoe
7
7
  Currently, canoe can do below:
8
8
  - project creation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3.2
4
+ version: 0.3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - XIONG Ziwei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2021-12-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |+
14
14
  Canoe offers project management and building facilities to C/C++ projects.