Hokkaido 0.0.2 → 0.0.3
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.
- data/.gitignore +1 -0
- data/.gitmodules +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +9 -19
- data/bin/Hokkaido +8 -5
- data/lib/Hokkaido.rb +19 -16
- data/lib/Hokkaido/version.rb +1 -1
- data/lib/motion_mock.rb +6 -0
- data/spec/Hokkaido/gem_modifier_spec.rb +7 -8
- data/spec/Hokkaido/port_spec.rb +12 -7
- metadata +2 -2
- data/.DS_Store +0 -0
data/.gitignore
CHANGED
data/.gitmodules
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -39,29 +39,19 @@ Where impossible or strange, A `FIXME` is produced. (not desirable but useful)
|
|
39
39
|
|
40
40
|
The above may be expanded later.
|
41
41
|
|
42
|
-
## Installation
|
43
|
-
|
44
|
-
Add this line to your application's Gemfile:
|
45
|
-
|
46
|
-
gem 'Hokkaido'
|
47
|
-
|
48
|
-
And then execute:
|
49
|
-
|
50
|
-
$ bundle
|
51
|
-
|
52
|
-
Or install it yourself as:
|
53
|
-
|
54
|
-
$ gem install Hokkaido
|
55
|
-
|
56
42
|
## Usage
|
57
43
|
|
58
|
-
`[bundle exec] Hokkaido <gem_name> <init_file> <lib_folder>`
|
44
|
+
Porting: `[bundle exec] Hokkaido port <gem_name> <init_file> <lib_folder>`
|
45
|
+
Testing: `[bundle exec] Hokkaido test <gem_name> <init_file> <lib_folder>`
|
46
|
+
|
47
|
+
Note, `init_file` is looked for within `lib_folder`
|
59
48
|
|
60
|
-
##
|
49
|
+
## Example
|
61
50
|
|
62
|
-
Hokkaido
|
63
|
-
Hokkaido
|
64
|
-
Hokkaido
|
51
|
+
Hokkaido port gherkin gherkin.rb gherkin-test/lib
|
52
|
+
Hokkaido port term ansicolor.rb term/lib
|
53
|
+
Hokkaido port cucumber cucumber.rb cucumber/lib
|
54
|
+
Hokkaido port gherkin gherkin.rb gherkin/lib
|
65
55
|
|
66
56
|
## Contributing
|
67
57
|
|
data/bin/Hokkaido
CHANGED
@@ -8,15 +8,18 @@ program :version, '0.0.1'
|
|
8
8
|
program :description, 'Gem port tool for RubyMotion'
|
9
9
|
|
10
10
|
command :port do |c|
|
11
|
-
c.syntax = "Usage: Hokkaido port <gem_name> <
|
11
|
+
c.syntax = "Usage: Hokkaido port <gem_name> <init_filename> <lib_dir>"
|
12
12
|
c.description = 'Attempts to port the gem. This will modify the files!'
|
13
13
|
c.option '--sim', TrueClass, 'Does not edit the gem files. Good for hacking Hokkaido'
|
14
14
|
c.action do |args, options|
|
15
|
-
if
|
15
|
+
if Hokkaido.valid_input?(args)
|
16
16
|
puts "Init Lib:".colorize(:blue)+" #{args[1]}"
|
17
17
|
puts "Gem name:".colorize(:blue)+" #{args[0]}"
|
18
18
|
say "Lib folder:".colorize(:blue)+" #{args[2]}"
|
19
19
|
port = Hokkaido::Port.new(args, options)
|
20
|
+
port.modify
|
21
|
+
say "Gem modification complete. It will now be tested.".colorize(:yellow)
|
22
|
+
say Hokkaido.self_test_result(port)
|
20
23
|
else
|
21
24
|
say "I can't process that."
|
22
25
|
end
|
@@ -24,11 +27,11 @@ command :port do |c|
|
|
24
27
|
end
|
25
28
|
|
26
29
|
command :test do |c|
|
27
|
-
c.syntax = "Usage: Hokkaido
|
28
|
-
c.description = '
|
30
|
+
c.syntax = "Usage: Hokkaido port <gem_name> <lib_dir> <init_filename> "
|
31
|
+
c.description = 'Test a gem with a mocked RubyMotion to see if it passes.'
|
29
32
|
c.action do |args, options|
|
30
33
|
if args[0] && File.exists?(args[0])
|
31
|
-
Hokkaido::Port.
|
34
|
+
say Hokkaido.self_test_result(Hokkaido::Port.new(args, options))
|
32
35
|
else
|
33
36
|
say "File not found."
|
34
37
|
end
|
data/lib/Hokkaido.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
require "Hokkaido/version"
|
2
2
|
require 'gem_modifier'
|
3
3
|
require 'term/ansicolor'
|
4
|
-
require 'pry'
|
5
|
-
|
6
|
-
|
7
4
|
|
8
5
|
module Hokkaido
|
9
6
|
|
@@ -19,26 +16,32 @@ module Hokkaido
|
|
19
16
|
|
20
17
|
def initialize(info, options=nil)
|
21
18
|
@mod_gem = GemModifier.new(info)
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
end
|
20
|
+
|
21
|
+
def modify
|
25
22
|
@mod_gem.modify!
|
26
|
-
puts "Gem modification complete. It will now be tested.".colorize(:yellow)
|
27
|
-
self.test
|
28
|
-
# end
|
29
23
|
end
|
30
24
|
|
31
25
|
def test
|
32
26
|
true_path = File.join(@mod_gem.lib_folder, @mod_gem.init_lib)
|
33
27
|
mocklib = File.expand_path('lib/motion_mock.rb')
|
34
|
-
|
35
|
-
if retval
|
36
|
-
puts "The #require removal was successful.".colorize(:green)
|
37
|
-
else
|
38
|
-
puts "The #require removal has failed.".colorize(:red)
|
39
|
-
end
|
40
|
-
return retval
|
28
|
+
system("/usr/bin/env ruby -r #{mocklib} #{true_path}")
|
41
29
|
end
|
42
30
|
end
|
43
31
|
|
32
|
+
def self.self_test_result(port)
|
33
|
+
if port.test
|
34
|
+
puts "The #require removal was successful.".colorize(:green)
|
35
|
+
else
|
36
|
+
puts "The #require removal has failed.".colorize(:red)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.valid_input?(args)
|
41
|
+
if args.length == 3 && args[0].length > 0
|
42
|
+
name, init_filename, lib_dir = args
|
43
|
+
init_path = File.join(lib_dir, init_filename)
|
44
|
+
File.directory?(lib_dir) && File.exists?(init_path)
|
45
|
+
end
|
46
|
+
end
|
44
47
|
end
|
data/lib/Hokkaido/version.rb
CHANGED
data/lib/motion_mock.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Hokkaido::GemModifier do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
4
|
+
it "sets up the 3 required input variables" do
|
5
|
+
info = ["cucumber", "cucumber/lib/cucumber.rb", "cucumber/lib"]
|
6
|
+
modifier = Hokkaido::GemModifier.new(info)
|
7
|
+
modifier.gem_name.should == "cucumber"
|
8
|
+
modifier.init_lib.should == "cucumber/lib/cucumber.rb"
|
9
|
+
modifier.lib_folder.should == "cucumber/lib"
|
10
|
+
end
|
12
11
|
end
|
data/spec/Hokkaido/port_spec.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
describe Hokkaido::Port do
|
6
|
-
|
7
|
-
|
4
|
+
before do
|
5
|
+
File.directory?("gherkin").should be_true
|
6
|
+
FileUtils.cp_r "gherkin", "gherkin-spec"
|
7
|
+
@info = ["gherkin-spec", "gherkin.rb", "gherkin-spec/lib"]
|
8
8
|
end
|
9
|
-
|
10
|
-
it "should
|
11
|
-
port = Hokkaido::Port.new(
|
9
|
+
|
10
|
+
it "should pass self test" do
|
11
|
+
port = Hokkaido::Port.new(@info)
|
12
|
+
port.modify
|
12
13
|
port.test.should be_true
|
13
14
|
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
FileUtils.rmtree 'gherkin-spec'
|
18
|
+
end
|
14
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Hokkaido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -133,8 +133,8 @@ executables:
|
|
133
133
|
extensions: []
|
134
134
|
extra_rdoc_files: []
|
135
135
|
files:
|
136
|
-
- .DS_Store
|
137
136
|
- .gitignore
|
137
|
+
- .gitmodules
|
138
138
|
- .rvmrc
|
139
139
|
- Gemfile
|
140
140
|
- Gemfile.lock
|
data/.DS_Store
DELETED
Binary file
|