mayday 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 528e45a5424cea26dc7661b18baa77c21989e5a0
4
- data.tar.gz: f2191fb65a8b7de70a7ef74b5bee6622dfe07818
3
+ metadata.gz: 54fd6eae0019921ad08a561b8608c07cc05434be
4
+ data.tar.gz: 8458b2fac4814310e1adf39f4c577218c5410a3b
5
5
  SHA512:
6
- metadata.gz: f18702d705d8456491604b27e208cdebafa6fc64b7237ca44065516350c198dac4153acf62043d2ed94cdeeefedb547cbfe6d62608c61a13551c0dab7fc2301d
7
- data.tar.gz: 8124aa4272be0943a239c97e7a54fe3ddddd6318fdbaf4492b4b87c8ef90cf384f1596806e80d465ad6c7f1d1fc57c898a9bad450b61534c132cbadeed5ef7be
6
+ metadata.gz: 16bae0fba41a1e56aba29ab7daed21d295cb9006c970adcadf5ebb8b87e6f3b34997c65666812af5b4647db3adfbf4315d939186e44a19876d8342b2a53be4da
7
+ data.tar.gz: ee96131376be5dabc33ec5dce2c823c2266616263e495b48dc2b5248868b880b4d0928be4579cc786eb4575c155a6f2398fe0d94e214d94d2ddcde3a52b4bcff
data/README.md CHANGED
@@ -78,6 +78,10 @@ Since Ruby is installed by default on OSX, the warnings and errors will work for
78
78
  * `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.
79
79
  * `warning :line, :exclude => ["*/Pods/*"] do ...` **Note, Pods are excluded by default by mayday**
80
80
 
81
+ ## Cookbook
82
+
83
+ For some ideas on how to start using mayday, see the [cookbook](https://github.com/marklarr/mayday/blob/master/docs/Cookbook.md)
84
+
81
85
  ## Benchmarking
82
86
 
83
87
  You may be concerned about how much overhead this will add to your build process. To see how quickly your `mayday` checks execute, use
@@ -94,7 +98,6 @@ $ mayday benchmark
94
98
  * If your custom blocks have errors in them that aren't found until they're executed (which is done whenever you call `mayday`), the stack trace won't be very helpful in debugging (because there is no source map from the build phase back to your `Maydayfile` code)
95
99
  * Generating efficient code to write into the build phase is difficult. The code generated by `MayDay::ScriptGenerator#to_ruby` could definitely be optimized.
96
100
 
97
-
98
101
  ## Uninstallation
99
102
 
