disclose 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a124f3bd76e5f76c9331eb28389d6ae062812c38
4
- data.tar.gz: 1b38a9590f2b3802426e343fbd7e4a154edb8f63
3
+ metadata.gz: a1783cb307e31d458a3cd9d176725d5d8e910b6d
4
+ data.tar.gz: 91c81bba7524c9618b983ff1f5b988b804624e5b
5
5
  SHA512:
6
- metadata.gz: a5d7274cee8b5f028528e28a078572e30cd00e7f074a75971c1de62bd6a6124c7b224c4e9018d2982029a989f7f10581a2687203cd81f5867acb600fc084d5cb
7
- data.tar.gz: 0305f2417576f315a36e0fce53591dbe4c57936315b77a0a2c14662c3c5514d336bb0f9aaca18bc46a718a0e049c1e2a14ec827e109c96a85eae1529c62f37c1
6
+ metadata.gz: 3d58c8cfb041c8b6fe32d4cf2a601a1e70184e5757e5d64e4a54bc3d949e5e9a8bfcbb534b1be2d9f41e871949a4f9a514b7ac3e8b8a38c7bb598349a515c2cb
7
+ data.tar.gz: ea3be4f08ab247506ca95096761e41c8316ba06922932d7577017d2b7c5b6f35fbe7cce5950773ee3aa6e2dad7e44d3326ebbcc41e8a7bbf2c6dc0f18a29748b
data/README.md CHANGED
@@ -2,13 +2,19 @@
2
2
 
3
3
  Pack your Node.js project into an executable without recompiling Node.js.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/disclose.svg)](https://badge.fury.io/rb/disclose)
6
+ [![Build Status](https://travis-ci.org/pmq20/disclose.svg)](https://travis-ci.org/pmq20/disclose)
7
+ [![Code Climate](https://codeclimate.com/github/pmq20/disclose/badges/gpa.svg)](https://codeclimate.com/github/pmq20/disclose)
8
+ [![codecov.io](https://codecov.io/github/pmq20/disclose/coverage.svg?branch=master)](https://codecov.io/github/pmq20/disclose?branch=master)
9
+ [![](http://inch-ci.org/github/pmq20/disclose.svg?branch=master)](http://inch-ci.org/github/pmq20/disclose?branch=master)
10
+
5
11
  ## Installation
6
12
 
7
13
  $ gem install disclose
8
14
 
9
15
  ## Usage
10
16
 
11
- $ disclose <node_path> <project_path>
17
+ $ disclose [node_path] [project_path]
12
18
 
13
19
  ## Example
14
20
 
data/exe/disclose CHANGED
@@ -1,12 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require "disclose"
4
+
3
5
  unless 2 == ARGV.size
4
6
  puts Disclose.usage
7
+ exit 1
5
8
  end
6
9
 
7
- instance = Disclose.new *ARGV
8
-
9
10
  begin
11
+ instance = Disclose.new *ARGV
10
12
  instance.run!
11
13
  rescue Disclose::Error => e
12
14
  STDERR.puts e.message
data/lib/disclose/c.rb CHANGED
@@ -7,13 +7,15 @@ class Disclose
7
7
  #include <stdlib.h>
8
8
  #include <assert.h>
9
9
 
10
- int main(){
11
- char file[] = "/tmp/disclose.file.XXXXXX";
12
- char dir[] = "/tmp/disclose.dir.XXXXXX";
10
+ int main(int argc, char const *argv[]) {
11
+ char file[] = "/tmp/disclose.file.XXXXXX";
12
+ char dir[] = "/tmp/disclose.dir.XXXXXX";
13
13
  FILE *fp = NULL;
14
14
  int ret = -1;
15
15
  char cmd[256] = {0};
16
16
  char arg[256] = {0};
17
+ char **argv2 = NULL;
18
+ int i, index;
17
19
 
18
20
  mktemp(file);
19
21
  mkdtemp(dir);
@@ -30,7 +32,17 @@ class Disclose
30
32
 
31
33
  snprintf(cmd, 255, "%s/node", dir);
32
34
  snprintf(arg, 255, "%s/#{name}", dir);
33
- execl(cmd, cmd, arg, NULL);
35
+ argv2 = malloc(sizeof(char*) * (argc + 10));
36
+ assert(argv2);
37
+ argv2[0] = cmd;
38
+ argv2[1] = arg;
39
+ index = 2;
40
+ for (i = 1; i < argc; ++i) {
41
+ argv2[index] = argv[i];
42
+ index += 1;
43
+ }
44
+ argv2[index] = NULL;
45
+ execv(cmd, argv2);
34
46
 
35
47
  return 1;
36
48
  }
@@ -1,3 +1,3 @@
1
1
  class Disclose
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/disclose.rb CHANGED
@@ -2,10 +2,18 @@ require "disclose/version"
2
2
  require "disclose/c"
3
3
  require 'fileutils'
4
4
  require 'shellwords'
5
+ require 'tmpdir'
5
6
  require 'json'
6
7
 
7
8
  class Disclose
8
9
  class Error < RuntimeError; end
10
+
11
+ def self.usage
12
+ %q{
13
+ Usage: disclose [node_path] [project_path]
14
+ e.g. disclose /usr/local/bin/node /usr/local/lib/node_modules/coffee-script
15
+ }.strip
16
+ end
9
17
 
10
18
  def initialize(node_path, project_path)
11
19
  @node_path = node_path
@@ -16,13 +24,13 @@ class Disclose
16
24
 
17
25
  def parse_binaries!
18
26
  @package_path = File.join(@project_path, 'package.json')
19
- raise "No package.json exist at #{@package_path}." unless File.exist?(@package_path)
27
+ raise Error, "No package.json exist at #{@package_path}." unless File.exist?(@package_path)
20
28
  @package_json = JSON.parse File.read @package_path
21
29
  @binaries = @package_json['bin']
22
30
  if @binaries
23
31
  STDERR.puts "Detected binaries: #{@binaries}"
24
32
  else
25
- raise "No Binaries detected inside #{@package_path}."
33
+ raise Error, "No Binaries detected inside #{@package_path}."
26
34
  end
27
35
  end
28
36
 
@@ -61,16 +69,12 @@ class Disclose
61
69
  end
62
70
  end
63
71
 
64
- def usage
65
- 'Usage: disclose <node_path> <project_path>'
66
- end
67
-
68
72
  private
69
73
 
70
74
  def exe(cmd)
71
75
  STDERR.puts "$ #{cmd}"
72
76
  STDERR.print `#{cmd}`
73
- raise "#{cmd} failed!" unless $?.success?
77
+ raise Error, "#{cmd} failed!" unless $?.success?
74
78
  end
75
79
 
76
80
  def chdir(path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disclose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The rugged tests are fragile
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-06 00:00:00.000000000 Z
11
+ date: 2016-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler