mayday 0.0.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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +46 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +80 -0
  6. data/Rakefile +2 -0
  7. data/bin/mayday +33 -0
  8. data/lib/mayday/abstract_flag/error.rb +7 -0
  9. data/lib/mayday/abstract_flag/warning.rb +11 -0
  10. data/lib/mayday/abstract_flag.rb +90 -0
  11. data/lib/mayday/error.rb +7 -0
  12. data/lib/mayday/reader.rb +108 -0
  13. data/lib/mayday/script_generator.rb +74 -0
  14. data/lib/mayday/target_integrator.rb +69 -0
  15. data/lib/mayday/user_definitions.rb +42 -0
  16. data/lib/mayday/version.rb +3 -0
  17. data/lib/mayday/warning.rb +11 -0
  18. data/lib/mayday.rb +2 -0
  19. data/mayday.gemspec +30 -0
  20. data/spec/fixtures/Fixtures/Fixtures/AppDelegate.swift +46 -0
  21. data/spec/fixtures/Fixtures/Fixtures/Base.lproj/LaunchScreen.xib +41 -0
  22. data/spec/fixtures/Fixtures/Fixtures/Base.lproj/Main.storyboard +25 -0
  23. data/spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.h +13 -0
  24. data/spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.m +15 -0
  25. data/spec/fixtures/Fixtures/Fixtures/Images.xcassets/AppIcon.appiconset/Contents.json +38 -0
  26. data/spec/fixtures/Fixtures/Fixtures/Info.plist +40 -0
  27. data/spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.h +13 -0
  28. data/spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.m +16 -0
  29. data/spec/fixtures/Fixtures/Fixtures/SomeDir/Fixtures-Bridging-Header.h +4 -0
  30. data/spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.h +5 -0
  31. data/spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.m +547 -0
  32. data/spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.h +15 -0
  33. data/spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.m +18 -0
  34. data/spec/fixtures/Fixtures/Fixtures/ViewController.swift +26 -0
  35. data/spec/fixtures/Fixtures/Fixtures.xcodeproj/project.pbxproj +487 -0
  36. data/spec/fixtures/Fixtures/Fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  37. data/spec/fixtures/Fixtures/Fixtures.xcodeproj/xcuserdata/marklarsen.xcuserdatad/xcschemes/Fixtures.xcscheme +110 -0
  38. data/spec/fixtures/Fixtures/FixturesTests/FixturesTests.swift +36 -0
  39. data/spec/fixtures/Fixtures/FixturesTests/Info.plist +24 -0
  40. data/spec/fixtures/Maydayfile +22 -0
  41. data/spec/fixtures/Maydayfile_ruby_error +11 -0
  42. data/spec/mayday/user_definitions_spec.rb +177 -0
  43. data/spec/spec_helper.rb +16 -0
  44. metadata +223 -0
@@ -0,0 +1,11 @@
1
+ xcode_proj "Fixtures/Fixtures.xcodeproj"
2
+ main_target "Fixtures"
3
+
4
+ warning :line, :language => "swift" do |line|
5
+ raise "error"
6
+ line.length > 120 ? "Length of line #{line.length} is longer than 120 characters!" : nil
7
+ end
8
+
9
+ error_regex "Please remove Copyright boilerplate", /^\/\/ Copyright \(c\).*$/, :files => "*AppDelegate*", :exclude => "Fixtures/SomeDir/Excluded/*"
10
+
11
+ warning_regex "TODO", /^\/\/\s+TODO:.*$/
@@ -0,0 +1,177 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mayday::UserDefinitions do
4
+
5
+ def parse_build_output
6
+ output =`xcodebuild -project spec/test_fixtures/Fixtures/Fixtures.xcodeproj/ -scheme Fixtures -configuration Debug`
7
+ exitstatus = $?.exitstatus
8
+ files_to_lines_to_warnings_hash = {}
9
+ output.split("\n").each do |line|
10
+ matches = line.match(/((.+):([0-9]+):\s(.+))/)
11
+ if matches
12
+ file_path = matches[2]
13
+ line_number = matches[3]
14
+ flag_message = matches[4]
15
+
16
+ files_to_lines_to_warnings_hash[file_path] ||= {}
17
+ files_to_lines_to_warnings_hash[file_path][line_number] ||= []
18
+ files_to_lines_to_warnings_hash[file_path][line_number] << flag_message
19
+ end
20
+ end
21
+ { :exitstatus => exitstatus, :files_to_lines_to_warnings_hash => files_to_lines_to_warnings_hash }
22
+ end
23
+
24
+ def create_mayday_file(&block)
25
+ string = block.to_source
26
+ file = File.open("Maydayfile_rspec_generated", "w")
27
+ file.write(block.to_source + ".call")
28
+ file
29
+ end
30
+
31
+ def with_captured_stdout
32
+ begin
33
+ old_stdout = $stdout
34
+ $stdout = StringIO.new('','w')
35
+ yield
36
+ $stdout.string
37
+ ensure
38
+ $stdout = old_stdout
39
+ end
40
+ end
41
+
42
+ let(:files_to_lines_to_warnings_hash) { @parsed_build_output[:files_to_lines_to_warnings_hash] }
43
+
44
+ describe "#up" do
45
+ describe "after running xcodebuild" do
46
+ before(:all) do
47
+ user_definitions = Mayday::UserDefinitions.new(FIXTURES_TEST_MAYDAY_FILE_PATH)
48
+ user_definitions.up
49
+ @parsed_build_output = parse_build_output
50
+ end
51
+
52
+ it "should have failed the build" do
53
+ expect(@parsed_build_output[:exitstatus]).to_not eq(0)
54
+ end
55
+
56
+ it "should have output all files with warnings or errors in them" do
57
+ expect(files_to_lines_to_warnings_hash.count).to eq(3)
58
+ end
59
+
60
+ it "should have, for every file, output all of the warnings or errors in them" do
61
+ some_object_h_flags = files_to_lines_to_warnings_hash['/Users/marklarsen/github.com/mayday/spec/test_fixtures/Fixtures/Fixtures/SomeDir/SomeObject.h']
62
+ app_delegate_swift_flags = files_to_lines_to_warnings_hash['/Users/marklarsen/github.com/mayday/spec/test_fixtures/Fixtures/Fixtures/AppDelegate.swift']
63
+ long_file_m_flags = files_to_lines_to_warnings_hash['/Users/marklarsen/github.com/mayday/spec/test_fixtures/Fixtures/Fixtures/SomeDir/LongFile.m']
64
+
65
+ expect(some_object_h_flags.count).to eq(1)
66
+ expect(app_delegate_swift_flags.count).to eq(9)
67
+ expect(long_file_m_flags.count).to eq(1)
68
+ end
69
+ end
70
+
71
+ describe "when using a Maydayfile containing Ruby errors" do
72
+ it "should raise the exception to the user when they try to 'up'" do
73
+ user_definitions = Mayday::UserDefinitions.new(FIXTURES_TEST_MAYDAY_FILE_RUBY_ERROR_PATH)
74
+ expect { user_definitions.up }.to raise_error("error")
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "#down" do
80
+ describe "after running xcodebuild" do
81
+ before(:all) do
82
+ user_definitions = Mayday::UserDefinitions.new(FIXTURES_TEST_MAYDAY_FILE_PATH)
83
+ user_definitions.up
84
+ user_definitions.down
85
+ @parsed_build_output = parse_build_output
86
+ end
87
+
88
+ it "should have passed the build" do
89
+ expect(@parsed_build_output[:exitstatus]).to eq(0)
90
+ end
91
+
92
+ it "should have no warnings or errors from Mayday" do
93
+ expect(files_to_lines_to_warnings_hash.count).to eq(0)
94
+ end
95
+ end
96
+ end
97
+
98
+ describe "#benchmark" do
99
+ it "should show benchmark data for the mayday build phase" do
100
+ user_definitions = Mayday::UserDefinitions.new(FIXTURES_TEST_MAYDAY_FILE_PATH)
101
+ output = with_captured_stdout { user_definitions.benchmark }
102
+ matches = output.match /\s+user\s+system\s+total\s+real\nMayday\s+([0-9]+\.[0-9]+)\s+([0-9]+\.[0-9]+)\s+([0-9]+\.[0-9]+).+([0-9]+\.[0-9]+)/
103
+
104
+ expect(matches.size).to eq(5)
105
+
106
+ real_time = matches[4].to_f
107
+ real_time.should be > 0.0
108
+ end
109
+
110
+ describe "after running xcodebuild" do
111
+ before(:all) do
112
+ user_definitions = Mayday::UserDefinitions.new(FIXTURES_TEST_MAYDAY_FILE_PATH)
113
+ user_definitions.benchmark
114
+ @parsed_build_output = parse_build_output
115
+ end
116
+
117
+ it "should have passed the build" do
118
+ expect(@parsed_build_output[:exitstatus]).to eq(0)
119
+ end
120
+
121
+ it "should have no warnings or errors from Mayday" do
122
+ expect(files_to_lines_to_warnings_hash.count).to eq(0)
123
+ end
124
+ end
125
+ end
126
+
127
+ describe "when the Maydayfile has no xcode_proj defined" do
128
+ it "should abort" do
129
+ mayday_file = create_mayday_file do
130
+ main_target "hey"
131
+ warning { |line| return nil }
132
+ error { |line| return "ERROR!" }
133
+ end
134
+
135
+ lambda { Mayday::UserDefinitions.new(mayday_file.path).up }.should raise_error SystemExit
136
+ end
137
+ end
138
+
139
+ describe "when the Maydayfile has no main_target_name defined" do
140
+ it "should abort" do
141
+ mayday_file = create_mayday_file do
142
+ xcode_proj "../spec/test_fixtures/Maydayfile"
143
+ warning { |line| return nil }
144
+ error { |line| return "ERROR!" }
145
+ end
146
+
147
+ lambda { Mayday::UserDefinitions.new(mayday_file.path).up }.should raise_error SystemExit
148
+ end
149
+ end
150
+
151
+ describe "when the Maydayfile cannot find the xcode_proj defined" do
152
+ it "should abort" do
153
+ mayday_file = create_mayday_file do
154
+ xcode_proj "Hi.xcodeproj"
155
+ main_target_name "wut"
156
+ warning { |line| return nil }
157
+ error { |line| return "ERROR!" }
158
+ end
159
+
160
+ lambda { Mayday::UserDefinitions.new(mayday_file.path).up }.should raise_error SystemExit
161
+ end
162
+ end
163
+
164
+ describe "when the Maydayfile cannot find the main_target_name defined" do
165
+ it "should abort" do
166
+ mayday_file = create_mayday_file do
167
+ xcode_proj "../spec/test_fixtures/Maydayfile"
168
+ main_target_name "Nonexistent"
169
+ warning { |line| return nil }
170
+ error { |line| return "ERROR!" }
171
+ end
172
+
173
+ lambda { Mayday::UserDefinitions.new(mayday_file.path).up }.should raise_error SystemExit
174
+ end
175
+ end
176
+
177
+ end
@@ -0,0 +1,16 @@
1
+ require 'bundler/setup'
2
+ require 'mayday'
3
+ require 'pry'
4
+ require 'xcodeproj'
5
+
6
+ PROJECT_FIXTURES_PATH = File.expand_path('../fixtures', __FILE__)
7
+ PROJECT_FIXTURES_TEST_PATH = File.expand_path('../test_fixtures', __FILE__)
8
+ PROJECT_FIXTURES_TEST_PROJECT_PATH= File.join(PROJECT_FIXTURES_TEST_PATH, 'fixtures/Fixtures.xcodeproj')
9
+ FileUtils.rm_rf(PROJECT_FIXTURES_TEST_PATH)
10
+ FileUtils.cp_r(PROJECT_FIXTURES_PATH, PROJECT_FIXTURES_TEST_PATH)
11
+ PROJECT_FIXTURES_TEST_PROJECT = Xcodeproj::Project.open(PROJECT_FIXTURES_TEST_PROJECT_PATH)
12
+ FIXTURES_TEST_MAYDAY_FILE_PATH = File.join(PROJECT_FIXTURES_TEST_PATH, 'Maydayfile')
13
+ FIXTURES_TEST_MAYDAY_FILE_RUBY_ERROR_PATH = File.join(PROJECT_FIXTURES_TEST_PATH, 'Maydayfile_ruby_error')
14
+
15
+ RSpec.configure do |config|
16
+ end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mayday
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mark Larsen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-20 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: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: clamp
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.3
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: colored
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sourcify
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.6.0rc4
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.6.0rc4
111
+ - !ruby/object:Gem::Dependency
112
+ name: xcodeproj
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.19.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.19.3
125
+ description: Custom warnings and errors
126
+ email:
127
+ - larse503@gmail.com
128
+ executables:
129
+ - mayday
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - bin/mayday
139
+ - lib/mayday.rb
140
+ - lib/mayday/abstract_flag.rb
141
+ - lib/mayday/abstract_flag/error.rb
142
+ - lib/mayday/abstract_flag/warning.rb
143
+ - lib/mayday/error.rb
144
+ - lib/mayday/reader.rb
145
+ - lib/mayday/script_generator.rb
146
+ - lib/mayday/target_integrator.rb
147
+ - lib/mayday/user_definitions.rb
148
+ - lib/mayday/version.rb
149
+ - lib/mayday/warning.rb
150
+ - mayday.gemspec
151
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/project.pbxproj
152
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
153
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/xcuserdata/marklarsen.xcuserdatad/xcschemes/Fixtures.xcscheme
154
+ - spec/fixtures/Fixtures/Fixtures/AppDelegate.swift
155
+ - spec/fixtures/Fixtures/Fixtures/Base.lproj/LaunchScreen.xib
156
+ - spec/fixtures/Fixtures/Fixtures/Base.lproj/Main.storyboard
157
+ - spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.h
158
+ - spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.m
159
+ - spec/fixtures/Fixtures/Fixtures/Images.xcassets/AppIcon.appiconset/Contents.json
160
+ - spec/fixtures/Fixtures/Fixtures/Info.plist
161
+ - spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.h
162
+ - spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.m
163
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/Fixtures-Bridging-Header.h
164
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.h
165
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.m
166
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.h
167
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.m
168
+ - spec/fixtures/Fixtures/Fixtures/ViewController.swift
169
+ - spec/fixtures/Fixtures/FixturesTests/FixturesTests.swift
170
+ - spec/fixtures/Fixtures/FixturesTests/Info.plist
171
+ - spec/fixtures/Maydayfile
172
+ - spec/fixtures/Maydayfile_ruby_error
173
+ - spec/mayday/user_definitions_spec.rb
174
+ - spec/spec_helper.rb
175
+ homepage: ''
176
+ licenses:
177
+ - MIT
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.2.2
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: Custom warnings and errors
199
+ test_files:
200
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/project.pbxproj
201
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/project.xcworkspace/contents.xcworkspacedata
202
+ - spec/fixtures/Fixtures/Fixtures.xcodeproj/xcuserdata/marklarsen.xcuserdatad/xcschemes/Fixtures.xcscheme
203
+ - spec/fixtures/Fixtures/Fixtures/AppDelegate.swift
204
+ - spec/fixtures/Fixtures/Fixtures/Base.lproj/LaunchScreen.xib
205
+ - spec/fixtures/Fixtures/Fixtures/Base.lproj/Main.storyboard
206
+ - spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.h
207
+ - spec/fixtures/Fixtures/Fixtures/Excluded/ExcludedFile.m
208
+ - spec/fixtures/Fixtures/Fixtures/Images.xcassets/AppIcon.appiconset/Contents.json
209
+ - spec/fixtures/Fixtures/Fixtures/Info.plist
210
+ - spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.h
211
+ - spec/fixtures/Fixtures/Fixtures/Pods/SomePodObject.m
212
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/Fixtures-Bridging-Header.h
213
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.h
214
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/LongFile.m
215
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.h
216
+ - spec/fixtures/Fixtures/Fixtures/SomeDir/SomeObject.m
217
+ - spec/fixtures/Fixtures/Fixtures/ViewController.swift
218
+ - spec/fixtures/Fixtures/FixturesTests/FixturesTests.swift
219
+ - spec/fixtures/Fixtures/FixturesTests/Info.plist
220
+ - spec/fixtures/Maydayfile
221
+ - spec/fixtures/Maydayfile_ruby_error
222
+ - spec/mayday/user_definitions_spec.rb
223
+ - spec/spec_helper.rb