encapsulator 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -25
- data/bin/encapsulator +18 -4
- data/lib/encapsulator/cli.rb +14 -12
- data/lib/encapsulator/installer.rb +5 -0
- data/lib/encapsulator/provr.rb +15 -7
- data/lib/encapsulator/rjson_parser.rb +13 -5
- data/lib/encapsulator/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c103957fcf7dbae391e3a0c469de945d45ac9c6
|
4
|
+
data.tar.gz: 701f0bb1ebd0d31b50749c39a1b2d31ea50255fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cae1a4c0191479bcdbf14d5fb8088363ac8dade95f9935e9764a12182f8753a3ca152d88a49e524c3cae95f4cdbdfc41955488924794730ce63ee37e9596b718
|
7
|
+
data.tar.gz: 244df5f46abedd99e7537a9ecf68458548bd654c59635b49c85dd8e6ff0c0f935826e59451caf796500461d07deb6e08acc5d8deabccd65b1b84af5c93784135
|
data/README.md
CHANGED
@@ -4,47 +4,51 @@
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
```
|
8
|
+
gem install encapsulator
|
9
|
+
```
|
10
|
+
|
11
|
+
## Building from source
|
12
|
+
|
7
13
|
### Fedora 25
|
8
14
|
|
9
15
|
```
|
10
|
-
sudo dnf install ruby
|
11
|
-
gem install
|
12
|
-
|
13
|
-
|
14
|
-
rake install
|
15
|
-
encapsulator --install fedora
|
16
|
-
encapsulator -h
|
16
|
+
$ sudo dnf install ruby
|
17
|
+
$ gem install encapsulator
|
18
|
+
$ encapsulator --install fedora
|
19
|
+
$ encapsulator -h
|
17
20
|
```
|
18
21
|
|
19
22
|
### Ubuntu
|
20
23
|
|
21
24
|
```
|
22
|
-
sudo apt install ruby
|
23
|
-
gem install
|
24
|
-
|
25
|
-
|
26
|
-
rake install
|
27
|
-
encapsulator --install ubuntu
|
28
|
-
encapsulator -h
|
25
|
+
$ sudo apt install ruby
|
26
|
+
$ gem install encapsulator
|
27
|
+
$ encapsulator --install ubuntu
|
28
|
+
$ encapsulator -h
|
29
29
|
```
|
30
30
|
|
31
31
|
### MacOS
|
32
32
|
|
33
33
|
```
|
34
|
-
brew install ruby
|
35
|
-
gem install
|
36
|
-
|
37
|
-
|
38
|
-
rake install
|
39
|
-
encapsulator --install mac
|
40
|
-
encapsulator -h
|
34
|
+
$ brew install ruby
|
35
|
+
$ gem install encapsulator
|
36
|
+
$ encapsulator --install mac
|
37
|
+
$ encapsulator -h
|
41
38
|
```
|
42
39
|
|
43
40
|
## USAGE
|
44
41
|
|
45
42
|
```
|
46
|
-
#
|
47
|
-
encapsulator
|
48
|
-
|
49
|
-
|
43
|
+
# see
|
44
|
+
$ encapsulator -h
|
45
|
+
--version display encapsulator version
|
46
|
+
--info <path to R script> display information about the R script
|
47
|
+
--jpg [--all] <path to R script> output graph as jpg
|
48
|
+
--png [--all] <path to R script> output graph as png
|
49
|
+
--svg [--all] <path to R script> output graph as svg
|
50
|
+
--code <path to R script> <output> [output] ... [output] create the source necessary to generate the specified output
|
51
|
+
--run <path to R script> run the provided r script
|
52
|
+
--encapsulate <user>/<project> <script> <output> [output] ... [output] create the specified capsule
|
53
|
+
--decapsulate <user>/<project> download the coresponding capsule
|
50
54
|
```
|
data/bin/encapsulator
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
require "encapsulator"
|
4
4
|
|
5
|
-
if ARGV[0] == '--
|
5
|
+
if ARGV[0] == '-v' || ARGV[0] == '--version'
|
6
|
+
puts Encapsulator::VERSION
|
7
|
+
elsif ARGV[0] == '--info'
|
6
8
|
Encapsulator::CLI::info ARGV[1]
|
7
9
|
elsif ARGV[0] == '--encapsulate'
|
8
10
|
system 'rm', '-rf', '.'+ARGV[1]
|
@@ -21,11 +23,23 @@ elsif ARGV[0] == '--encapsulate'
|
|
21
23
|
elsif ARGV[0] == '--decapsulate'
|
22
24
|
decapsulate ARGV[1]
|
23
25
|
elsif ARGV[0] == '--jpg'
|
24
|
-
|
26
|
+
if ARGV[1] == '--all'
|
27
|
+
Encapsulator::CLI::get_jpg ARGV[2], true
|
28
|
+
else
|
29
|
+
Encapsulator::CLI::get_jpg ARGV[1]
|
30
|
+
end
|
25
31
|
elsif ARGV[0] == '--png'
|
26
|
-
|
32
|
+
if ARGV[1] == '--all'
|
33
|
+
Encapsulator::CLI::get_png ARGV[2], true
|
34
|
+
else
|
35
|
+
Encapsulator::CLI::get_png ARGV[1]
|
36
|
+
end
|
27
37
|
elsif ARGV[0] == '--svg'
|
28
|
-
|
38
|
+
if ARGV[1] == '--all'
|
39
|
+
Encapsulator::CLI::get_svg ARGV[2], true
|
40
|
+
else
|
41
|
+
Encapsulator::CLI::get_svg ARGV[1]
|
42
|
+
end
|
29
43
|
elsif ARGV[0] == '--code'
|
30
44
|
out_path = '.encapsulator'
|
31
45
|
system 'rm', '-rf', out_path
|
data/lib/encapsulator/cli.rb
CHANGED
@@ -2,10 +2,11 @@ module Encapsulator
|
|
2
2
|
module CLI
|
3
3
|
def CLI.usage
|
4
4
|
puts "USAGE\n\n"
|
5
|
+
puts '--version display encapsulator version'
|
5
6
|
puts '--info <path to R script> display information about the provenance graph'
|
6
|
-
puts '--jpg <path to R script> output graph as jpg'
|
7
|
-
puts '--png <path to R script> output graph as png'
|
8
|
-
puts '--svg <path to R script> output graph as svg'
|
7
|
+
puts '--jpg [--all] <path to R script> output graph as jpg'
|
8
|
+
puts '--png [--all] <path to R script> output graph as png'
|
9
|
+
puts '--svg [--all] <path to R script> output graph as svg'
|
9
10
|
puts '--code <path to R script> <output> [output] ... [output] create the source necessary to generate the specified output'
|
10
11
|
puts '--run <path to R script> run the provided r script'
|
11
12
|
puts '--encapsulate <user>/<project> <script> <output> [output] ... [output] create the specified capsule'
|
@@ -17,7 +18,7 @@ module Encapsulator
|
|
17
18
|
provision << '# -*- mode: ruby -*-'
|
18
19
|
provision << '# vi: set ft=ruby :'
|
19
20
|
provision << 'Vagrant.configure(2) do |config|'
|
20
|
-
provision << " "+'config.vm.box = "jhcook/
|
21
|
+
provision << " "+'config.vm.box = "jhcook/fedora27"'
|
21
22
|
provision << " "+'config.vm.provider "virtualbox" do |vb|'
|
22
23
|
provision << " "+'vb.gui = true'
|
23
24
|
provision << " "+'vb.memory = 2048'
|
@@ -31,6 +32,7 @@ module Encapsulator
|
|
31
32
|
provision << " "+'sudo dnf -y -v install libcurl libcurl-devel'
|
32
33
|
provision << " "+'sudo dnf -y -v install perl-CPAN'
|
33
34
|
provision << " "+'sudo dnf -y -v install ruby'
|
35
|
+
provision << " "+'sudo dnf -y -v install R'
|
34
36
|
provision << " "+'wget https://atom.io/download/rpm'
|
35
37
|
provision << " "+'mv ./rpm ./atom.rpm'
|
36
38
|
provision << " "+'sudo dnf -y -v install ./atom.rpm'
|
@@ -57,7 +59,7 @@ module Encapsulator
|
|
57
59
|
end
|
58
60
|
puts 'Provision script is ready...'
|
59
61
|
puts 'getting your capsule ready, be patient...'
|
60
|
-
system("vagrant", "up", out: $stdout, err: $stdout)
|
62
|
+
system("vagrant", "up", "--provider", "virtualbox", out: $stdout, err: $stdout)
|
61
63
|
system("vagrant", "halt", out: $stdout, err: $stdout)
|
62
64
|
end
|
63
65
|
puts 'Your capsule should be visible in the virtualbox interface.'
|
@@ -68,7 +70,7 @@ module Encapsulator
|
|
68
70
|
puts "looking for the capsule #{vm}..."
|
69
71
|
system("vagrant", "init", capsule_name, out: $stdout, err: $stdout)
|
70
72
|
puts 'getting your capsule ready, be patient...'
|
71
|
-
system("vagrant", "up", out: $stdout, err: $stdout)
|
73
|
+
system("vagrant", "up", "--provider", "virtualbox", out: $stdout, err: $stdout)
|
72
74
|
system("vagrant", "halt", out: $stdout, err: $stdout)
|
73
75
|
puts 'you should find your capsule in the virtualbox GUI.'
|
74
76
|
end
|
@@ -88,21 +90,21 @@ module Encapsulator
|
|
88
90
|
end
|
89
91
|
end
|
90
92
|
|
91
|
-
def CLI.get_jpg script
|
93
|
+
def CLI.get_jpg script, all=false
|
92
94
|
ProvR.run_script script do
|
93
|
-
Encapsulator::RJSONParser.new('../'+script).read_json_file('ddg.json').jpg
|
95
|
+
Encapsulator::RJSONParser.new('../'+script, all).read_json_file('ddg.json').jpg
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|
97
|
-
def CLI.get_png script
|
99
|
+
def CLI.get_png script, all=false
|
98
100
|
ProvR.run_script script do
|
99
|
-
Encapsulator::RJSONParser.new('../'+script).read_json_file('ddg.json').png
|
101
|
+
Encapsulator::RJSONParser.new('../'+script, all).read_json_file('ddg.json').png
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
def CLI.get_svg script
|
105
|
+
def CLI.get_svg script, all=false
|
104
106
|
ProvR.run_script script do
|
105
|
-
Encapsulator::RJSONParser.new('../'+script).read_json_file('ddg.json').svg
|
107
|
+
Encapsulator::RJSONParser.new('../'+script, all).read_json_file('ddg.json').svg
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
@@ -4,6 +4,11 @@ module Encapsulator
|
|
4
4
|
system 'wget', 'http://download.virtualbox.org/virtualbox/5.1.22/VirtualBox-5.1-5.1.22_115126_fedora25-1.x86_64.rpm', out: $stdout, err: $stdout
|
5
5
|
system 'sudo', 'dnf', '-y', '-v', 'install', './VirtualBox-5.1-5.1.22_115126_fedora25-1.x86_64.rpm', out: $stdout, err: $stdout
|
6
6
|
system 'sudo', 'dnf', '-y', '-v', 'install', 'vagrant', out: $stdout, err: $stdout
|
7
|
+
system 'sudo', 'dnf', '-y', '-v', 'install', 'openssl-devel', out: $stdout, err: $stdout
|
8
|
+
system 'sudo', 'dnf', '-y', '-v', 'install', 'libcurl-devel', out: $stdout, err: $stdout
|
9
|
+
system 'sudo', 'dnf', '-y', '-v', 'install', 'libxml-devel', out: $stdout, err: $stdout
|
10
|
+
system 'sudo', 'dnf', '-y', '-v', 'install', 'libxml2-devel', out: $stdout, err: $stdout
|
11
|
+
system 'sudo', 'dnf', '-y', '-v', 'install', 'R', out: $stdout, err: $stdout
|
7
12
|
end
|
8
13
|
|
9
14
|
def self.install_ubuntu
|
data/lib/encapsulator/provr.rb
CHANGED
@@ -1,19 +1,27 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Encapsulator
|
2
4
|
module ProvR
|
3
5
|
def ProvR.run script
|
4
|
-
|
6
|
+
FileUtils.mkdir_p './prov'
|
7
|
+
require 'rinruby'
|
5
8
|
r = RinRuby.new(echo: false)
|
9
|
+
r.eval "chooseCRANmirror(ind=81)"
|
6
10
|
r.eval "install.packages('devtools')"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
r.eval "prov.capture('#{script}'
|
11
|
+
r.eval "require('devtools')"
|
12
|
+
r.eval "install_github('provtools/provR', ref='dev')"
|
13
|
+
r.eval "require('provR')"
|
14
|
+
r.eval "prov.capture('#{script}')"
|
15
|
+
r.eval "f <- file('./prov/ddg.json')"
|
16
|
+
r.eval "writeLines(prov.json(), f)"
|
17
|
+
r.eval "close(f)"
|
11
18
|
end
|
12
19
|
|
13
20
|
def ProvR.tidy script
|
14
21
|
require 'rinruby'
|
15
22
|
r = RinRuby.new(echo: false)
|
16
|
-
|
23
|
+
r.eval "chooseCRANmirror(ind=81)"
|
24
|
+
r.eval "install.packages('formatR', repos = 'http://cran.rstudio.com')"
|
17
25
|
r.eval "require('formatR')"
|
18
26
|
r.eval "tidy_file('#{script}')"
|
19
27
|
end
|
@@ -24,7 +32,7 @@ module Encapsulator
|
|
24
32
|
run script
|
25
33
|
$ran_script = true
|
26
34
|
end
|
27
|
-
prov_folder =
|
35
|
+
prov_folder = './prov'
|
28
36
|
Dir.chdir prov_folder do
|
29
37
|
yield
|
30
38
|
end
|
@@ -14,8 +14,9 @@ module Encapsulator
|
|
14
14
|
attr_reader :libraries
|
15
15
|
attr_reader :packages
|
16
16
|
attr_reader :file
|
17
|
+
attr_reader :informed
|
17
18
|
|
18
|
-
def initialize r_file
|
19
|
+
def initialize r_file, informed=false
|
19
20
|
@dg = RGL::DirectedAdjacencyGraph.new # initialise the graph structure
|
20
21
|
@map = Hash.new(0)
|
21
22
|
@files = Hash.new
|
@@ -24,6 +25,7 @@ module Encapsulator
|
|
24
25
|
@libraries = Hash.new
|
25
26
|
@packages = Hash.new
|
26
27
|
@script = IO.readlines(r_file)
|
28
|
+
@informed = informed
|
27
29
|
end
|
28
30
|
|
29
31
|
def get_operation start_line, end_line
|
@@ -53,7 +55,7 @@ module Encapsulator
|
|
53
55
|
end
|
54
56
|
|
55
57
|
def wasInformedBy k, v
|
56
|
-
|
58
|
+
@dg.add_edge v['prov:informed'], v['prov:informant'] unless !informed
|
57
59
|
end
|
58
60
|
|
59
61
|
def wasAssociatedWith k, v
|
@@ -110,15 +112,21 @@ module Encapsulator
|
|
110
112
|
end
|
111
113
|
|
112
114
|
def svg
|
113
|
-
|
115
|
+
Dir.chdir('..') do
|
116
|
+
@dg.write_to_graphic_file('svg')
|
117
|
+
end
|
114
118
|
end
|
115
119
|
|
116
120
|
def jpg
|
117
|
-
|
121
|
+
Dir.chdir('..') do
|
122
|
+
@dg.write_to_graphic_file('jpg')
|
123
|
+
end
|
118
124
|
end
|
119
125
|
|
120
126
|
def png
|
121
|
-
|
127
|
+
Dir.chdir('..') do
|
128
|
+
@dg.write_to_graphic_file('png')
|
129
|
+
end
|
122
130
|
end
|
123
131
|
|
124
132
|
def get_list file
|
data/lib/encapsulator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: encapsulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Pasquier
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rgl
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.6.
|
124
|
+
rubygems_version: 2.6.14
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: encapsulator for R.
|