raka 0.2.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -19
  3. data/VERSION +1 -1
  4. data/bin/raka +58 -0
  5. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3391bad82ef017d820e266d897d570d32f6a62c3b09382b4b6ad8d1f8ead6fe
4
- data.tar.gz: 39aa088fc9e87bda8a7ad14f60678b934ca006de0d78c893da5678f0a1082740
3
+ metadata.gz: 39d1cdcbdf429bcdfd1696a923ab288a18586cfaadec6593a3b10744553a65ab
4
+ data.tar.gz: ee50756d449134a34439d39cd1f56593d22610d0ffc6559a3babae1d0783db70
5
5
  SHA512:
6
- metadata.gz: b0b426ad5076914630e192345d0796dfa1c30c580f3709d6c88773170ee8e18148c9795f6f7c2619bc5fa22983f0f50f4ed34e09880fc3a8004cbd773b138a5e
7
- data.tar.gz: db00045e711049a23735dc9358b7faca10528a07b893307becd8eb4d73a90002430a19f6a4e5bb228366455b5066ee1e27b0b609b9b2192768fb8ea33131986a
6
+ metadata.gz: 9f48f4da48b22ee932108f3c5f4872ad01204f05b946cbf901e2926cf11f898636ef0c369e9986ab3946df9f739439c1a4892a4691587a86eb253ba373107eb4
7
+ data.tar.gz: 4f962ee86863aec86b1bee8b129092973492654c60f1389a49c3c475810520b8194863807662ef3d57ed7dfcd8b961a8bcc03fba0d126fa7f632855ba5699809
data/README.md CHANGED
@@ -5,29 +5,30 @@
5
5
  Data processing tasks can involve plenty of steps, each with its dependencies. Compared to bare Rake or the more classical Make, Raka offers the following advantages:
6
6
 
7
7
  1. Advanced pattern matching and template resolving to define general rules and maximize code reuse.
8
- 2. Extensible and context-aware protocol architecture
9
- 3. Multilingual. Other programming languages can be easily embedded
10
- 4. Auto dependency and naming by conventions
11
- 5. Support scopes to ease comparative studies
12
- 6. Terser syntax
8
+ 2. Extensible and context-aware protocol architecture.
9
+ 3. Multilingual. Other programming languages can be easily embedded.
10
+ 4. Auto dependency and naming by conventions.
11
+ 5. Scopes to ease comparative studies.
12
+ 6. Terser syntax.
13
13
 
14
14
  ... and more.
15
15
 
16
- ## Usage
16
+ Compared to more comlex, GUI-based solutions (perhaps classified as scientific-workflow software) like Kepler, etc., Raka has the following advantages:
17
17
 
18
- Raka is a drop-in library for rake. Though rake is cross platform, raka may not work on Windows since it relies some shell facilities. To use raka, one has to install ruby and rake first. Ruby is available for most \*nix systems including Mac OSX so the only task is to install rake like:
18
+ 1. Lightweight and easy to setup, especially on platforms with ruby preinstalled.
19
+ 2. Easy to deploy, version-control, backup or share workflows since the workflows are merely text files.
20
+ 3. Easy to reuse modules or create reusable modules, which are merely plain ruby code snippets (or in other languages with protocols).
21
+ 4. Expressive so a few lines of code can replace many manual operations.
19
22
 
20
- ```bash
21
- gem install rake
22
- ```
23
+ ## Installation
23
24
 
24
- The next step is to clone this project to local machine, cd to the directory, and install the gem:
25
+ Raka is a library based on rake. Though rake is cross platform, raka may not work on Windows since it relies some shell facilities. To use raka, one has to install ruby and rake first. Ruby is available for most \*nix systems including Mac OSX so the only task is to install raka like:
25
26
 
26
27
  ```bash
27
- gem install pkg/raka-0.1.0.gem
28
+ gem install raka
28
29
  ```
29
30
 
30
- ## For the Impatient
31
+ ## QuickStart
31
32
 
32
33
  First create a file named `main.raka` and import & initialize the DSL
33
34
 
@@ -191,12 +192,12 @@ One can write special token `_` or `something[]` if the captured value is useful
191
192
 
192
193
  In some places of `rexpr`, templates can be written instead of strings, so that it can represent different values at runtime. There are two types of variables that can be used in templates. The first is automatic variables, which is just like `$@` in Make or `task.name` in Rake. We even preserve some Make conventions for easier migrations. All automatic varibales begin with `$`. The possible automatic variables are:
193
194
 
194
- | symbol | meaning | symbol | meaning |
195
- | -------------- | ---------------------- | ------------- | ------------------------------- |
196
- | \$@ | output file | \$^ | all dependecies (sep by spaces) |
197
- | \$< | first dependency | $0, $1, … \$i | ith depdency |
198
- | \$(scope) | scope for current task | \$(output_stem) | stem of the output file |
199
- | \$(input_stem) | stem of the input file | | |
195
+ | symbol | meaning | symbol | meaning |
196
+ | -------------- | ---------------------- | --------------- | ------------------------------- |
197
+ | \$@ | output file | \$^ | all dependecies (sep by spaces) |
198
+ | \$< | first dependency | $0, $1, … \$i | ith depdency |
199
+ | \$(scope) | scope for current task | \$(output_stem) | stem of the output file |
200
+ | \$(input_stem) | stem of the input file | | |
200
201
 
201
202
  The other type of variables are those bounded during pattern matching,which can be referred to using `%{var}`. In the example of the [pattern matching](###pattern-matching) section, `%{indicator}` will be replaced by `node_num`, `%{top}` will be replaced by `top_50` and `%{top0}` will be replaced by `50`. In such case, a template as `'calculate top %{top0} of %{indicator} for $@'` will be resolved as `'calculate top 50 of node_num for top_50__node_num__buildings.pdf'`
202
203
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.1
data/bin/raka ADDED
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'optparse'
5
+ require 'English'
6
+ require 'open3'
7
+
8
+ def detect_main
9
+ # check predefined files
10
+ main_file_cands = ['Rakefile.raka', 'rakefile.raka', 'main.raka']
11
+ main_file_cands.each do |cand|
12
+ return cand if File.exist?(cand)
13
+ end
14
+
15
+ # if only one .raka file, use it as main
16
+ rakas = Dir.glob('*.raka')
17
+ return rakas[0] if rakas.length == 1
18
+ end
19
+
20
+ entry = detect_main
21
+
22
+ options = { rake: {}, raka_finished: false }
23
+ def set_option(opts, key, value)
24
+ if opts[:raka_finished]
25
+ opts[:rake][key] = value
26
+ else
27
+ opts[key] = value
28
+ end
29
+ end
30
+ parser = OptionParser.new do |opts|
31
+ opts.banner = 'Usage: raka [options] [raka file] -- [rake options]'
32
+
33
+ opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
34
+ set_option(options, :verbose, v)
35
+ end
36
+ end
37
+
38
+ both_args = ARGV.join(' ').split(' -- ')
39
+ extra_args = both_args[1]
40
+ self_args = both_args[0].split(/\s+/)
41
+ parser.parse!(self_args)
42
+
43
+ env = if options[:verbose]
44
+ 'LOG_LEVEL=0 '
45
+ else
46
+ ''
47
+ end
48
+ targets = self_args.join(' ')
49
+ cmd = "#{env}rake -f #{entry} #{extra_args} #{targets}"
50
+ puts cmd
51
+ output, err, code = Open3.capture3(cmd)
52
+ if code == 0
53
+ # TOOD: if empty, print all exist
54
+ puts output unless output.empty?
55
+ else
56
+ puts 'Error: rake returns the following information:'
57
+ end
58
+ puts err
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yarray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -120,6 +120,7 @@ files:
120
120
  - LICENSE
121
121
  - README.md
122
122
  - VERSION
123
+ - bin/raka
123
124
  - lib/compile.rb
124
125
  - lib/interface.rbs
125
126
  - lib/lang/psql/impl.rb
@@ -144,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
145
  requirements:
145
146
  - - ">="
146
147
  - !ruby/object:Gem::Version
147
- version: '0'
148
+ version: 2.3.0
148
149
  required_rubygems_version: !ruby/object:Gem::Requirement
149
150
  requirements:
150
151
  - - ">="