encapsulator 0.1.0 → 0.1.1

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: 769fd6683b13b693f17cb124d830d342293cf361
4
- data.tar.gz: 1130e4c1fbcdd079a1fbaa3f08a08969d58425f2
3
+ metadata.gz: 6c103957fcf7dbae391e3a0c469de945d45ac9c6
4
+ data.tar.gz: 701f0bb1ebd0d31b50749c39a1b2d31ea50255fc
5
5
  SHA512:
6
- metadata.gz: 9daf5273e46dbd602fd90c7e434b513667c4e21d219ef1520e5d96fcae62845e2a7a3bacb31f5e2b8a4b21953851265950d9ecbe53ba03eb5b30934a0186da65
7
- data.tar.gz: bbb09b6f629c2db920188ac92070e8303da56118063844297339fb2bfc6fadd6240321e5f1075ade043c7cb706e826cfecc95f7a1af7fc88f1491c50b326f810
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 json rgl rake bundler
12
- git clone https://github.com/tfjmp/encapsulator.git
13
- cd encapsulator
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 json rgl rake bundler
24
- git clone https://github.com/tfjmp/encapsulator.git
25
- cd encapsulator
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 json rgl rake bundler
36
- git clone https://github.com/tfjmp/encapsulator.git
37
- cd encapsulator
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
- # extract info from ddg.json
47
- encapsulator --info <your_RDT_prov.json>
48
- # select an output node to generate the code to be generate
49
- encapsulator --code <your_RDT_prov.json> <output_node_name> <new R script>
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
  ```
@@ -2,7 +2,9 @@
2
2
 
3
3
  require "encapsulator"
4
4
 
5
- if ARGV[0] == '--info'
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
- Encapsulator::CLI::get_jpg ARGV[1]
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
- Encapsulator::CLI::get_png ARGV[1]
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
- Encapsulator::CLI::get_svg ARGV[1]
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
@@ -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/fedora25"'
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
@@ -1,19 +1,27 @@
1
+ require 'fileutils'
2
+
1
3
  module Encapsulator
2
4
  module ProvR
3
5
  def ProvR.run script
4
- require 'rinruby'
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
- r.eval "require('devtools')"
8
- r.eval "install_github('provtools/provR', ref='dev')"
9
- r.eval "require('provR')"
10
- r.eval "prov.capture('#{script}', save=TRUE)"
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
- r.eval "install.packages('formatR', repos = 'http://cran.rstudio.com')"
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 = script.gsub('.R', '_ddg')
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
- #@dg.add_edge v['prov:informed'], v['prov:informant']
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
- @dg.write_to_graphic_file('svg')
115
+ Dir.chdir('..') do
116
+ @dg.write_to_graphic_file('svg')
117
+ end
114
118
  end
115
119
 
116
120
  def jpg
117
- @dg.write_to_graphic_file('jpg')
121
+ Dir.chdir('..') do
122
+ @dg.write_to_graphic_file('jpg')
123
+ end
118
124
  end
119
125
 
120
126
  def png
121
- @dg.write_to_graphic_file('png')
127
+ Dir.chdir('..') do
128
+ @dg.write_to_graphic_file('png')
129
+ end
122
130
  end
123
131
 
124
132
  def get_list file
@@ -1,3 +1,3 @@
1
1
  module Encapsulator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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: 2017-09-15 00:00:00.000000000 Z
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.11
124
+ rubygems_version: 2.6.14
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: encapsulator for R.