rplusplus 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rplusplus/environment.rb +34 -53
- data/lib/rplusplus/version.rb +1 -1
- data/rplusplus.gemspec +1 -1
- data/spec/spec_helper.rb +3 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0989e8c5ffe3aae629bfbf79784467f6c1677b32
|
4
|
+
data.tar.gz: 635f42a74effc1ff5e20ce09448735cd1e3a62eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8da90c09d0bb646389ec6012013f153adca607234b44eff0d0e4fc40ee8a706c26cb5fee12d631e24f31da4ee0709b1435595c09c88acecd2f2a9326febcd676
|
7
|
+
data.tar.gz: 09919db3de64c94cb4e61b0b0501d7bd84fe4e03178c9254b0fef12c59dc6f2ca6ab7f445959858ff36e5ce96775ed9c6f602741cb108a8060bd4a92c56bc875
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# R++
|
1
|
+
# R++ [![Gem Version](https://badge.fury.io/rb/rplusplus.svg)](http://badge.fury.io/rb/rplusplus) [![Code Climate](https://codeclimate.com/github/jellymann/rplusplus/badges/gpa.svg)](https://codeclimate.com/github/jellymann/rplusplus) [![Test Coverage](https://codeclimate.com/github/jellymann/rplusplus/badges/coverage.svg)](https://codeclimate.com/github/jellymann/rplusplus/coverage) [![Circle CI](https://circleci.com/gh/jellymann/rplusplus.svg?style=svg)](https://circleci.com/gh/jellymann/rplusplus)
|
2
2
|
|
3
3
|
Making C++ slightly less painful.
|
4
4
|
|
@@ -31,88 +31,69 @@ module RPlusPlus
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def objects_hash
|
34
|
-
@
|
35
|
-
@
|
34
|
+
@cpp_metadata ||= metadata_for_filetype('cpp')
|
35
|
+
@header_metadata ||= metadata_for_filetype('h')
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
hash[objectify cpp] = [cpp] | deps_for(info)
|
37
|
+
@cpp_metadata.each_with_object({}) do |(cpp_file, metadata), hash|
|
38
|
+
hash[objectify cpp_file] = [cpp_file] | dependencies_from_metadata(metadata)
|
40
39
|
end
|
41
|
-
hash
|
42
40
|
end
|
43
41
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
end
|
42
|
+
def dependencies_from_metadata metadata
|
43
|
+
dependency_dependencies = metadata[:dependencies].flat_map do |dependency|
|
44
|
+
dependencies_from_metadata(@header_metadata[dependency])
|
45
|
+
end
|
46
|
+
metadata[:dependencies] | dependency_dependencies
|
48
47
|
end
|
49
48
|
|
50
49
|
def builds_hash
|
51
50
|
objects
|
52
|
-
|
53
|
-
|
54
|
-
next unless info[:main]
|
55
|
-
|
56
|
-
hash[basename cpp] = obj_deps objectify(cpp)
|
51
|
+
@cpp_metadata.each_with_object({}) do |(cpp_file, metadata), hash|
|
52
|
+
hash[File.basename cpp_file, '.cpp'] = object_dependencies objectify(cpp_file) if metadata[:is_main]
|
57
53
|
end
|
58
|
-
hash
|
59
54
|
end
|
60
55
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
deps << o
|
68
|
-
deps |= obj_deps(o, [o,*visited])
|
56
|
+
def object_dependencies object_file, visited=[]
|
57
|
+
objects[object_file].each_with_object([]) do |source_dependency, dependencies|
|
58
|
+
object_dependency = objectify(source_dependency)
|
59
|
+
if !visited.include?(object_dependency) && objects.include?(object_dependency)
|
60
|
+
dependencies << object_dependency
|
61
|
+
dependencies |= object_dependencies(object_dependency, [object_dependency, *visited])
|
69
62
|
end
|
70
63
|
end
|
71
|
-
deps
|
72
64
|
end
|
73
65
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
hash[f] = info_for f
|
66
|
+
def metadata_for_filetype type
|
67
|
+
metadata = Dir[Pathname(@path).join("**/*.#{type}")].each_with_object({}) do |filename, hash|
|
68
|
+
hash[filename] = metadata_for filename
|
78
69
|
end
|
79
|
-
Dir[Pathname(@path).join("**/*.#{type}.erb")].
|
80
|
-
hash[
|
70
|
+
Dir[Pathname(@path).join("**/*.#{type}.erb")].each_with_object(metadata) do |filename, hash|
|
71
|
+
hash[File.basename filename, '.erb'] = metadata_for filename
|
81
72
|
end
|
82
|
-
hash
|
83
73
|
end
|
84
74
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
File.foreach(
|
89
|
-
|
90
|
-
|
91
|
-
|
75
|
+
def metadata_for filename
|
76
|
+
is_main = false
|
77
|
+
dependencies = []
|
78
|
+
File.foreach(filename) do |line|
|
79
|
+
is_main ||= is_main_declaration(line)
|
80
|
+
dependency = get_included_file line
|
81
|
+
dependencies << dependency if dependency
|
92
82
|
end
|
93
|
-
{
|
94
|
-
end
|
95
|
-
|
96
|
-
def unerb fn
|
97
|
-
fn.gsub(/\.erb$/,'')
|
83
|
+
{is_main: is_main, dependencies: dependencies}
|
98
84
|
end
|
99
85
|
|
100
|
-
def
|
101
|
-
|
86
|
+
def is_main_declaration line
|
87
|
+
!!(line =~ /^\W*int\W*main\(.*?\)/)
|
102
88
|
end
|
103
89
|
|
104
|
-
def
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
def include_match l
|
109
|
-
m = /#include "(?<file>.*)"/.match(l)
|
90
|
+
def get_included_file line
|
91
|
+
m = /#include "(?<file>.*)"/.match(line)
|
110
92
|
m[:file] if m
|
111
93
|
end
|
112
94
|
|
113
95
|
def objectify filename
|
114
96
|
filename.gsub(/\.(cpp|cpp\.erb|h|h\.erb)$/,'.o')
|
115
97
|
end
|
116
|
-
|
117
98
|
end
|
118
99
|
end
|
data/lib/rplusplus/version.rb
CHANGED
data/rplusplus.gemspec
CHANGED
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency "rake", "~> 10.3"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.0"
|
28
28
|
spec.add_development_dependency "pry", "~> 0.10"
|
29
|
-
spec.add_development_dependency "
|
29
|
+
spec.add_development_dependency "codeclimate-test-reporter", "~> 0.4"
|
30
30
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rplusplus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Smith
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.10'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: codeclimate-test-reporter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.4'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.4'
|
97
97
|
description: A collection of command-line tools for making C++ development easier.
|
98
98
|
email:
|
99
99
|
- jellymann@gmail.com
|