Hokkaido 0.0.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.
- data/.DS_Store +0 -0
- data/.gitignore +20 -0
- data/.rvmrc +48 -0
- data/Gemfile +4 -0
- data/Guardfile +24 -0
- data/Hokkaido.gemspec +24 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/Rakefile +2 -0
- data/bin/Hokkaido +37 -0
- data/lib/Hokkaido.rb +44 -0
- data/lib/Hokkaido/version.rb +3 -0
- data/lib/gem_modifier.rb +101 -0
- data/lib/motion_mock.rb +22 -0
- data/lib/term/ansicolor.rb +124 -0
- data/spec/Hokkaido/gem_modifier_spec.rb +12 -0
- data/spec/Hokkaido/port_spec.rb +14 -0
- data/spec/spec_helper.rb +28 -0
- metadata +182 -0
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p194@Hokkaido"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.14.3 (master)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :version => 2 do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara request specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/Hokkaido.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/Hokkaido/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jonathan Silverman", "Keyvan Fatehi"]
|
6
|
+
gem.email = ["jsilver@mdks.org", "keyvan@mdks.org"]
|
7
|
+
gem.description = %q{Automates as much as possible in assistance with porting of gems to RubyMotion}
|
8
|
+
gem.summary = %q{Automates as much as possible in assistance with porting of gems to RubyMotion}
|
9
|
+
gem.homepage = "https://github.com/jsilverMDX/Hokkaido"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "Hokkaido"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Hokkaido::VERSION
|
17
|
+
gem.add_development_dependency 'rspec'
|
18
|
+
gem.add_development_dependency 'pry'
|
19
|
+
gem.add_development_dependency 'guard'
|
20
|
+
gem.add_development_dependency 'guard-rspec'
|
21
|
+
gem.add_development_dependency 'pry-debugger'
|
22
|
+
gem.add_runtime_dependency 'ruby_parser'
|
23
|
+
gem.add_runtime_dependency 'commander'
|
24
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 MDKS
|
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,72 @@
|
|
1
|
+
# Hokkaido
|
2
|
+
|
3
|
+
Hokkaido attempts to do as much of the work of porting a Gem to RubyMotion for you as possible
|
4
|
+
|
5
|
+
Currently, it only supports one patching operation.
|
6
|
+
|
7
|
+
* Refold `Requires` into RubyMotion Project Manifest automatically!
|
8
|
+
|
9
|
+
Now working. New load order math!
|
10
|
+
|
11
|
+
for example, in gherkin/lib/gherkin.rb:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
# require 'gherkin/lexer/i18n_lexer'
|
15
|
+
# require 'gherkin/parser/parser'
|
16
|
+
Motion::Project::App.setup do |app|
|
17
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/native/null.rb'))
|
18
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/native.rb'))
|
19
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/hashable.rb'))
|
20
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/model.rb'))
|
21
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/rubify.rb'))
|
22
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/ansi_escapes.rb'))
|
23
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/step_printer.rb'))
|
24
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/argument.rb'))
|
25
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/escaping.rb'))
|
26
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/formatter/pretty_formatter.rb'))
|
27
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/c_lexer.rb'))
|
28
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/rb_lexer.rb'))
|
29
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/js_lexer.rb'))
|
30
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/i18n.rb'))
|
31
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/lexer/i18n_lexer.rb'))
|
32
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/listener/formatter_listener.rb'))
|
33
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin/parser/parser.rb'))
|
34
|
+
app.files << File.expand_path(File.join(File.dirname(__FILE__),'gherkin.rb'))
|
35
|
+
end
|
36
|
+
```
|
37
|
+
|
38
|
+
Where impossible or strange, A `FIXME` is produced. (not desirable but useful)
|
39
|
+
|
40
|
+
The above may be expanded later.
|
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
|
+
## Usage
|
57
|
+
|
58
|
+
`[bundle exec] Hokkaido <gem_name> <init_file> <lib_folder>`
|
59
|
+
|
60
|
+
## Examples
|
61
|
+
|
62
|
+
Hokkaido term ansicolor.rb term/lib
|
63
|
+
Hokkaido cucumber cucumber.rb cucumber/lib
|
64
|
+
Hokkaido gherkin gherkin.rb gherkin/lib
|
65
|
+
|
66
|
+
## Contributing
|
67
|
+
|
68
|
+
1. Fork it
|
69
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
70
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
71
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
72
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/Hokkaido
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'commander/import'
|
3
|
+
require 'Hokkaido'
|
4
|
+
puts "Hokkaido v#{Hokkaido::VERSION} codename Northern Sea Circuit".colorize(:yellow)
|
5
|
+
|
6
|
+
program :name, "Hokkaido"
|
7
|
+
program :version, '0.0.1'
|
8
|
+
program :description, 'Gem port tool for RubyMotion'
|
9
|
+
|
10
|
+
command :port do |c|
|
11
|
+
c.syntax = "Usage: Hokkaido port <gem_name> <init_file> <lib_dir>"
|
12
|
+
c.description = 'Attempts to port the gem. This will modify the files!'
|
13
|
+
c.option '--sim', TrueClass, 'Does not edit the gem files. Good for hacking Hokkaido'
|
14
|
+
c.action do |args, options|
|
15
|
+
if File.exists?(args[1]) && File.directory?(args[2]) && args[0].size > 1
|
16
|
+
puts "Init Lib:".colorize(:blue)+" #{args[1]}"
|
17
|
+
puts "Gem name:".colorize(:blue)+" #{args[0]}"
|
18
|
+
say "Lib folder:".colorize(:blue)+" #{args[2]}"
|
19
|
+
port = Hokkaido::Port.new(args, options)
|
20
|
+
else
|
21
|
+
say "I can't process that."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
command :test do |c|
|
27
|
+
c.syntax = "Usage: Hokkaido test <init_file>"
|
28
|
+
c.description = 'Attempts to test the gem with a mocked RubyMotion.'
|
29
|
+
c.action do |args, options|
|
30
|
+
if args[0] && File.exists?(args[0])
|
31
|
+
Hokkaido::Port.test(args[0])
|
32
|
+
else
|
33
|
+
say "File not found."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/lib/Hokkaido.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "Hokkaido/version"
|
2
|
+
require 'gem_modifier'
|
3
|
+
require 'term/ansicolor'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
module Hokkaido
|
9
|
+
|
10
|
+
RUBYMOTION_GEM_CONFIG = <<-HEREDOC
|
11
|
+
Motion::Project::App.setup do |app|
|
12
|
+
MAIN_CONFIG_FILES
|
13
|
+
end
|
14
|
+
HEREDOC
|
15
|
+
|
16
|
+
INCLUDE_STRING = " app.files << File.expand_path(File.join(File.dirname(__FILE__),'RELATIVE_LIBRARY_PATH'))"
|
17
|
+
|
18
|
+
class Port
|
19
|
+
|
20
|
+
def initialize(info, options=nil)
|
21
|
+
@mod_gem = GemModifier.new(info)
|
22
|
+
# if options.sim
|
23
|
+
# @mod_gem.simulate!
|
24
|
+
# else
|
25
|
+
@mod_gem.modify!
|
26
|
+
puts "Gem modification complete. It will now be tested.".colorize(:yellow)
|
27
|
+
self.test
|
28
|
+
# end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test
|
32
|
+
true_path = File.join(@mod_gem.lib_folder, @mod_gem.init_lib)
|
33
|
+
mocklib = File.expand_path('lib/motion_mock.rb')
|
34
|
+
retval = system("/usr/bin/env ruby -r #{mocklib} #{true_path}")
|
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
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/gem_modifier.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'ruby_parser'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
# require removal only
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
module Hokkaido
|
10
|
+
class GemModifier
|
11
|
+
attr_reader :gem_name, :init_lib, :lib_folder
|
12
|
+
|
13
|
+
def initialize(info)
|
14
|
+
@gem_name, @init_lib, @lib_folder = info
|
15
|
+
@require_libs = [File.join(@lib_folder, @init_lib)]
|
16
|
+
end
|
17
|
+
|
18
|
+
def modify!
|
19
|
+
parse_gem(File.join(@lib_folder, @init_lib))
|
20
|
+
write_manifest
|
21
|
+
end
|
22
|
+
|
23
|
+
# def simulate!
|
24
|
+
# puts "simulator not implemented..."
|
25
|
+
# end
|
26
|
+
|
27
|
+
def parse_gem(init_lib)
|
28
|
+
# puts "Processing: #{init_lib}"
|
29
|
+
# don't ask
|
30
|
+
init_path = init_lib
|
31
|
+
|
32
|
+
init_file = File.read(init_lib)
|
33
|
+
current_file = ""
|
34
|
+
|
35
|
+
init_file.each_line do |line|
|
36
|
+
if line.strip =~ /^require/
|
37
|
+
parser = RubyParser.new
|
38
|
+
sexp = parser.parse(line)
|
39
|
+
call = sexp[2]
|
40
|
+
|
41
|
+
unless call == :require
|
42
|
+
# WEIRD SHIT IS HAPPENING
|
43
|
+
current_file += line
|
44
|
+
next
|
45
|
+
end
|
46
|
+
|
47
|
+
require_type = sexp[3][1][0]
|
48
|
+
library = sexp[3][1][1]
|
49
|
+
#p library
|
50
|
+
|
51
|
+
if require_type == :str && library.match(@gem_name)
|
52
|
+
# fold in
|
53
|
+
full_rb_path = File.join([@lib_folder, "#{library}.rb"])
|
54
|
+
unless @require_libs.include?(full_rb_path)
|
55
|
+
file_index = @require_libs.index(init_lib)
|
56
|
+
insert_index = file_index
|
57
|
+
@require_libs.insert insert_index, full_rb_path
|
58
|
+
parse_gem(full_rb_path)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
current_file += "# FIXME: #require is not supported in RubyMotion\n"
|
62
|
+
current_file += "# #{line}"
|
63
|
+
next
|
64
|
+
end
|
65
|
+
# comment it out
|
66
|
+
current_file += "# #{line}"
|
67
|
+
next
|
68
|
+
end
|
69
|
+
|
70
|
+
# dont intefere
|
71
|
+
current_file += line
|
72
|
+
end
|
73
|
+
|
74
|
+
# replace file
|
75
|
+
File.open(init_lib, 'w') {|f| f.write(current_file) } #unless TEST_MODE
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def write_manifest
|
80
|
+
|
81
|
+
#puts @require_libs
|
82
|
+
|
83
|
+
@manifest_files = @require_libs.collect do |lib|
|
84
|
+
|
85
|
+
lib = lib.gsub("#{@lib_folder}/", "")
|
86
|
+
|
87
|
+
INCLUDE_STRING.gsub("RELATIVE_LIBRARY_PATH", lib)
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
# creates config manifest
|
92
|
+
@manifest = RUBYMOTION_GEM_CONFIG.gsub("MAIN_CONFIG_FILES", @manifest_files.join("\n"))
|
93
|
+
|
94
|
+
# puts @manifest
|
95
|
+
|
96
|
+
File.open(File.join(@lib_folder, @init_lib), 'a') {|f| f.puts(@manifest) } #unless TEST_MODE
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
data/lib/motion_mock.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
module Motion
|
5
|
+
FILES = []
|
6
|
+
module Project
|
7
|
+
module App
|
8
|
+
class Files
|
9
|
+
def self.<<(path)
|
10
|
+
Motion::FILES << path
|
11
|
+
Kernel.require path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def self.setup(&block)
|
15
|
+
block.call(self)
|
16
|
+
end
|
17
|
+
def self.files
|
18
|
+
Files
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module Hokkaido
|
2
|
+
module Term
|
3
|
+
# The ANSIColor module can be used for namespacing and mixed into your own
|
4
|
+
# classes.
|
5
|
+
module ANSIColor
|
6
|
+
# :stopdoc:
|
7
|
+
ATTRIBUTES = [
|
8
|
+
[ :clear , 0 ],
|
9
|
+
[ :reset , 0 ], # synonym for :clear
|
10
|
+
[ :bold , 1 ],
|
11
|
+
[ :dark , 2 ],
|
12
|
+
[ :italic , 3 ], # not widely implemented
|
13
|
+
[ :underline , 4 ],
|
14
|
+
[ :underscore , 4 ], # synonym for :underline
|
15
|
+
[ :blink , 5 ],
|
16
|
+
[ :rapid_blink , 6 ], # not widely implemented
|
17
|
+
[ :negative , 7 ], # no reverse because of String#reverse
|
18
|
+
[ :concealed , 8 ],
|
19
|
+
[ :strikethrough, 9 ], # not widely implemented
|
20
|
+
[ :black , 30 ],
|
21
|
+
[ :red , 31 ],
|
22
|
+
[ :green , 32 ],
|
23
|
+
[ :yellow , 33 ],
|
24
|
+
[ :blue , 34 ],
|
25
|
+
[ :magenta , 35 ],
|
26
|
+
[ :cyan , 36 ],
|
27
|
+
[ :white , 37 ],
|
28
|
+
[ :on_black , 40 ],
|
29
|
+
[ :on_red , 41 ],
|
30
|
+
[ :on_green , 42 ],
|
31
|
+
[ :on_yellow , 43 ],
|
32
|
+
[ :on_blue , 44 ],
|
33
|
+
[ :on_magenta , 45 ],
|
34
|
+
[ :on_cyan , 46 ],
|
35
|
+
[ :on_white , 47 ],
|
36
|
+
]
|
37
|
+
|
38
|
+
ATTRIBUTE_NAMES = ATTRIBUTES.transpose.first
|
39
|
+
# :startdoc:
|
40
|
+
|
41
|
+
# Returns true, if the coloring function of this module
|
42
|
+
# is switched on, false otherwise.
|
43
|
+
def self.coloring?
|
44
|
+
@coloring
|
45
|
+
end
|
46
|
+
|
47
|
+
# Turns the coloring on or off globally, so you can easily do
|
48
|
+
# this for example:
|
49
|
+
# Cucumber::Term::ANSIColor::coloring = STDOUT.isatty
|
50
|
+
def self.coloring=(val)
|
51
|
+
@coloring = val
|
52
|
+
end
|
53
|
+
self.coloring = true
|
54
|
+
|
55
|
+
ATTRIBUTES.each do |c, v|
|
56
|
+
eval %Q{
|
57
|
+
def #{c}(string = nil)
|
58
|
+
result = ''
|
59
|
+
result << "\e[#{v}m" if Hokkaido::Term::ANSIColor.coloring?
|
60
|
+
if block_given?
|
61
|
+
result << yield
|
62
|
+
elsif string
|
63
|
+
result << string
|
64
|
+
elsif respond_to?(:to_str)
|
65
|
+
result << to_str
|
66
|
+
else
|
67
|
+
return result #only switch on
|
68
|
+
end
|
69
|
+
result << "\e[0m" if Hokkaido::Term::ANSIColor.coloring?
|
70
|
+
result
|
71
|
+
end
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Regular expression that is used to scan for ANSI-sequences while
|
76
|
+
# uncoloring strings.
|
77
|
+
COLORED_REGEXP = /\e\[(?:[34][0-7]|[0-9])?m/
|
78
|
+
|
79
|
+
|
80
|
+
def self.included(klass)
|
81
|
+
if version_is_greater_than_18? and klass == String
|
82
|
+
ATTRIBUTES.delete(:clear)
|
83
|
+
ATTRIBUTE_NAMES.delete(:clear)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns an uncolored version of the string, that is all
|
88
|
+
# ANSI-sequences are stripped from the string.
|
89
|
+
def uncolored(string = nil) # :yields:
|
90
|
+
if block_given?
|
91
|
+
yield.gsub(COLORED_REGEXP, '')
|
92
|
+
elsif string
|
93
|
+
string.gsub(COLORED_REGEXP, '')
|
94
|
+
elsif respond_to?(:to_str)
|
95
|
+
to_str.gsub(COLORED_REGEXP, '')
|
96
|
+
else
|
97
|
+
''
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
module_function
|
102
|
+
|
103
|
+
# Returns an array of all Hokkaido::Term::ANSIColor attributes as symbols.
|
104
|
+
def attributes
|
105
|
+
ATTRIBUTE_NAMES
|
106
|
+
end
|
107
|
+
extend self
|
108
|
+
|
109
|
+
private
|
110
|
+
|
111
|
+
def version_is_greater_than_18?
|
112
|
+
version = RUBY_VERSION.split('.')
|
113
|
+
version.map! &:to_i
|
114
|
+
version[0] >= 1 && version[1] > 8
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
class String
|
121
|
+
def colorize(sym)
|
122
|
+
Hokkaido::Term::ANSIColor.send(sym, self)
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hokkaido::GemModifier do
|
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
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
describe Hokkaido::Port do
|
6
|
+
it "is a factory" do
|
7
|
+
Hokkaido::Port.should respond_to(:new)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should attempt to port a gem to RubyMotion" do
|
11
|
+
port = Hokkaido::Port.new(["gherkin", "gherkin.rb", "gherkin/lib"])
|
12
|
+
port.test.should be_true
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$:.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler'
|
6
|
+
Bundler.setup
|
7
|
+
|
8
|
+
require 'Hokkaido'
|
9
|
+
|
10
|
+
# RSpec.configure do |c|
|
11
|
+
# c.before do
|
12
|
+
# ::Cucumber::Term::ANSIColor.coloring = true
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
|
16
|
+
module RSpec
|
17
|
+
module WorkInProgress
|
18
|
+
def pending_under platforms, reason, &block
|
19
|
+
if [platforms].flatten.map(&:to_s).include? RUBY_PLATFORM
|
20
|
+
pending "pending under #{platforms.inspect} because: #{reason}", &block
|
21
|
+
else
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Hokkaido
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jonathan Silverman
|
9
|
+
- Keyvan Fatehi
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: pry
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: guard
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: guard-rspec
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: pry-debugger
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: ruby_parser
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: commander
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :runtime
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
description: Automates as much as possible in assistance with porting of gems to RubyMotion
|
128
|
+
email:
|
129
|
+
- jsilver@mdks.org
|
130
|
+
- keyvan@mdks.org
|
131
|
+
executables:
|
132
|
+
- Hokkaido
|
133
|
+
extensions: []
|
134
|
+
extra_rdoc_files: []
|
135
|
+
files:
|
136
|
+
- .DS_Store
|
137
|
+
- .gitignore
|
138
|
+
- .rvmrc
|
139
|
+
- Gemfile
|
140
|
+
- Gemfile.lock
|
141
|
+
- Guardfile
|
142
|
+
- Hokkaido.gemspec
|
143
|
+
- LICENSE
|
144
|
+
- README.md
|
145
|
+
- Rakefile
|
146
|
+
- bin/Hokkaido
|
147
|
+
- lib/Hokkaido.rb
|
148
|
+
- lib/Hokkaido/version.rb
|
149
|
+
- lib/gem_modifier.rb
|
150
|
+
- lib/motion_mock.rb
|
151
|
+
- lib/term/ansicolor.rb
|
152
|
+
- spec/Hokkaido/gem_modifier_spec.rb
|
153
|
+
- spec/Hokkaido/port_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
homepage: https://github.com/jsilverMDX/Hokkaido
|
156
|
+
licenses: []
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
163
|
+
requirements:
|
164
|
+
- - ! '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
none: false
|
169
|
+
requirements:
|
170
|
+
- - ! '>='
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
requirements: []
|
174
|
+
rubyforge_project:
|
175
|
+
rubygems_version: 1.8.24
|
176
|
+
signing_key:
|
177
|
+
specification_version: 3
|
178
|
+
summary: Automates as much as possible in assistance with porting of gems to RubyMotion
|
179
|
+
test_files:
|
180
|
+
- spec/Hokkaido/gem_modifier_spec.rb
|
181
|
+
- spec/Hokkaido/port_spec.rb
|
182
|
+
- spec/spec_helper.rb
|