100
103
  ```sh
data/docs/Cookbook.md ADDED
@@ -0,0 +1,46 @@
1
+ # Cookbook
2
+
3
+ The mayday cookbook contains common warning/error checks that are ready to use out-of-the-box and can be customized as you please.
4
+
5
+ * [Reminders](#reminders)
6
+ * [Lint](#lint)
7
+
8
+ ## Reminders
9
+
10
+ ```ruby
11
+ # Warning for TODO comments
12
+ warning_regex 'TODO', /\s*\/\/\s*TODO:/
13
+ ```
14
+
15
+ ```ruby
16
+ # Warning for FIXME comments
17
+ warning_regex 'FIXME', /\s*\/\/\s*FIXME:/
18
+ ```
19
+
20
+ ## Lint
21
+
22
+ ```ruby
23
+ # Warning for lines that are more than 120 columns long
24
+ warning :line { |line| line.length > 120 ? "Line is #{line.length} columns long" : false }
25
+ ```
26
+
27
+ ```ruby
28
+ # Warning for files that are more than 500 lines long
29
+ warning :file do |entire_file|
30
+ max_number_of_lines = 500
31
+
32
+ number_of_code_or_comment_lines = entire_file.split("\n").select { |line| line.strip.length > 0 }.count
33
+ if number_of_code_or_comment_lines > max_number_of_lines
34
+ # Map line numbers to errors
35
+ { "1" => "File is #{number_of_code_or_comment_lines} lines long" }
36
+ else
37
+ false
38
+ end
39
+ end
40
+ ```
41
+
42
+ ```ruby
43
+ # Warning for Copyright placed at the beginning of every file
44
+ warning_regex "Please remove Copyright boilerplate", /^\/\/ Copyright \(c\).*$/
45
+ ```
46
+
data/lib/mayday/reader.rb CHANGED
@@ -13,6 +13,11 @@ module Mayday
13
13
  @script_generator = ScriptGenerator.new
14
14
  end
15
15
 
16
+ def require(lib_name)
17
+ super
18
+ @script_generator.libs_to_require << lib_name
19
+ end
20
+
16
21
  def to_target_integrator
17
22
  instance_eval(@mayday_file.read, @mayday_file.path, 0)
18
23
  validate_xcode_proj
@@ -23,14 +28,17 @@ module Mayday
23
28
  real_xcodeproj_path = File.join(Pathname.new(@mayday_file.path).realpath.parent, xcode_proj_path)
24
29
  @xcode_proj = Xcodeproj::Project.open(real_xcodeproj_path)
25
30
  end
31
+ private :xcode_proj
26
32
 
27
33
  def warning_regex(message, regex, options={})
28
34
  abstract_flag_regex(Warning, message, regex, options)
29
35
  end
36
+ private :warning_regex
30
37
 
31
38
  def error_regex(message, regex, options={})
32
39
  abstract_flag_regex(Error, message, regex, options)
33
40
  end
41
+ private :error_regex
34
42
 
35
43
  def validate_xcode_proj
36
44
  unless @xcode_proj
@@ -6,16 +6,18 @@ require 'pathname'
6
6
  module Mayday
7
7
  class ScriptGenerator
8
8
 
9
- attr_accessor :flags
9
+ attr_accessor :flags, :libs_to_require
10
10
 
11
11
  def initialize
12
12
  self.flags = []
13
+ self.libs_to_require = []
13
14
  end
14
15
 
15
16
  def to_ruby(opts={})
16
17
  opts[:exit_after] = true if opts[:exit_after] == nil;
17
18
  opts[:output] = true if opts[:output] == nil;
18
19
 
20
+ require_lines = libs_to_require.map { |lib_to_require| "require '#{lib_to_require}'" }.join("\n")
19
21
  function_defs = flags.map(&:function_def_string).join
20
22
  exit_chunk = if opts[:exit_after]
21
23
  <<-CODE
@@ -37,6 +39,8 @@ end
37
39
  # encoding: utf-8
38
40
  Encoding.default_external = "utf-8"
39
41
 
42
+ #{require_lines}
43
+
40
44
  #{function_defs}
41
45
 
42
46
  Dir[ENV["SRCROOT"] + "/**/*.{m,h,swift}"].each do |filename|
@@ -51,7 +51,7 @@ module Mayday
51
51
  if native_targets.count > 0
52
52
  native_targets
53
53
  else
54
- puts "Could not find any native targets that have no target dependencies".red
54
+ puts "Could not find any native targets".red
55
55
  abort
56
56
  end
57
57
  end
@@ -1,3 +1,3 @@
1
1
  module Mayday
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/mayday.gemspec CHANGED
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'clamp', '~> 0.6.3'
27
27
  spec.add_dependency 'colorize', '~> 0.7.3'
28
28
  spec.add_dependency 'sourcify', '~> 0.6.0rc4'
29
- spec.add_dependency 'xcodeproj', '~> 0.19.3'
29
+ spec.add_dependency 'xcodeproj', '~> 0.20'
30
30
  end
@@ -1,6 +1,11 @@
1
+ require 'cmath'
2
+
1
3
  xcode_proj "Fixtures/Fixtures.xcodeproj"
2
4
 
5
+ CMath.sin(2)
6
+
3
7
  warning :line, :language => "swift" do |line|
8
+ CMath.sin(2)
4
9
  line.length > 120 ? "Length of line #{line.length} is longer than 120 characters!" : false
5
10
  end
6
11
 
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe Mayday::UserDefinitions do
4
4
 
5
5
  def parse_build_output(opts={})
6
- extra_test_flags = opts[:test] ? "-sdk iphonesimulator test" : ""
7
- output =`xcodebuild -project spec/test_fixtures/Fixtures/Fixtures.xcodeproj/ -scheme Fixtures -configuration Debug #{extra_test_flags}`
6
+ extra_test_flags = opts[:test] ? "test" : ""
7
+ output =`xcodebuild -project spec/test_fixtures/Fixtures/Fixtures.xcodeproj/ -scheme Fixtures -sdk iphonesimulator #{extra_test_flags}`
8
8
  exitstatus = $?.exitstatus
9
9
  files_to_lines_to_warnings_hash = {}
10
10
  output.split("\n").each do |line|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mayday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-23 00:00:00.000000000 Z
11
+ date: 2015-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.19.3
117
+ version: '0.20'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.19.3
124
+ version: '0.20'
125
125
  description: Custom warnings and errors
126
126
  email:
127
127
  - larse503@gmail.com
@@ -137,6 +137,7 @@ files:
137
137
  - README.md
138
138
  - Rakefile
139
139
  - bin/mayday
140
+ - docs/Cookbook.md
140
141
  - docs/example.jpg
141
142
  - docs/example_inline.jpg
142
143
  - lib/mayday.rb