rakugoka 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.rdoc +7 -0
- data/Rakefile +72 -0
- data/VERSION +1 -0
- data/bin/rakugoka +40 -0
- data/lib/rakugoka.rb +25 -0
- data/lib/rakugoka/formatter/importer.rb +89 -0
- data/test/rakugoka_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +84 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Roland Swingler
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rakugoka"
|
8
|
+
gem.summary = "Allows you to upload cucumber features to Rakugoka"
|
9
|
+
gem.email = "roland.swingler@gmail.com"
|
10
|
+
gem.homepage = "http://rakugoka.rubyforge.org/"
|
11
|
+
gem.authors = ["Roland Swingler"]
|
12
|
+
gem.rubyforge_project = "rakugoka"
|
13
|
+
gem.executables = "rakugoka"
|
14
|
+
gem.add_dependency("cucumber", ">=0.3")
|
15
|
+
gem.add_dependency("rest-client")
|
16
|
+
gem.files = [
|
17
|
+
"LICENSE",
|
18
|
+
"README.rdoc",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"bin/rakugoka",
|
22
|
+
"lib/rakugoka.rb",
|
23
|
+
"test/rakugoka_test.rb",
|
24
|
+
"lib/rakugoka/formatter/importer.rb",
|
25
|
+
"test/test_helper.rb"
|
26
|
+
]
|
27
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
28
|
+
end
|
29
|
+
|
30
|
+
Jeweler::RubyforgeTasks.new
|
31
|
+
rescue LoadError
|
32
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rake/testtask'
|
36
|
+
Rake::TestTask.new(:test) do |test|
|
37
|
+
test.libs << 'lib' << 'test'
|
38
|
+
test.pattern = 'test/**/*_test.rb'
|
39
|
+
test.verbose = true
|
40
|
+
end
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'rcov/rcovtask'
|
44
|
+
Rcov::RcovTask.new do |test|
|
45
|
+
test.libs << 'test'
|
46
|
+
test.pattern = 'test/**/*_test.rb'
|
47
|
+
test.verbose = true
|
48
|
+
end
|
49
|
+
rescue LoadError
|
50
|
+
task :rcov do
|
51
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
task :default => :test
|
57
|
+
|
58
|
+
require 'rake/rdoctask'
|
59
|
+
Rake::RDocTask.new do |rdoc|
|
60
|
+
if File.exist?('VERSION.yml')
|
61
|
+
config = YAML.load(File.read('VERSION.yml'))
|
62
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
63
|
+
else
|
64
|
+
version = ""
|
65
|
+
end
|
66
|
+
|
67
|
+
rdoc.rdoc_dir = 'rdoc'
|
68
|
+
rdoc.title = "rakugoka #{version}"
|
69
|
+
rdoc.rdoc_files.include('README*')
|
70
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
71
|
+
end
|
72
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/rakugoka
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Add '.rb' to work around a bug in IronRuby's File#dirname
|
3
|
+
$:.unshift(File.dirname(__FILE__ + '.rb') + '/../lib') unless $:.include?(File.dirname(__FILE__ + '.rb') + '/../lib')
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'cucumber/rspec_neuter'
|
7
|
+
require 'cucumber/cli/main'
|
8
|
+
require 'rakugoka'
|
9
|
+
require 'rakugoka/formatter/importer'
|
10
|
+
|
11
|
+
REMOTE_HOST = "http://192.168.0.4:3001"
|
12
|
+
directory = ARGV[0] ? ARGV[0] : "features"
|
13
|
+
|
14
|
+
if File.exists?(directory) && File.directory?(directory)
|
15
|
+
warn "Starting importing features to #{REMOTE_HOST}."
|
16
|
+
warn "Rakugoka is still pre-alpha - it probably won't be able to import all of your features successfully, sorry."
|
17
|
+
warn "Right! Warming up the cucumber lamps..."
|
18
|
+
else
|
19
|
+
warn "Could not find features, exiting."
|
20
|
+
warn "Rakugoka will look for features under /features or a directory you specify on the command line."
|
21
|
+
Kernel.exit 1
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
API_KEY = load_api_key
|
26
|
+
PROJECT_URL = load_project_url(API_KEY)
|
27
|
+
args = ["--dry-run", "--format", "Rakugoka::Formatter::Importer", directory]
|
28
|
+
failure = Cucumber::Cli::Main.new(args).execute!(Cucumber::Cli::Main.step_mother)
|
29
|
+
Kernel.exit(1) if failure
|
30
|
+
puts "See your project at"
|
31
|
+
puts PROJECT_URL + "/queues"
|
32
|
+
Kernel.exit 0
|
33
|
+
|
34
|
+
rescue SystemExit => e
|
35
|
+
Kernel.exit(e.status)
|
36
|
+
rescue Exception => e
|
37
|
+
STDERR.puts("#{e.message} (#{e.class})")
|
38
|
+
STDERR.puts(e.backtrace.join("\n"))
|
39
|
+
Kernel.exit 1
|
40
|
+
end
|
data/lib/rakugoka.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
def load_api_key
|
5
|
+
config_file = ENV["HOME"] + "/.rakugoka"
|
6
|
+
if File.exists?(config_file)
|
7
|
+
config = YAML.load(File.read(config_file))
|
8
|
+
else
|
9
|
+
config = {"api_key" => RestClient.post("#{REMOTE_HOST}/api_keys", {}).to_s}
|
10
|
+
File.open(config_file, "w") {|fh| fh.write YAML.dump(config) }
|
11
|
+
end
|
12
|
+
config["api_key"]
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_project_url(api_key)
|
16
|
+
project_config_file = Dir.pwd + "/rakugoka.yml"
|
17
|
+
if File.exists?(project_config_file)
|
18
|
+
project = YAML.load(File.read(project_config_file))["location"]
|
19
|
+
else
|
20
|
+
response = RestClient.post("#{REMOTE_HOST}/projects.xml", {"api_key" => api_key, "project[name]" => "Rakugoka import " + rand(1000).to_s })
|
21
|
+
project = response.headers[:location]
|
22
|
+
File.open(project_config_file, "w") {|fh| fh.write YAML.dump({"location" => project})}
|
23
|
+
end
|
24
|
+
project
|
25
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module Rakugoka
|
2
|
+
module Formatter
|
3
|
+
class Importer < Cucumber::Ast::Visitor
|
4
|
+
def initialize(step_mother, io, options)
|
5
|
+
super(step_mother)
|
6
|
+
@options = options
|
7
|
+
end
|
8
|
+
|
9
|
+
def visit_features(features)
|
10
|
+
super
|
11
|
+
STDERR.write("\n")
|
12
|
+
end
|
13
|
+
|
14
|
+
def visit_feature(feature)
|
15
|
+
STDERR.write(".")
|
16
|
+
@current_feature = {:filename => feature.file}
|
17
|
+
if feature.file && File.exists?(feature.file)
|
18
|
+
@current_feature[:last_changed_at] = File.mtime(feature.file)
|
19
|
+
end
|
20
|
+
@scenarios = []
|
21
|
+
@exceptions = []
|
22
|
+
@feature_file_name = feature.file
|
23
|
+
|
24
|
+
super
|
25
|
+
post_attributes = {:feature => @current_feature, :api_key => API_KEY}
|
26
|
+
|
27
|
+
@scenarios.each_with_index do |hash, i|
|
28
|
+
hash.each do |k,v|
|
29
|
+
post_attributes["feature[scenarios_attributes][#{i}][#{k}]"] = v
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
begin
|
34
|
+
response = RestClient.post PROJECT_URL + "/features.xml", post_attributes
|
35
|
+
rescue => e
|
36
|
+
STDERR.puts("\nCould not upload #{@feature_file_name}")
|
37
|
+
end
|
38
|
+
@feature_file_name = ""
|
39
|
+
end
|
40
|
+
|
41
|
+
def visit_feature_name(name)
|
42
|
+
lines = name.split(/\r?\n/)
|
43
|
+
title = lines[0].gsub(/^\s*Feature:\s*/,'').strip if lines[0] =~ /^\s*Feature:/
|
44
|
+
title = title_from_file_name if title.nil? || title == ""
|
45
|
+
@current_feature[:title] = title
|
46
|
+
@current_feature[:narrative] = lines[1..-1].map {|l| l.strip }.join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
def title_from_file_name
|
50
|
+
@feature_file_name.gsub(/.feature$|^features\//,'').gsub(/_/," ").capitalize
|
51
|
+
end
|
52
|
+
|
53
|
+
def visit_feature_element(feature_element)
|
54
|
+
@current_scenario = {:steps => []}
|
55
|
+
super
|
56
|
+
@current_scenario[:steps] = @current_scenario[:steps].join("\n")
|
57
|
+
@scenarios << @current_scenario
|
58
|
+
end
|
59
|
+
|
60
|
+
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
|
61
|
+
@listing_background = false
|
62
|
+
@current_scenario[:title] = name
|
63
|
+
end
|
64
|
+
|
65
|
+
def visit_step_name(keyword, step_match, status, source_indent, background)
|
66
|
+
if @current_scenario
|
67
|
+
@current_scenario[:steps] << build_step(keyword, step_match)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def visit_py_string(string)
|
72
|
+
if @current_scenario
|
73
|
+
@current_scenario[:steps] << string
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
protected
|
78
|
+
|
79
|
+
def build_step(keyword, step_match)
|
80
|
+
step_name = step_match.format_args(lambda{|param| param })
|
81
|
+
"#{keyword} #{step_name}"
|
82
|
+
end
|
83
|
+
|
84
|
+
def format_exception(exception)
|
85
|
+
(["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rakugoka
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Roland Swingler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-23 00:00:00 +01:00
|
13
|
+
default_executable: rakugoka
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: cucumber
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0.3"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rest-client
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description:
|
36
|
+
email: roland.swingler@gmail.com
|
37
|
+
executables:
|
38
|
+
- rakugoka
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README.rdoc
|
47
|
+
- Rakefile
|
48
|
+
- VERSION
|
49
|
+
- bin/rakugoka
|
50
|
+
- lib/rakugoka.rb
|
51
|
+
- lib/rakugoka/formatter/importer.rb
|
52
|
+
- test/rakugoka_test.rb
|
53
|
+
- test/test_helper.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://rakugoka.rubyforge.org/
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project: rakugoka
|
78
|
+
rubygems_version: 1.3.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Allows you to upload cucumber features to Rakugoka
|
82
|
+
test_files:
|
83
|
+
- test/test_helper.rb
|
84
|
+
- test/rakugoka_test.rb
|