codeinventory 0.1.3 → 0.2.0
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 +4 -4
- data/lib/codeinventory/cli/app.rb +8 -0
- data/lib/codeinventory/cli/combine.rb +42 -0
- data/lib/codeinventory/cli/csv.rb +4 -4
- data/lib/codeinventory/cli/json.rb +4 -4
- data/lib/codeinventory/cli.rb +2 -4
- data/lib/codeinventory/inventory.rb +8 -0
- data/lib/codeinventory/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52632d5e404811eb03727b173a2265e5186597c2
|
4
|
+
data.tar.gz: d5a5d2ba4fa4d47a61aa96e2abe69c65b4f0e0fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b47dc08ef098ef7d7024e97a4fcd1e6964a006cadd0e4494a7351c745c92fe1d8da4b5e392e3e93782f45adaa8bd369aef065e6c93601a275ac30068269fc58
|
7
|
+
data.tar.gz: e961bf9d33e4c7bc18e0d2ffcd362cf5a381c2c55394ef5c023e7fd66ef021f442bc487fde83a6477b6ae0b9b5851e836d82bdb3bc894004ce8f6a007eb1945a
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module CodeInventory
|
5
|
+
module CLI
|
6
|
+
class App < Thor
|
7
|
+
desc "combine AGENCY FILENAMES ...", "Combine multiple code.json files"
|
8
|
+
option :replace, aliases: "-r", type: :boolean, desc: "Replace all projects' organization field values with the agency name from each existing code.json"
|
9
|
+
option :pretty, aliases: "-p", type: :boolean, desc: "Format JSON output with linebreaks and indentation"
|
10
|
+
def combine(agency, *filenames)
|
11
|
+
if filenames.count == 0
|
12
|
+
puts "You must provide at least one code.json file"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
combined = {
|
16
|
+
"version" => "1.0.1",
|
17
|
+
"agency" => agency,
|
18
|
+
"projects" => []
|
19
|
+
}
|
20
|
+
filenames.each do |filename|
|
21
|
+
if !File.exist? filename
|
22
|
+
puts "File not found: #{filename}"
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
inventory = JSON.load(File.new(filename))
|
26
|
+
projects = inventory["projects"]
|
27
|
+
if options[:replace]
|
28
|
+
projects.each do |project|
|
29
|
+
project["organization"] = inventory["agency"] if !inventory["agency"].nil?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
combined["projects"].concat(projects)
|
33
|
+
end
|
34
|
+
if options["pretty"]
|
35
|
+
puts JSON.pretty_generate(combined)
|
36
|
+
else
|
37
|
+
puts combined.to_json
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -5,8 +5,8 @@ require "pathname"
|
|
5
5
|
module CodeInventory
|
6
6
|
module CLI
|
7
7
|
class App < Thor
|
8
|
-
desc "csv FILENAME", "Build an inventory from a CSV file"
|
9
|
-
def csv(filename)
|
8
|
+
desc "csv AGENCY FILENAME", "Build an inventory from a CSV file"
|
9
|
+
def csv(agency, filename)
|
10
10
|
file = Pathname.new(filename)
|
11
11
|
unless File.exist? file
|
12
12
|
puts "No such file: #{file}"
|
@@ -14,8 +14,8 @@ module CodeInventory
|
|
14
14
|
end
|
15
15
|
source = CodeInventory::CSVFile.new(file)
|
16
16
|
inventory = CodeInventory::Inventory.new(source)
|
17
|
-
|
18
|
-
puts JSON.pretty_generate(
|
17
|
+
output = inventory.generate(agency, "1.0.1")
|
18
|
+
puts JSON.pretty_generate(output)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -5,8 +5,8 @@ require "pathname"
|
|
5
5
|
module CodeInventory
|
6
6
|
module CLI
|
7
7
|
class App < Thor
|
8
|
-
desc "json FILENAME", "Build an inventory from a JSON file"
|
9
|
-
def json(filename)
|
8
|
+
desc "json AGENCY FILENAME", "Build an inventory from a JSON file"
|
9
|
+
def json(agency, filename)
|
10
10
|
file = Pathname.new(filename)
|
11
11
|
unless File.exist? file
|
12
12
|
puts "No such file: #{file}"
|
@@ -14,8 +14,8 @@ module CodeInventory
|
|
14
14
|
end
|
15
15
|
source = CodeInventory::JSONFile.new(file)
|
16
16
|
inventory = CodeInventory::Inventory.new(source)
|
17
|
-
|
18
|
-
puts JSON.pretty_generate(
|
17
|
+
output = inventory.generate(agency, "1.0.1")
|
18
|
+
puts JSON.pretty_generate(output)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/lib/codeinventory/cli.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require "codeinventory"
|
2
|
-
require "
|
2
|
+
require "codeinventory/cli/app"
|
3
3
|
require "codeinventory/cli/csv"
|
4
4
|
require "codeinventory/cli/json"
|
5
|
+
require "codeinventory/cli/combine"
|
5
6
|
|
6
7
|
module CodeInventory
|
7
8
|
module CLI
|
8
|
-
class App < Thor
|
9
|
-
end
|
10
|
-
|
11
9
|
def self.start
|
12
10
|
plugin_files = Gem.find_latest_files('codeinventory_plugin.rb')
|
13
11
|
plugin_files.each do |plugin_file|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeinventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fredrickson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -130,6 +130,8 @@ files:
|
|
130
130
|
- exe/codeinv
|
131
131
|
- lib/codeinventory.rb
|
132
132
|
- lib/codeinventory/cli.rb
|
133
|
+
- lib/codeinventory/cli/app.rb
|
134
|
+
- lib/codeinventory/cli/combine.rb
|
133
135
|
- lib/codeinventory/cli/csv.rb
|
134
136
|
- lib/codeinventory/cli/json.rb
|
135
137
|
- lib/codeinventory/csv_file.rb
|