swift-gist 0.0.2 → 0.0.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 +4 -4
- data/Gemfile.lock +1 -1
- data/bin/swift-gist +5 -1
- data/lib/swift/gist/cli.rb +29 -0
- data/lib/swift/gist/{watcher.rb → file_watcher.rb} +1 -3
- data/lib/swift/gist/runner.rb +27 -14
- data/lib/swift/gist/stdin_watcher.rb +11 -0
- data/lib/swift/gist/version.rb +1 -1
- data/lib/swift/gist.rb +2 -1
- data/swift-gist.gemspec +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce8536fe946be19b7b6f904f8b24fd884b0d7a8
|
4
|
+
data.tar.gz: 5fbc98be03c1be06a726e87ba4c8535fa33600c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82dbb712dbc77a88db8a355e2f3aebf6d9fd33954cb2d15e31d6f57302847fdb3b16d6f706e4e2c45662d55d7ad70c84617696c22ec4ae07880b2031cad6be0c
|
7
|
+
data.tar.gz: 69bc72e5d7cd2111fbd060254db10f89bd28b9fdfe77987caf9692832f02f8f1e624ae27cfa2fe9654aaeb868fddd30a5635662593d55c88b7eaeeea0a0011d8
|
data/Gemfile.lock
CHANGED
data/bin/swift-gist
CHANGED
data/lib/swift/gist/cli.rb
CHANGED
@@ -2,11 +2,27 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module Swift
|
4
4
|
module Gist
|
5
|
+
class CLIError < StandardError
|
6
|
+
attr_accessor :reason
|
7
|
+
|
8
|
+
def initialize reason
|
9
|
+
self.reason = reason
|
10
|
+
end
|
11
|
+
end
|
5
12
|
|
6
13
|
# The CLI creates a new module for every `--module` or `--test-module`
|
7
14
|
# argument. The `--source` and `--depends-on` arguments are all applied
|
8
15
|
# to the last defined swift module.
|
9
16
|
def self.parse_command_line_arguments arguments
|
17
|
+
unless arguments.count > 0
|
18
|
+
error = CLIError.new(<<REASON
|
19
|
+
Usage: swift-gist [--module[=<name>]] [--test-module[=<name>]]
|
20
|
+
[--source[=<glob>]] [--depends-on[=<module name>]]
|
21
|
+
REASON
|
22
|
+
)
|
23
|
+
raise error
|
24
|
+
end
|
25
|
+
|
10
26
|
swift_modules = []
|
11
27
|
|
12
28
|
OptionParser.new do |parser|
|
@@ -15,6 +31,10 @@ module Swift
|
|
15
31
|
end
|
16
32
|
|
17
33
|
parser.on('--source SOURCE') do |source|
|
34
|
+
if swift_modules.last.nil?
|
35
|
+
raise CLIError.new("Error: The `--source` argument requires that a `--module` or `--test-module` has already been defined.")
|
36
|
+
end
|
37
|
+
|
18
38
|
swift_modules.last.sources |= Dir[source]
|
19
39
|
end
|
20
40
|
|
@@ -23,10 +43,19 @@ module Swift
|
|
23
43
|
end
|
24
44
|
|
25
45
|
parser.on('--depends-on MODULE') do |module_name|
|
46
|
+
if swift_modules.last.nil?
|
47
|
+
raise CLIError.new("Error: The `--depends-on` argument requires that a `--module` or `--test-module` has already been defined.")
|
48
|
+
end
|
26
49
|
swift_modules.last.depends_on << module_name
|
27
50
|
end
|
28
51
|
end.parse arguments
|
29
52
|
|
53
|
+
swift_modules.each do |swift_module|
|
54
|
+
if swift_module.sources.count == 0
|
55
|
+
raise CLIError.new("Error: The module '#{swift_module.name}' does not have any valid sources.")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
30
59
|
swift_modules
|
31
60
|
end
|
32
61
|
|
@@ -2,7 +2,7 @@ require 'listen'
|
|
2
2
|
|
3
3
|
module Swift
|
4
4
|
module Gist
|
5
|
-
def self.watch_sources swift_modules, listener: Listen
|
5
|
+
def self.watch_sources swift_modules, listener: Listen
|
6
6
|
sources = Set.new(swift_modules.map { |swift_module| swift_module.sources }.flatten)
|
7
7
|
dirs = Set.new(sources.map { |path| Dir.exist?(path) ? path : File.dirname(path) })
|
8
8
|
|
@@ -10,8 +10,6 @@ module Swift
|
|
10
10
|
next unless sources.intersect?(Set.new(modified + created + deleted))
|
11
11
|
yield
|
12
12
|
end.start
|
13
|
-
|
14
|
-
sleep.call
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
data/lib/swift/gist/runner.rb
CHANGED
@@ -17,33 +17,46 @@ module Swift
|
|
17
17
|
project_art_generator: method(:generate_project_art),
|
18
18
|
project_generator: method(:generate_project),
|
19
19
|
rm_rf: FileUtils.method(:rm_rf),
|
20
|
-
|
20
|
+
stdin_watcher: method(:watch_stdin),
|
21
21
|
stdout: $stdout.method(:puts),
|
22
|
+
system: method(:system),
|
22
23
|
watcher: method(:watch_sources)
|
23
24
|
)
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
system.call('swift test')
|
26
|
+
begin
|
27
|
+
swift_modules = cli.call arguments
|
28
|
+
rescue CLIError => error
|
29
|
+
puts error.reason
|
30
|
+
exit
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
stdout.call
|
33
|
+
begin
|
34
|
+
tmp_dir = project_generator.call(swift_modules)
|
35
|
+
stdout.call project_art_generator.call(swift_modules, tmp_dir)
|
36
|
+
|
36
37
|
chdir.call(tmp_dir) do
|
37
38
|
system.call('swift test')
|
38
39
|
end
|
39
40
|
|
40
|
-
counter
|
41
|
+
counter = 1
|
42
|
+
|
43
|
+
build_command = -> {
|
44
|
+
stdout.call "\n\n-----> Running `$ swift test` @ '#{formatted_date.call}' - Build ##{counter}"
|
45
|
+
chdir.call(tmp_dir) do
|
46
|
+
system.call('swift test')
|
47
|
+
end
|
48
|
+
|
49
|
+
counter += 1
|
50
|
+
}
|
51
|
+
|
52
|
+
watcher.call(swift_modules, &build_command)
|
53
|
+
stdin_watcher.call(&build_command)
|
54
|
+
|
55
|
+
ensure
|
56
|
+
rm_rf.call tmp_dir
|
41
57
|
end
|
42
58
|
|
43
59
|
0
|
44
|
-
|
45
|
-
ensure
|
46
|
-
rm_rf.call tmp_dir
|
47
60
|
end
|
48
61
|
|
49
62
|
end
|
data/lib/swift/gist/version.rb
CHANGED
data/lib/swift/gist.rb
CHANGED
@@ -4,12 +4,13 @@ module Swift
|
|
4
4
|
end
|
5
5
|
|
6
6
|
require "swift/gist/cli"
|
7
|
+
require "swift/gist/file_watcher"
|
7
8
|
require "swift/gist/format_swift_module"
|
8
9
|
require "swift/gist/generate_project"
|
9
10
|
require "swift/gist/generate_project_art"
|
10
11
|
require "swift/gist/runner"
|
11
12
|
require "swift/gist/spm_package_creator"
|
12
13
|
require "swift/gist/spm_project_creator"
|
14
|
+
require "swift/gist/stdin_watcher"
|
13
15
|
require "swift/gist/swift_module"
|
14
16
|
require "swift/gist/version"
|
15
|
-
require "swift/gist/watcher"
|
data/swift-gist.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swift-gist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Samuels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -99,15 +99,16 @@ files:
|
|
99
99
|
- bin/swift-gist
|
100
100
|
- lib/swift/gist.rb
|
101
101
|
- lib/swift/gist/cli.rb
|
102
|
+
- lib/swift/gist/file_watcher.rb
|
102
103
|
- lib/swift/gist/format_swift_module.rb
|
103
104
|
- lib/swift/gist/generate_project.rb
|
104
105
|
- lib/swift/gist/generate_project_art.rb
|
105
106
|
- lib/swift/gist/runner.rb
|
106
107
|
- lib/swift/gist/spm_package_creator.rb
|
107
108
|
- lib/swift/gist/spm_project_creator.rb
|
109
|
+
- lib/swift/gist/stdin_watcher.rb
|
108
110
|
- lib/swift/gist/swift_module.rb
|
109
111
|
- lib/swift/gist/version.rb
|
110
|
-
- lib/swift/gist/watcher.rb
|
111
112
|
- swift-gist.gemspec
|
112
113
|
homepage: https://github.com/paulsamuels/swift-gist
|
113
114
|
licenses:
|
@@ -121,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
122
|
requirements:
|
122
123
|
- - ">="
|
123
124
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
125
|
+
version: 2.3.3
|
125
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
127
|
requirements:
|
127
128
|
- - ">="
|