rubypack 1.0.1 → 1.0.2

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: 1643d283312bf9a5252d4c64dfc40e98159bbbe0
4
- data.tar.gz: a41e70151492acba18ae7c2cc56de25e3a37628b
3
+ metadata.gz: 42235b3189090f26621ada9ac9ab740cbf97890a
4
+ data.tar.gz: 2b515af6d5ae52391fad4d95581ccdca82f4a0cf
5
5
  SHA512:
6
- metadata.gz: 2676e5b9715aad2a76c2ed5981c26ea0d30f10abb8a67102d46c5cccec0290f6ed862be3d66b6f45c85e395ca13292b879d8dca1c7e5796865b7b349ef6387bd
7
- data.tar.gz: fa072c36bbcfaa376a266920ffac91e16e169bcbba49ff29161a4189ca95a9bbcb9d05f6d47e10ff7c20b11e4e8c91b9bf8b49a2d820fa234e97b07e6ccc5e9a
6
+ metadata.gz: 28a006b1e1ea8a2bc47254cb1c07dda03683ca5f8d0fda82b30a30c6e8fbeb94c90b15c9116a9bdea2a58ed38fd897fe8bbffd1cb6864f7135d7c723f7c7bee3
7
+ data.tar.gz: d3194b7101d72188c25548dcf2bc328453a48abb5e02c9e6ec717063931767f2ea457c3d5d88ab2222c1d9169dd1d2417f2d992b57c10c5dd9b6edebd1dc6130
data/README.md CHANGED
@@ -28,11 +28,12 @@ The content of the `.rubypack` file:
28
28
  name 'TestApp'
29
29
  version '3.1'
30
30
 
31
+ include git
31
32
  exclude '*.log'
32
33
  include 'js/node_modules/**/**'
33
34
  ```
34
35
 
35
- Please note that if the first instruction among include/exclude is *include*, then the strategy to select the files will start with zero files and start applying the filters. However if the first instruction is a *exclude*, the selection of files will start with ALL files and start applying the filters in order.
36
+ Please note that if the first filter among include/exclude is *include*, then the strategy to select the files will start with zero files and continue applying the filters in order appearance. However if the first filter is *exclude*, the selection of files will start with ALL files and continue applying the reamining of the filters.
36
37
 
37
38
  Then run the following command to build your package:
38
39
 
@@ -76,7 +77,7 @@ To view more details about what is happening, you can use the `--verbose` switch
76
77
 
77
78
  ### Available commands
78
79
 
79
- ```bash
80
+ ```
80
81
  $ rubypack --help
81
82
  RubyPack 0.1.0 (c) 2017 Jorge del Rio
82
83
  A ruby package generation and execution manager.
@@ -92,7 +93,7 @@ Options:
92
93
 
93
94
  ### Build command
94
95
 
95
- ```bash
96
+ ```
96
97
  $ rubypack build --help
97
98
  build - Builds a package of your application.
98
99
 
@@ -108,7 +109,7 @@ Options:
108
109
 
109
110
  ### Deploy command
110
111
 
111
- ```bash
112
+ ```
112
113
  $ rubypack deploy --help
113
114
  deploy - Install the application package and all the gems.
114
115
 
@@ -132,6 +133,56 @@ Options:
132
133
  -h, --help Show this message
133
134
  ```
134
135
 
