mayday 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c78e754b1dc60b302813defb808feecea2b0d056
4
+ data.tar.gz: f2e8d5ef9935f9d5a132e04b2be0e2219aad00a5
5
+ SHA512:
6
+ metadata.gz: 8ff4fe103f6da0e9ca701f807b81c9f7d9f38c360e511db50c5f604b75012ecd88bd2cd9923212bdb3bb5fbfd99ed551a0264852e0ff9e75921ce4e01b4a6ab4
7
+ data.tar.gz: 9439827e1a41aa7dd6aca66c268d88c06c80fe5327a87de0b59373d6066df108c8919f2c67a2e1e4a10e58b182a1bf2518d1b35c2825531cb86f9f9ab2ca23bf
data/.gitignore ADDED
@@ -0,0 +1,46 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ # Xcode
25
+ build/
26
+ *.pbxuser
27
+ !default.pbxuser
28
+ *.mode1v3
29
+ !default.mode1v3
30
+ *.mode2v3
31
+ !default.mode2v3
32
+ *.perspectivev3
33
+ !default.perspectivev3
34
+ xcuserdata
35
+ *.xccheckout
36
+ *.moved-aside
37
+ DerivedData
38
+ *.hmap
39
+ *.ipa
40
+ *.xcuserstate
41
+ *.DS_Store
42
+
43
+
44
+ # Spec
45
+ spec/test_fixtures/
46
+ Maydayfile_rspec_generated
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mayday.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Mark Larsen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ Easily add custom warnings and errors to your Xcode project's build process.
2
+
3
+ ## Installation
4
+
5
+ $ gem install mayday
6
+
7
+ ## Usage
8
+
9
+ Create a Maydayfile at the root of your project, defining your warnings and errors using `warning`, `error`, `warning_regex`, and `error_regex`.
10
+
11
+ ```ruby
12
+ # Maydayfile
13
+
14
+ # Required
15
+ xcode_proj "CoolApp.xcodeproj"
16
+ # Required. This will most likely be the same name as your project.
17
+ main_target "CoolApp"
18
+
19
+ # Use regular expressions to define errors or warnings on a line-by-line basis
20
+
21
+ error_regex "Please remove Copyright boilerplate", /^\/\/ Copyright \(c\).*$/, :files => "*AppDelegate*", :exclude => "Fixtures/SomeDir/Excluded/*"
22
+
23
+ warning_regex "TODO", /^\/\/\s+TODO:.*$/
24
+
25
+ # Do more complicated checks or return dynamic messages via blocks
26
+ warning :line do |line|
27
+ line.length > 120 ? "Length of line #{line.length} is longer than 120 characters!" : false
28
+ end
29
+
30
+ # You can get the whole file, too
31
+ error :file do |entire_file|
32
+ max_number_of_lines = 500
33
+
34
+ number_of_code_or_comment_lines = entire_file.split("\n").select { |line| line.strip.length > 0 }.count
35
+ if number_of_code_or_comment_lines > max_number_of_lines
36
+ # Map line numbers to errors
37
+ { "1" => "File is #{number_of_code_or_comment_lines} lines long" }
38
+ else
39
+ false
40
+ end
41
+ end
42
+
43
+ ```
44
+
45
+ And then,
46
+
47
+ $ mayday
48
+
49
+ ### Options
50
+
51
+ `warning`, `error`, `warning_regex`, and `error_regex` all accept an options hash with any of the following options
52
+
53
+ * `language` limits to files in the provided language. Accepts `"swift"` and `"objective-c"`.
54
+ * `warning :line, :language => "swift" do ...`
55
+ * `files` limits to files that have an absolute path that matches the provided [globs](http://en.wikipedia.org/wiki/Glob_(programming)). Accepts an array.
56
+ * `warning_regex "Foo!", /^barbaz$/, :files => ["*.h"] do ...`
57
+ * `exclusions` doesn't run on files that have an absolute path that matches the provided [globs](http://en.wikipedia.org/wiki/Glob_(programming)). Accepts an array.
58
+ * `warning :line, :exclude => ["*/Pods/*"] do ...` **Note, Pods are excluded by default by mayday**
59
+
60
+ ## Benchmarking
61
+
62
+ You may be concerned about how much overhead this will add to your build process. To see how quickly your `mayday` checks execute, use
63
+
64
+ $ mayday benchmark
65
+
66
+ ## Caveats
67
+
68
+ * Since `mayday` uses [sourcify]() to write your custom `warning` and `errors` blocks to a build phase, all [gotchas in sourcify](https://github.com/ngty/sourcify#gotchas) apply to your blocks.
69
+ * Generating efficient code to write into the build phase is difficult. `MayDay::ScriptGenerator#to_ruby` could definitely by optimized.
70
+
71
+
72
+ ## Uninstallation
73
+
74
+ $ mayday down
75
+
76
+ ## Contributing
77
+
78
+ We'd love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We'll do our best to respond to your patch as soon as possible. You can also submit a [new Github issue](https://github.com/venmo/synx/issues/new) if you find bugs or have questions. :octocat:
79
+
80
+ Please make sure to follow our general coding style and add test coverage for new features!
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/mayday ADDED
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'clamp'
4
+ require 'mayday'
5
+
6
+ Clamp do
7
+
8
+ self.default_subcommand = "up"
9
+
10
+ MAYDAY_FILE_PATH = "Maydayfile"
11
+
12
+ subcommand "up", "Integrate the warnings and errors from Maydayfile into your Xcode project" do
13
+ def execute
14
+ puts "Integrating mayday into your project..."
15
+ Mayday::UserDefinitions.new(MAYDAY_FILE_PATH).up
16
+ puts "Done!"
17
+ end
18
+ end
19
+
20
+ subcommand "down", "Remove the warnings and errors from Maydayfile into your Xcode project" do
21
+ def execute
22
+ puts "Removing mayday from your project..."
23
+ Mayday::UserDefinitions.new(MAYDAY_FILE_PATH).down
24
+ puts "Done!"
25
+ end
26
+ end
27
+
28
+ subcommand "benchmark", "Output benchmark results of running your Maydayfile errors and warnings on your Xcode project" do
29
+ def execute
30
+ Mayday::UserDefinitions.new(MAYDAY_FILE_PATH).benchmark
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,7 @@
1
+ require "mayday/abstract_flag"
2
+
3
+ module Mayday
4
+ class Error < AbstractFlag
5
+
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require "mayday/error"
2
+
3
+ module Mayday
4
+ class Warning < Error
5
+
6
+ def message_prefix
7
+ "warning: "
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,90 @@
1
+ require 'sourcify'
2
+
3
+ module Mayday
4
+ class AbstractFlag
5
+
6
+ @@function_names = []
7
+
8
+ def initialize(block, options={})
9
+ @block = block
10
+
11
+ @include_file_globs = Array(options[:files])
12
+ @exclude_file_globs = Array(options[:exclude])
13
+
14
+ if options[:language]
15
+ language = options[:language].to_s
16
+ if language == "swift"
17
+ @include_file_globs << "*.swift"
18
+ elsif language == "objective-c"
19
+ @include_file_globs << "*.{h,m}"
20
+ else
21
+ puts "Unrecognized language '#{language}'".red
22
+ abort
23
+ end
24
+ end
25
+
26
+ @exclude_file_globs << "*Pods/*"
27
+ end
28
+
29
+ def message_prefix
30
+ ""
31
+ end
32
+
33
+ def block_string
34
+ case @block
35
+ when String
36
+ @block
37
+ when Proc
38
+ @block.to_source
39
+ else
40
+ raise TypeError, "#{self.class}'s block has invalid type of #{@block.class}"
41
+ end
42
+ end
43
+
44
+ def function_def_string
45
+ <<-CODE
46
+ def #{function_name}(file_path, file_contents)
47
+ #{file_fn_match_lines("file_path")}
48
+
49
+ line_number_to_warning_hash = lambda do
50
+ #{block_string}.call(file_contents)
51
+ end.call
52
+
53
+ if line_number_to_warning_hash && line_number_to_warning_hash.keys.count > 0
54
+ final_warning_array = []
55
+ line_number_to_warning_hash.map do |line_number, warning_str|
56
+ final_warning_array << "\#{file_path}:\#{line_number}: #{message_prefix}\#{warning_str} [Wmayday]"
57
+ end
58
+ final_warning_array.join("\n")
59
+ else
60
+ false
61
+ end
62
+ end
63
+ CODE
64
+ end
65
+
66
+ def file_fn_match_lines(file_path_var_name)
67
+ @file_fn_match_lines ||= begin
68
+ includes_chunk = @include_file_globs.map do |file_glob|
69
+ "return unless File.fnmatch(\"#{file_glob}\", #{file_path_var_name})"
70
+ end.join("\n")
71
+
72
+ excludes_chunk = @exclude_file_globs.map do |file_glob|
73
+ "return if File.fnmatch(\"#{file_glob}\", #{file_path_var_name})"
74
+ end.join("\n")
75
+
76
+ includes_chunk + "\n" + excludes_chunk
77
+ end
78
+ end
79
+ private :file_fn_match_lines
80
+
81
+ def function_name
82
+ @function_name ||= begin
83
+ # Enforce uniqueness
84
+ candidate_function_name = "abstract_flag_matcher_#{rand(10000)}"
85
+ @@function_names.include?(candidate_function_name) ? function_name : candidate_function_name
86
+ end
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,7 @@
1
+ require "mayday/abstract_flag"
2
+
3
+ module Mayday
4
+ class Error < AbstractFlag
5
+
6
+ end
7
+ end
@@ -0,0 +1,108 @@
1
+ require 'mayday/target_integrator'
2
+ require 'mayday/script_generator'
3
+ require 'mayday/abstract_flag/warning'
4
+ require 'mayday/abstract_flag/error'
5
+
6
+ require 'pathname'
7
+
8
+ module Mayday
9
+ class Reader
10
+
11
+ def initialize(mayday_file)
12
+ @mayday_file = mayday_file
13
+ @script_generator = ScriptGenerator.new
14
+ end
15
+
16
+ def to_target_integrator
17
+ instance_eval(@mayday_file.read, @mayday_file.path, 0)
18
+ validate_xcode_proj
19
+ validate_main_target_name
20
+ TargetIntegrator.new(@xcode_proj, @script_generator, @main_target_name)
21
+ end
22
+
23
+ def main_target(main_target_name)
24
+ @main_target_name = main_target_name
25
+ end
26
+
27
+ def xcode_proj(xcode_proj_path)
28
+ real_xcodeproj_path = File.join(Pathname.new(@mayday_file.path).realpath.parent, xcode_proj_path)
29
+ @xcode_proj = Xcodeproj::Project.open(real_xcodeproj_path)
30
+ end
31
+
32
+ def warning_regex(message, regex, options={})
33
+ abstract_flag_regex(Warning, message, regex, options)
34
+ end
35
+
36
+ def error_regex(message, regex, options={})
37
+ abstract_flag_regex(Error, message, regex, options)
38
+ end
39
+
40
+ def validate_xcode_proj
41
+ unless @xcode_proj
42
+ puts "No Xcode project specified in #{@mayday_file.path}. Specify one using xcode_proj 'Path/To/MyProject.xcodeproj'".red
43
+ abort
44
+ end
45
+ end
46
+ private :validate_xcode_proj
47
+
48
+ def validate_main_target_name
49
+ unless @main_target_name
50
+ puts "No main target specified in #{@mayday_file.path}. Specify one using main_target_name 'My Target'".red
51
+ abort
52
+ end
53
+ end
54
+ private :validate_xcode_proj
55
+
56
+ def abstract_flag_regex(klass, message, regex, options={})
57
+ block = <<-CODE
58
+ lambda do |line|
59
+ line =~ Regexp.new('#{regex}') ? "#{message}" : nil
60
+ end
61
+ CODE
62
+ abstract_flag(klass, :line, block, options)
63
+ end
64
+ private :abstract_flag_regex
65
+
66
+ def warning(type, options={}, &block)
67
+ abstract_flag(Warning, type, block, options)
68
+ end
69
+ private :warning
70
+
71
+ def error(type, options={}, &block)
72
+ abstract_flag(Error, type, block, options)
73
+ end
74
+ private :error
75
+
76
+ def abstract_flag(klass, type, block, options={})
77
+ block_str = case block
78
+ when String
79
+ block
80
+ when Proc
81
+ block.to_source
82
+ else
83
+ raise TypeError, "#{self.class}'s block has invalid type of #{@block.class}"
84
+ end
85
+
86
+ final_block = case type
87
+ when :line
88
+ <<-CODE
89
+ lambda do |file_contents|
90
+ hash = {}
91
+ lines = file_contents.split("\n")
92
+ lines.each_with_index do |line, line_number|
93
+ message = #{block_str}.call(line)
94
+ hash[line_number + 1] = message if message
95
+ end
96
+ hash
97
+ end
98
+ CODE
99
+ when :file
100
+ block
101
+ end
102
+
103
+ @script_generator.flags << klass.new(final_block, options)
104
+ end
105
+ private :abstract_flag
106
+
107
+ end
108
+ end
@@ -0,0 +1,74 @@
1
+ require "mayday/abstract_flag/error"
2
+ require "mayday/abstract_flag/warning"
3
+
4
+ require 'pathname'
5
+
6
+ module Mayday
7
+ class ScriptGenerator
8
+
9
+ attr_accessor :flags
10
+
11
+ def initialize
12
+ self.flags = []
13
+ end
14
+
15
+ def to_ruby(opts={})
16
+ opts[:exit_after] = true if opts[:exit_after] == nil;
17
+ opts[:output] = true if opts[:output] == nil;
18
+
19
+ function_defs = flags.map(&:function_def_string).join
20
+ exit_chunk = if opts[:exit_after]
21
+ <<-CODE
22
+ if #{any_errors_variable_name}
23
+ exit(1)
24
+ else
25
+ exit
26
+ end
27
+ CODE
28
+ else
29
+ ""
30
+ end
31
+
32
+ call_flag_functions_chunk = call_flag_functions_string("file", opts[:output])
33
+
34
+ # Return the final code blob
35
+
36
+ <<-CODE
37
+ # encoding: utf-8
38
+ Encoding.default_external = "utf-8"
39
+
40
+ #{function_defs}
41
+
42
+ Dir[ENV["SRCROOT"] + "/**/*.{m,h,swift}"].each do |filename|
43
+ # Could be a dir with .m, like Underscore.m's dir
44
+ if (File.file?(filename))
45
+ file = File.open(filename, 'r')
46
+ #{call_flag_functions_chunk}
47
+ end
48
+ end
49
+
50
+ #{exit_chunk}
51
+ CODE
52
+ end
53
+
54
+ def call_flag_functions_string(file_var_name, output)
55
+ "file_contents = file.read\n" + flags.map do |flag|
56
+ any_errors_line = flag.class == Mayday::Error ? "#{any_errors_variable_name} = true" : ""
57
+ <<-CODE
58
+ abstract_flag_output = #{flag.function_name}(#{file_var_name}.path, file_contents)
59
+ if abstract_flag_output && #{output}
60
+ puts abstract_flag_output
61
+ #{any_errors_line}
62
+ end
63
+ CODE
64
+ end.join("\n")
65
+ end
66
+ private :call_flag_functions_string
67
+
68
+ def any_errors_variable_name
69
+ "@any_errors"
70
+ end
71
+ private :any_errors_variable_name
72
+
73
+ end
74
+ end
@@ -0,0 +1,69 @@
1
+ require 'xcodeproj'
2
+
3
+ module Mayday
4
+ class TargetIntegrator
5
+
6
+ def initialize(project, script_generator, target_name)
7
+ @project = project
8
+ @script_generator = script_generator
9
+ @target_name = target_name
10
+ end
11
+
12
+ def integrate
13
+ if runs_successfully?
14
+ phase = existing_mayday_build_phase_for_native_target(native_target_to_integrate) || native_target_to_integrate.new_shell_script_build_phase(mayday_build_phase_name)
15
+ phase.shell_path = "/usr/bin/ruby"
16
+ phase.shell_script = @script_generator.to_ruby
17
+ phase.show_env_vars_in_log = '0'
18
+ @project.save
19
+ end
20
+ end
21
+
22
+ def deintegrate
23
+ phase = existing_mayday_build_phase_for_native_target(native_target_to_integrate)
24
+ phase.remove_from_project if phase
25
+ @project.save
26
+ end
27
+
28
+ def runs_successfully?
29
+ ENV["SRCROOT"] = @project.path.parent.to_s
30
+ eval(@script_generator.to_ruby(:exit_after => false, :output => false))
31
+ true
32
+ end
33
+
34
+ def benchmark
35
+ ENV["SRCROOT"] = @project.path.parent.to_s
36
+
37
+ require 'benchmark'
38
+ Benchmark.bm(7) do |benchmarker|
39
+ benchmarker.report('Mayday') { eval(@script_generator.to_ruby(:exit_after => false, :output => false)) }
40
+ end
41
+ end
42
+
43
+ def native_target_to_integrate
44
+ native_target = @project.targets.detect do |target|
45
+ target.is_a?(Xcodeproj::Project::Object::PBXNativeTarget) && target.name == @target_name
46
+ end
47
+
48
+ if native_target
49
+ native_target
50
+ else
51
+ valid_target_names = @project.targets.select { |target| target.is_a?(Xcodeproj::Project::Object::PBXNativeTarget) }.map(&:name)
52
+ puts "Could not find a target named #{@target_name} in #{@project.path}. Available targets: #{valid_target_names.join(", ")}".red
53
+ abort
54
+ end
55
+ end
56
+ private :native_target_to_integrate
57
+
58
+ def existing_mayday_build_phase_for_native_target(native_target)
59
+ native_target.shell_script_build_phases.detect { |bp| bp.name == mayday_build_phase_name }
60
+ end
61
+ private :existing_mayday_build_phase_for_native_target
62
+
63
+ def mayday_build_phase_name
64
+ 'Generate Mayday Flags'
65
+ end
66
+ private :mayday_build_phase_name
67
+
68
+ end
69
+ end
@@ -0,0 +1,42 @@
1
+ require 'mayday/reader'
2
+ require 'colored'
3
+
4
+ module Mayday
5
+ class UserDefinitions
6
+
7
+ def initialize(mayday_file_path)
8
+ @mayday_file_path = mayday_file_path
9
+ end
10
+
11
+ def up
12
+ mayday_file do |file|
13
+ Reader.new(file).to_target_integrator.integrate
14
+ end
15
+ end
16
+
17
+ def down
18
+ mayday_file do |file|
19
+ Reader.new(file).to_target_integrator.deintegrate
20
+ end
21
+ end
22
+
23
+ def benchmark
24
+ mayday_file do |file|
25
+ Reader.new(file).to_target_integrator.benchmark
26
+ end
27
+ end
28
+
29
+ def mayday_file
30
+ unless File.exist?(@mayday_file_path)
31
+ puts "No file found at path ./#{@mayday_file_path}".red
32
+ abort
33
+ end
34
+
35
+ file = File.open(@mayday_file_path)
36
+ yield file
37
+ file.close
38
+ end
39
+ private :mayday_file
40
+
41
+ end
42
+ end
@@ -0,0 +1,3 @@
1
+ module Mayday
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,11 @@
1
+ require "mayday/error"
2
+
3
+ module Mayday
4
+ class Warning < Error
5
+
6
+ def message_prefix
7
+ "warning: "
8
+ end
9
+
10
+ end
11
+ end
data/lib/mayday.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "mayday/version"
2
+ require "mayday/user_definitions"
data/mayday.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mayday/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mayday"
8
+ spec.version = Mayday::VERSION
9
+ spec.authors = ["Mark Larsen"]
10
+ spec.email = ["larse503@gmail.com"]
11
+ spec.summary = %q{Custom warnings and errors}
12
+ spec.description = %q{Custom warnings and errors}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "pry", "~> 0.9"
23
+ spec.add_development_dependency "rake", "~> 10.3"
24
+ spec.add_development_dependency "rspec", "~> 2.14"
25
+
26
+ spec.add_dependency 'clamp', '~> 0.6.3'
27
+ spec.add_dependency 'colored', '~> 1.2'
28
+ spec.add_dependency 'sourcify', '~> 0.6.0rc4'
29
+ spec.add_dependency 'xcodeproj', '~> 0.19.3'
30
+ end