bait 0.2.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9352d315f041c234622a2d08cb1d7eefc70886c0
4
- data.tar.gz: b508310f57abe42029ca801cca980c0f978bd378
3
+ metadata.gz: 538ab60ada5752213726f9810c21f4b9a628925d
4
+ data.tar.gz: 27fa1ecb9bc9e38a8db35a698b6e5c75fd534faf
5
5
  SHA512:
6
- metadata.gz: 263636979c1adf36fe0d1113ebbaa122aa464a247c88fdbf7fa0816526cfc139bd74d4d7d61bc046951d0a31f39cbde561ac37def514406820d15454582c9837
7
- data.tar.gz: 6d6a352c5554ecacaeb76fb85403c246ddf3e22beeb66d9faba9fa1265b0208b1ba319c4a0b26304ea9316256c3ff351a8d0db8b943b1ad2a942877ea6fe14bc
6
+ metadata.gz: 35c7dbf5f18c4779305b512d913b0cd74a1d2bfa6fe318a7b8603c366873b172c62ba398af03f104fd172981bf700ab2762d8fdc75b1e2f49b196e343eabdc33
7
+ data.tar.gz: fa325bd7030acac83f71aa121efcfdbc24231b7f4dc3dffcab8bed7c270d759c6dcf62b07411c127e87071bc493bee518e3aa18dcfce19fbef4b31c33966fbba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bait (0.2.0)
4
+ bait (0.2.1)
5
5
  git
6
6
  haml
7
7
  moneta
data/README.md CHANGED
@@ -26,7 +26,7 @@ Scribbeo-motion proved that this works, and so bait is a service I'm envisioning
26
26
  # Architectural Overview
27
27
 
28
28
  ```
29
- Github POST bait:80/
29
+ Github POST bait:8417/
30
30
  ______________________ \./
31
31
  | Mac OS X 10.8 | |
32
32
  | w/ RubyMotion | |
@@ -120,8 +120,22 @@ scripts upon a Github hook.
120
120
 
121
121
  But how exactly will it help add a ruby test suite to an Obj-C app?
122
122
 
123
- Watch this spot for some examples soon; essentially we'll be doing this
124
- in Ruby using bait::Wrap::ObjC or some such :)
123
+ Watch this spot for some examples soon
124
+
125
+ The basic idea however is to bootstrap a rubymotion project in your
126
+ `test.sh` file, throw your Obj-C files into vendor/ and then setup your
127
+ Rakefile like so:
128
+
129
+ ```ruby
130
+ Motion::Project::App.setup do |app|
131
+ app.name = 'My Wrapped Project'
132
+
133
+ %w[Tools Models Controllers Views].map{|i| app.vendor_project "vendor/SB/#{i}", :static }
134
+ end
135
+ ```
136
+
137
+ Now that's just a preliminary example; I will try to make this very easy
138
+ and conventional and then report my findings here.
125
139
 
126
140
  # Future
127
141
 
@@ -0,0 +1,48 @@
1
+ require 'bait/objective_c/project'
2
+
3
+ module Bait
4
+ module ObjectiveC
5
+ class DependencyOrderer
6
+ attr_accessor :errors, :order, :queue, :project
7
+ def initialize path_array, project
8
+ @project = project
9
+ @queue = path_array
10
+ @order = []
11
+ @errors = []
12
+ end
13
+
14
+ def examine_file path
15
+ return unless path && File.exists?(path)
16
+ if @order.include? path
17
+ return
18
+ end
19
+ imports_within(path).each do |name|
20
+ examine_file @project.glob(name).first
21
+ end
22
+ @order << path
23
+ end
24
+
25
+ def imports_within path
26
+ imports = []
27
+ File.open(path, 'r') do |f|
28
+ f.each_line do |line|
29
+ if matches = line.match(/^#import "(.*)"/)
30
+ imports << matches[1]
31
+ end
32
+ end
33
+ end
34
+ rescue => ex
35
+ @errors << ex
36
+ ensure
37
+ return imports
38
+ end
39
+
40
+ def start
41
+ @queue.each do |path|
42
+ examine_file path
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,17 @@
1
+ require 'bait/project'
2
+ require 'bait/objective_c/dependency_orderer'
3
+
4
+ module Bait
5
+ module ObjectiveC
6
+ class Project < Bait::Project
7
+ def h_files
8
+ @h_files ||= ordered_dependencies '*.h', ObjectiveC::DependencyOrderer
9
+ end
10
+
11
+ def m_files
12
+ @m_files ||= ordered_dependencies '*.m', ObjectiveC::DependencyOrderer
13
+ end
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,20 @@
1
+ module Bait
2
+ class Project
3
+ def initialize root_path
4
+ unless Dir.exists? root_path
5
+ raise "Expected a valid directory"
6
+ end
7
+ @path = Pathname.new(root_path)
8
+ end
9
+
10
+ def glob pattern
11
+ Dir.glob @path.join("**/#{pattern}")
12
+ end
13
+
14
+ def ordered_dependencies file_pattern, klass
15
+ orderer = klass.new(glob(file_pattern), self)
16
+ orderer.start
17
+ orderer.order
18
+ end
19
+ end
20
+ end
data/lib/bait/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bait
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'bait/objective_c/dependency_orderer'
2
+
3
+ describe Bait::ObjectiveC::DependencyOrderer do
4
+ it "initializes with a path array and a Bait::Project" do
5
+ project = Bait::ObjectiveC::Project.new File.dirname(__FILE__)
6
+ Bait::ObjectiveC::DependencyOrderer.new [], project
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require 'bait/objective_c/project'
2
+
3
+ describe Bait::ObjectiveC::Project do
4
+ subject { Bait::ObjectiveC::Project.new "/" }
5
+ it { should respond_to :h_files }
6
+ it { should respond_to :m_files }
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ require 'bait/project'
2
+
3
+ describe Bait::Project do
4
+ it "requires a valid root path" do
5
+ expect { Bait::Project.new('fawfewa') }.to raise_error
6
+ expect { Bait::Project.new('/') }.not_to raise_error
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keyvan Fatehi
@@ -214,6 +214,9 @@ files:
214
214
  - lib/bait.rb
215
215
  - lib/bait/api.rb
216
216
  - lib/bait/build.rb
217
+ - lib/bait/objective_c/dependency_orderer.rb
218
+ - lib/bait/objective_c/project.rb
219
+ - lib/bait/project.rb
217
220
  - lib/bait/public/css/styles.css
218
221
  - lib/bait/simple_query.rb
219
222
  - lib/bait/tester.rb
@@ -222,6 +225,9 @@ files:
222
225
  - lib/bait/views/layout.haml
223
226
  - spec/lib/bait/api_spec.rb
224
227
  - spec/lib/bait/build_spec.rb
228
+ - spec/lib/bait/objective_c/dependency_orderer_spec.rb
229
+ - spec/lib/bait/objective_c/project_spec.rb
230
+ - spec/lib/bait/project_spec.rb
225
231
  - spec/lib/bait/tester_spec.rb
226
232
  - spec/lib/bait_spec.rb
227
233
  - spec/spec_helper.rb
@@ -253,6 +259,9 @@ summary: build and integration test service
253
259
  test_files:
254
260
  - spec/lib/bait/api_spec.rb
255
261
  - spec/lib/bait/build_spec.rb
262
+ - spec/lib/bait/objective_c/dependency_orderer_spec.rb
263
+ - spec/lib/bait/objective_c/project_spec.rb
264
+ - spec/lib/bait/project_spec.rb
256
265
  - spec/lib/bait/tester_spec.rb
257
266
  - spec/lib/bait_spec.rb
258
267
  - spec/spec_helper.rb