depcheck 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +50 -0
  3. data/Gemfile +5 -0
  4. data/Gemfile.lock +37 -0
  5. data/LICENSE +21 -0
  6. data/README.md +48 -0
  7. data/Rakefile +6 -0
  8. data/bin/depcheck +16 -0
  9. data/depcheck.gemspec +25 -0
  10. data/example/Example.xcodeproj/project.pbxproj +323 -0
  11. data/example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  12. data/example/Example.xcodeproj/project.xcworkspace/xcuserdata/wojtek.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  13. data/example/Example.xcodeproj/xcuserdata/wojtek.xcuserdatad/xcschemes/Example.xcscheme +91 -0
  14. data/example/Example.xcodeproj/xcuserdata/wojtek.xcuserdatad/xcschemes/xcschememanagement.plist +22 -0
  15. data/example/Example/AppDelegate.swift +16 -0
  16. data/example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +73 -0
  17. data/example/Example/Base.lproj/LaunchScreen.storyboard +27 -0
  18. data/example/Example/Base.lproj/Main.storyboard +26 -0
  19. data/example/Example/Info.plist +47 -0
  20. data/example/Example/Models/Model1.swift +14 -0
  21. data/example/Example/Models/Model2.swift +13 -0
  22. data/example/Example/Models/Model3.swift +13 -0
  23. data/example/Example/Models/Model4.swift +13 -0
  24. data/example/Example/Models/Model5.swift +15 -0
  25. data/example/Example/ViewController.swift +19 -0
  26. data/example/analyze.png +0 -0
  27. data/example/usage.png +0 -0
  28. data/lib/depcheck.rb +9 -0
  29. data/lib/depcheck/analyzer.rb +59 -0
  30. data/lib/depcheck/command/analyze_command.rb +17 -0
  31. data/lib/depcheck/command/usage_command.rb +17 -0
  32. data/lib/depcheck/command/version_command.rb +6 -0
  33. data/lib/depcheck/dependency_info.rb +13 -0
  34. data/lib/depcheck/finder.rb +33 -0
  35. data/lib/depcheck/output/simple_output.rb +21 -0
  36. data/lib/depcheck/version.rb +3 -0
  37. metadata +136 -0
@@ -0,0 +1,17 @@
1
+ class AnalyzeCommand < Clamp::Command
2
+ option ['--project'], 'PROJECT', 'Path to the xcodeproj'
3
+ option ['--scheme'], 'SCHEME', 'The scheme that the project was built in'
4
+ option ['--workspace'], 'WORKSPACE', 'Path to the workspace'
5
+
6
+ def execute
7
+
8
+ unless project || (workspace && scheme)
9
+ raise StandardError, 'Must provide project path or workspace path with scheme.'
10
+ end
11
+
12
+ swiftdeps = Depcheck::Finder.find_swiftdeps(project, workspace, scheme)
13
+ results = Depcheck::Analyzer.generate_dependencies(swiftdeps)
14
+ Depcheck::SimpleOutput.post(results)
15
+ end
16
+
17
+ end
@@ -0,0 +1,17 @@
1
+ class UsageCommand < Clamp::Command
2
+ option ['--project'], 'PROJECT', 'Path to the xcodeproj'
3
+ option ['--scheme'], 'SCHEME', 'The scheme that the project was built in'
4
+ option ['--workspace'], 'WORKSPACE', 'Path to the workspace'
5
+
6
+ def execute
7
+
8
+ unless project || (workspace && scheme)
9
+ raise StandardError, 'Must provide project path or workspace path with scheme.'
10
+ end
11
+
12
+ swiftdeps = Depcheck::Finder.find_swiftdeps(project, workspace, scheme)
13
+ results = Depcheck::Analyzer.generate_dependencies(swiftdeps)
14
+ Depcheck::SimpleOutput.post_usage(results)
15
+ end
16
+
17
+ end
@@ -0,0 +1,6 @@
1
+ class VersionCommand < Clamp::Command
2
+
3
+ def execute
4
+ puts "depcheck #{Depcheck::VERSION}"
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module Depcheck
2
+ class DependencyInfo
3
+ attr_accessor :name, :nominal, :dependencies, :usage
4
+
5
+ def initialize(name, nominal, dependencies)
6
+ self.name = name
7
+ self.nominal = nominal
8
+ self.dependencies = dependencies
9
+ self.usage = 0
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ module Depcheck
2
+ module Finder
3
+
4
+ def self.find_derived_data_path(project, workspace, scheme)
5
+ arg = if project
6
+ "-project \"#{project}\""
7
+ else
8
+ "-workspace \"#{workspace}\" -scheme \"#{scheme}\""
9
+ end
10
+
11
+ build_settings = `xcodebuild #{arg} -showBuildSettings build CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO 2>&1`
12
+
13
+ if build_settings
14
+ derived_data_path = build_settings.match(/ OBJROOT = (.+)/)
15
+ derived_data_path = derived_data_path[1] if derived_data_path
16
+ end
17
+
18
+ derived_data_path
19
+ end
20
+
21
+ def self.find_swiftdeps(project, workspace, scheme)
22
+ derived_data_path = find_derived_data_path(project, workspace, scheme)
23
+ swiftdeps = Dir.glob("#{derived_data_path}/**/*.swiftdeps") if derived_data_path
24
+
25
+ if swiftdeps.nil? || swiftdeps.empty?
26
+ raise StandardError, 'No derived data found. Please make sure the project was built.'
27
+ end
28
+
29
+ swiftdeps
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,21 @@
1
+ module Depcheck
2
+ module SimpleOutput
3
+
4
+ def self.post(objs)
5
+ objs = objs.sort_by { |obj| obj.dependencies.size }.reverse
6
+
7
+ objs.each_with_index do |obj, index|
8
+ puts "#{index + 1}. #{obj.name} - #{obj.dependencies.size} \n"
9
+ end
10
+ end
11
+
12
+ def self.post_usage(objs)
13
+ objs = objs.sort_by(&:usage).reverse
14
+
15
+ objs.each_with_index do |obj, index|
16
+ puts "#{index + 1}. #{obj.name} - #{obj.usage} \n"
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Depcheck
2
+ VERSION = '0.1.0' unless defined?(Depcheck::VERSION)
3
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: depcheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Wojciech Lukaszuk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: clamp
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ description:
70
+ email:
71
+ - wojciech.lukaszuk@icloud.com
72
+ executables:
73
+ - depcheck
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - bin/depcheck
84
+ - depcheck.gemspec
85
+ - example/Example.xcodeproj/project.pbxproj
86
+ - example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata
87
+ - example/Example.xcodeproj/project.xcworkspace/xcuserdata/wojtek.xcuserdatad/UserInterfaceState.xcuserstate
88
+ - example/Example.xcodeproj/xcuserdata/wojtek.xcuserdatad/xcschemes/Example.xcscheme
89
+ - example/Example.xcodeproj/xcuserdata/wojtek.xcuserdatad/xcschemes/xcschememanagement.plist
90
+ - example/Example/AppDelegate.swift
91
+ - example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json
92
+ - example/Example/Base.lproj/LaunchScreen.storyboard
93
+ - example/Example/Base.lproj/Main.storyboard
94
+ - example/Example/Info.plist
95
+ - example/Example/Models/Model1.swift
96
+ - example/Example/Models/Model2.swift
97
+ - example/Example/Models/Model3.swift
98
+ - example/Example/Models/Model4.swift
99
+ - example/Example/Models/Model5.swift
100
+ - example/Example/ViewController.swift
101
+ - example/analyze.png
102
+ - example/usage.png
103
+ - lib/depcheck.rb
104
+ - lib/depcheck/analyzer.rb
105
+ - lib/depcheck/command/analyze_command.rb
106
+ - lib/depcheck/command/usage_command.rb
107
+ - lib/depcheck/command/version_command.rb
108
+ - lib/depcheck/dependency_info.rb
109
+ - lib/depcheck/finder.rb
110
+ - lib/depcheck/output/simple_output.rb
111
+ - lib/depcheck/version.rb
112
+ homepage: https://github.com/wojteklu/depcheck
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.4.6
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Dependency analyzer tool for Swift projects
136
+ test_files: []