136
+ ## Configuration file
137
+
138
+ The configuration file `.rubypack` is used to determinate which will be included in the final package file.
139
+
140
+ The *name* and *version* methods are used to define the final name of the package. For example: `MyApp-1.2.0.tgz.rpack`
141
+
142
+ ```ruby
143
+ name 'MyApp'
144
+ version '1.2.0'
145
+ ```
146
+
147
+ You can rubypack configuration is a ruby file than can contain any code. Therefore, you can set the version using the definition in another file.
148
+
149
+ ```
150
+ require 'version.rb'
151
+
152
+ name 'MyApp'
153
+ version MyApp::VERSION
154
+ ```
155
+
156
+ The *git* keyword fetches all the files in the repository using the following command: `` `git ls-files -z\`.split("\x0") ``
157
+
158
+ ```ruby
159
+ include git
160
+ ```
161
+
162
+ The *all* keyword fetches all the files using the wildcards `**/**`.
163
+
164
+ ```ruby
165
+ include all
166
+ ```
167
+
168
+ To include a specific file, simple write the relative URL to the file.
169
+
170
+ ```
171
+ include 'Myfile.txt'
172
+ ```
173
+
174
+ It is possible to include several filters in the same line.
175
+
176
+ ```
177
+ include git, 'js/node_modules', 'public/**/**'
178
+ ```
179
+
180
+ The order of the include/exclude instructions matters. The filters are applied in order of appearance. For example, to select only the files not tracked by git:
181
+
182
+ ```
183
+ include all
184
+ exclude git
185
+ ```
135
186
 
136
187
  ## Development
137
188
 
data/bin/rubypack CHANGED
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
- require 'trollop'
5
- require 'rubypack'
3
+ Dir.chdir(File.dirname(__FILE__)) do
4
+ require 'bundler/setup'
5
+ require 'trollop'
6
+ require 'rubypack'
7
+ end
6
8
 
7
9
  SUB_COMMANDS = %w(build deploy list)
8
10
  global_opts = Trollop::options do
@@ -59,6 +59,7 @@ module Rubypack
59
59
  def generate_list_of_files(pack)
60
60
  @output.step('Generating list of files...') do
61
61
  pack.include(pack.filename)
62
+ pack.include('Gemfile')
62
63
  pack.include('Gemfile.lock')
63
64
  pack.include('vendor/cache/*')
64
65
  all_files = pack.list_files
@@ -7,33 +7,29 @@ module Rubypack
7
7
 
8
8
  def package
9
9
  begin
10
- old_pwd = Dir.pwd
11
- Dir.chdir(@path)
12
- IO.popen(['bundle', 'package', '--all-platforms', '--all', err: [:child, :out]]) do |out|
13
- yield(out)
10
+ Dir.chdir(@path) do
11
+ IO.popen(['bundle', 'package', '--all-platforms', '--all', err: [:child, :out]]) do |out|
12
+ yield(out)
13
+ end
14
+ fail("bundle package failed: #{$?.exitstatus}") unless $?.exitstatus == 0
15
+ true
14
16
  end
15
- fail("bundle package failed: #{$?.exitstatus}") unless $?.exitstatus == 0
16
- true
17
17
  rescue => error
18
18
  fail("Error executing bundle package: #{error.message}")
19
- ensure
20
- Dir.chdir(old_pwd)
21
19
  end
22
20
  end
23
21
 
24
22
  def install
25
23
  begin
26
- old_pwd = Dir.pwd
27
- Dir.chdir(@path)
28
- IO.popen(['bundle', 'install', '--local', '--deployment', err: [:child, :out]]) do |out|
29
- yield(out)
24
+ Dir.chdir(@path) do
25
+ IO.popen(['bundle', 'install', '--local', '--deployment', err: [:child, :out]]) do |out|
26
+ yield(out)
27
+ end
28
+ fail("bundle install failed: #{$?.exitstatus}") unless $?.exitstatus == 0
29
+ true
30
30
  end
31
- fail("bundle install failed: #{$?.exitstatus}") unless $?.exitstatus == 0
32
- true
33
31
  rescue => error
34
32
  fail("Error executing bundle install: #{error.message}")
35
- ensure
36
- Dir.chdir(old_pwd)
37
33
  end
38
34
  end
39
35
  end
@@ -26,15 +26,13 @@ module Rubypack
26
26
 
27
27
  begin
28
28
  filename = File.expand_path(output_filename + @compressor.extension)
29
- old_pwd = Dir.pwd
30
- Dir.chdir(path)
31
- @compressor.compress(filename: filename) do |out|
32
- while line = out.gets do
33
- @output.verbose(' >', line)
29
+ Dir.chdir(path) do
30
+ @compressor.compress(filename: filename) do |out|
31
+ while line = out.gets do
32
+ @output.verbose(' >', line)
33
+ end
34
34
  end
35
35
  end
36
- ensure
37
- Dir.chdir(old_pwd)
38
36
  end
39
37
 
40
38
  @output.status(' File created: ', filename)
@@ -51,15 +49,13 @@ module Rubypack
51
49
 
52
50
  begin
53
51
  full_filename = File.expand_path(filename)
54
- old_pwd = Dir.pwd
55
- Dir.chdir(directory)
56
- @compressor.decompress(filename: full_filename) do |out|
57
- while line = out.gets do
58
- @output.verbose(' >', line)
52
+ Dir.chdir(directory) do
53
+ @compressor.decompress(filename: full_filename) do |out|
54
+ while line = out.gets do
55
+ @output.verbose(' >', line)
56
+ end
59
57
  end
60
58
  end
61
- ensure
62
- Dir.chdir(old_pwd)
63
59
  end
64
60
 
65
61
  @output.status(' Directory created: ', directory)
@@ -31,20 +31,28 @@ module Rubypack
31
31
  "#{@name}-#{@version}"
32
32
  end
33
33
 
34
- def run(command)
35
- @command = command
36
- end
37
-
38
34
  def include(*args)
35
+ args.flatten!
39
36
  @rules = [] unless defined?(@rules)
40
37
  args.each { |entry| @rules << { action: :include, filter: entry } }
41
38
  end
42
39
 
43
40
  def exclude(*args)
41
+ args.flatten!
44
42
  @rules = [] unless defined?(@rules)
45
43
  args.each { |entry| @rules << { action: :exclude, filter: entry } }
46
44
  end
47
45
 
46
+ def all
47
+ '**/**'
48
+ end
49
+
50
+ def git
51
+ Dir.chdir(@path) do
52
+ `git ls-files -z`.split("\x0")
53
+ end
54
+ end
55
+
48
56
  def format_rule(rule, files)
49
57
  @output.status(" Action: #{rule[:action]}, Filter: #{rule[:filter]}")
50
58
  icon = (rule[:action] == :include) ? ' +' : ' -'
@@ -52,49 +60,47 @@ module Rubypack
52
60
  end
53
61
 
54
62
  def list_files
55
- old_pwd = Dir.pwd
56
- Dir.chdir(@path)
57
-
58
- # If not rules were defined, include all by default
59
- unless defined?(@rules)
60
- files = Dir['**/**']
61
- format_rule({ action: :include, filter: '**/**' }, files)
62
- return ffiles
63
- end
63
+ Dir.chdir(@path) do
64
64
 
65
- # Determinate if the package must start with all files or with none
66
- action = @rules.first[:action]
67
- if action == :include
68
- files = []
69
- elsif action == :exclude
70
- files = Dir['**/**']
71
- format_rule({ action: :include, filter: '**/**' }, files)
72
- else
73
- fail("Action not implemented: #{action}")
74
- end
65
+ # If not rules were defined, include all by default
66
+ unless defined?(@rules)
67
+ files = Dir['**/**']
68
+ format_rule({ action: :include, filter: '**/**' }, files)
69
+ return ffiles
70
+ end
75
71
 
76
- # Include/exclude based on the rules
77
- @rules.each do |rule|
78
- if rule[:action] == :include
79
- filtered_files = Dir[rule[:filter]]
80
- files |= filtered_files
81
- format_rule(rule, filtered_files)
82
- elsif rule[:action] == :exclude
83
- filtered_files = Dir[rule[:filter]]
84
- files -= filtered_files
85
- format_rule(rule, filtered_files)
72
+ # Determinate if the package must start with all files or with none
73
+ action = @rules.first[:action]
74
+ if action == :include
75
+ files = []
76
+ elsif action == :exclude
77
+ files = Dir['**/**']
78
+ format_rule({ action: :include, filter: '**/**' }, files)
86
79
  else
87
- fail("Action not implemented: #{rule[:action]}")
80
+ fail("Action not implemented: #{action}")
88
81
  end
89
- end
90
82
 
91
- # Remove directories
92
- files.reject! { |file| File.directory?(file) }
83
+ # Include/exclude based on the rules
84
+ @rules.each do |rule|
85
+ if rule[:action] == :include
86
+ filtered_files = Dir[rule[:filter]]
87
+ files |= filtered_files
88
+ format_rule(rule, filtered_files)
89
+ elsif rule[:action] == :exclude
90
+ filtered_files = Dir[rule[:filter]]
91
+ files -= filtered_files
92
+ format_rule(rule, filtered_files)
93
+ else
94
+ fail("Action not implemented: #{rule[:action]}")
95
+ end
96
+ end
97
+
98
+ # Remove directories
99
+ files.reject! { |file| File.directory?(file) }
93
100
 
94
- # Sort the file names
95
- files.sort
96
- ensure
97
- Dir.chdir(old_pwd)
101
+ # Sort the file names
102
+ files.sort
103
+ end
98
104
  end
99
105
 
100
106
  end
@@ -1,3 +1,3 @@
1
1
  module Rubypack
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jorge del Rio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-23 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler