andhapp-decoct 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +0 -0
- data/Rakefile +45 -0
- data/VERSION.yml +4 -0
- data/bin/decoct +14 -0
- data/decoct.gemspec +67 -0
- data/lib/dconstants.rb +8 -0
- data/lib/dscript.rb +64 -0
- data/test/templates/generic_app.rb +7 -0
- data/test/templates/spec/rcov.opts +2 -0
- data/test/templates/spec/spec.opts +4 -0
- data/test/templates/spec/spec_helper.rb +38 -0
- data/test/ts_script.rb +87 -0
- metadata +115 -0
data/README.markdown
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# sinatra-rspec
|
2
|
+
|
3
|
+
%W{rake rake/testtask rake/rdoctask rcov/rcovtask}.each{|x| require x}
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |s|
|
8
|
+
s.name = "decoct"
|
9
|
+
s.summary = "Its a simple gem which creates a project structure for sinatra to work with rspec, ZenTest, Snarl(on Windows), RedGreen, Rcov"
|
10
|
+
s.email = "anuj@andhapp.com"
|
11
|
+
s.homepage = "http://github.com/andhapp/decoct"
|
12
|
+
s.description = "Sinatra Rspec project generator"
|
13
|
+
s.authors = ["Anuj Dutta"]
|
14
|
+
s.add_dependency 'rspec'
|
15
|
+
s.add_dependency 'ZenTest'
|
16
|
+
s.add_dependency 'ruby-snarl'
|
17
|
+
s.add_dependency 'redgreen'
|
18
|
+
s.add_dependency 'rcov'
|
19
|
+
end
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.pattern = 'test/**/*_test.rb'
|
27
|
+
t.verbose = false
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::RDocTask.new do |rdoc|
|
31
|
+
rdoc.rdoc_dir = 'rdoc'
|
32
|
+
rdoc.title = 'Jeweler'
|
33
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
34
|
+
rdoc.rdoc_files.include('README*')
|
35
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
|
+
end
|
37
|
+
|
38
|
+
Rcov::RcovTask.new do |t|
|
39
|
+
t.libs << "test"
|
40
|
+
t.test_files = FileList['test/*_test.rb']
|
41
|
+
t.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
task :default => :rcov
|
45
|
+
|
data/VERSION.yml
ADDED
data/bin/decoct
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
app_path = ARGV.first
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../lib'
|
4
|
+
require 'dscript'
|
5
|
+
|
6
|
+
Dedoct::Dscript.new(app_path)
|
7
|
+
Dedoct::Dscript.run
|
8
|
+
Dedoct::Dscript.create_lib
|
9
|
+
Dedoct::Dscript.create_spec
|
10
|
+
Dedoct::Dscript.create_views
|
11
|
+
Dedoct::Dscript.create_public
|
12
|
+
Dedoct::Dscript.copy_autotest_file
|
13
|
+
Dedoct::Dscript.copy_rspec_files
|
14
|
+
Dedoct::Dscript.create_app_file
|
data/decoct.gemspec
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{decoct}
|
5
|
+
s.version = "1.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Anuj Dutta"]
|
9
|
+
s.date = %q{2009-04-19}
|
10
|
+
s.default_executable = %q{decoct}
|
11
|
+
s.description = %q{Sinatra Rspec project generator}
|
12
|
+
s.email = %q{anuj@andhapp.com}
|
13
|
+
s.executables = ["decoct"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.markdown"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"README.markdown",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION.yml",
|
21
|
+
"bin/decoct",
|
22
|
+
"decoct.gemspec",
|
23
|
+
"lib/dconstants.rb",
|
24
|
+
"lib/dscript.rb",
|
25
|
+
"test/templates/generic_app.rb",
|
26
|
+
"test/templates/spec/rcov.opts",
|
27
|
+
"test/templates/spec/spec.opts",
|
28
|
+
"test/templates/spec/spec_helper.rb",
|
29
|
+
"test/ts_script.rb"
|
30
|
+
]
|
31
|
+
s.has_rdoc = true
|
32
|
+
s.homepage = %q{http://github.com/andhapp/decoct}
|
33
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.3.1}
|
36
|
+
s.summary = %q{Its a simple gem which creates a project structure for sinatra to work with rspec, ZenTest, Snarl(on Windows), RedGreen, Rcov}
|
37
|
+
s.test_files = [
|
38
|
+
"test/templates/generic_app.rb",
|
39
|
+
"test/templates/spec/spec_helper.rb",
|
40
|
+
"test/ts_script.rb"
|
41
|
+
]
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
45
|
+
s.specification_version = 2
|
46
|
+
|
47
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
48
|
+
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
49
|
+
s.add_runtime_dependency(%q<ZenTest>, [">= 0"])
|
50
|
+
s.add_runtime_dependency(%q<ruby-snarl>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<redgreen>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<rcov>, [">= 0"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
55
|
+
s.add_dependency(%q<ZenTest>, [">= 0"])
|
56
|
+
s.add_dependency(%q<ruby-snarl>, [">= 0"])
|
57
|
+
s.add_dependency(%q<redgreen>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
59
|
+
end
|
60
|
+
else
|
61
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
62
|
+
s.add_dependency(%q<ZenTest>, [">= 0"])
|
63
|
+
s.add_dependency(%q<ruby-snarl>, [">= 0"])
|
64
|
+
s.add_dependency(%q<redgreen>, [">= 0"])
|
65
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
+
end
|
67
|
+
end
|
data/lib/dconstants.rb
ADDED
data/lib/dscript.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'ftools'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/dconstants'
|
3
|
+
|
4
|
+
module Dedoct
|
5
|
+
|
6
|
+
include Dedoct::Dconstants
|
7
|
+
|
8
|
+
# move the creation into a module and just include that module
|
9
|
+
class Dscript
|
10
|
+
|
11
|
+
attr_reader :app_name
|
12
|
+
|
13
|
+
def initialize(app_name)
|
14
|
+
fail "app name cannot be nil or empty!!!" if app_name.eql?(nil) || app_name.empty?
|
15
|
+
@app_name = app_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
create_app_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_lib
|
23
|
+
create_dir(Dconstants::LIB)
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_spec
|
27
|
+
create_dir(Dconstants::SPEC)
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_views
|
31
|
+
create_dir(Dconstants::VIEWS)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_public
|
35
|
+
create_dir(Dconstants::PUBLIC)
|
36
|
+
end
|
37
|
+
|
38
|
+
def copy_autotest_file
|
39
|
+
File.copy("templates/.autotest", "#{app_name}/.autotest")
|
40
|
+
end
|
41
|
+
|
42
|
+
def copy_rspec_files
|
43
|
+
File.copy("templates/spec/spec.opts", "#{app_name}/spec/spec.opts")
|
44
|
+
File.copy("templates/spec/rcov.opts", "#{app_name}/spec/rcov.opts")
|
45
|
+
File.copy("templates/spec/spec_helper.rb", "#{app_name}/spec/spec_helper.rb")
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_app_file
|
49
|
+
File.copy("templates/generic_app.rb", "#{app_name}/#{app_name}.rb")
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def create_app_dir
|
55
|
+
create_dir
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_dir(value = '')
|
59
|
+
Dir.mkdir("#{app_name}/#{value}")
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
|
2
|
+
# from the project root directory.
|
3
|
+
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
|
4
|
+
require 'spec/autorun'
|
5
|
+
|
6
|
+
Spec::Runner.configure do |config|
|
7
|
+
# == Fixtures
|
8
|
+
#
|
9
|
+
# You can declare fixtures for each example_group like this:
|
10
|
+
# describe "...." do
|
11
|
+
# fixtures :table_a, :table_b
|
12
|
+
#
|
13
|
+
# Alternatively, if you prefer to declare them only once, you can
|
14
|
+
# do so right here. Just uncomment the next line and replace the fixture
|
15
|
+
# names with your fixtures.
|
16
|
+
#
|
17
|
+
# config.global_fixtures = :table_a, :table_b
|
18
|
+
#
|
19
|
+
# If you declare global fixtures, be aware that they will be declared
|
20
|
+
# for all of your examples, even those that don't use them.
|
21
|
+
#
|
22
|
+
# You can also declare which fixtures to use (for example fixtures for test/fixtures):
|
23
|
+
#
|
24
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures/'
|
25
|
+
#
|
26
|
+
# == Mock Framework
|
27
|
+
#
|
28
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
29
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
30
|
+
#
|
31
|
+
# config.mock_with :mocha
|
32
|
+
# config.mock_with :flexmock
|
33
|
+
# config.mock_with :rr
|
34
|
+
#
|
35
|
+
# == Notes
|
36
|
+
#
|
37
|
+
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
|
38
|
+
end
|
data/test/ts_script.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
%W(test/unit redgreen shoulda rr ../lib/dscript fileutils).each{|x| require x}
|
2
|
+
|
3
|
+
class TestScript < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def dir_in_app_folder
|
6
|
+
Dir.entries("epoxys").each {|x| [] << x if !File.directory?(x)}
|
7
|
+
end
|
8
|
+
|
9
|
+
context "creating sinatra app with rspec" do
|
10
|
+
setup do
|
11
|
+
@script = Dedoct::Dscript.new('epoxys')
|
12
|
+
@app_name = @script.app_name
|
13
|
+
@script.run
|
14
|
+
end
|
15
|
+
|
16
|
+
should 'create the app directory' do
|
17
|
+
assert File.exists?(@app_name)
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'create a directory called lib' do
|
21
|
+
initial_num_of_dir = dir_in_app_folder().size()
|
22
|
+
@script.create_lib
|
23
|
+
final_num_of_dir = dir_in_app_folder().size()
|
24
|
+
assert_equal final_num_of_dir, initial_num_of_dir + 1
|
25
|
+
assert_not_nil dir_in_app_folder.index("lib")
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'create a directory called spec and copy the rspec files' do
|
29
|
+
initial_num_of_dir = dir_in_app_folder().size()
|
30
|
+
@script.create_spec
|
31
|
+
final_num_of_dir = dir_in_app_folder().size()
|
32
|
+
|
33
|
+
@script.copy_rspec_files
|
34
|
+
|
35
|
+
assert File.exists?("#{@app_name}/spec/spec.opts")
|
36
|
+
assert File.exists?("#{@app_name}/spec/rcov.opts")
|
37
|
+
assert File.exists?("#{@app_name}/spec/spec_helper.rb")
|
38
|
+
|
39
|
+
assert_equal final_num_of_dir, initial_num_of_dir + 1
|
40
|
+
assert_not_nil dir_in_app_folder.index("spec")
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'create a directory called views' do
|
44
|
+
initial_num_of_dir = dir_in_app_folder().size()
|
45
|
+
@script.create_views
|
46
|
+
final_num_of_dir = dir_in_app_folder().size()
|
47
|
+
assert_equal final_num_of_dir, initial_num_of_dir + 1
|
48
|
+
assert_not_nil dir_in_app_folder.index("views")
|
49
|
+
end
|
50
|
+
|
51
|
+
should 'create a directory called public' do
|
52
|
+
initial_num_of_dir = dir_in_app_folder().size()
|
53
|
+
@script.create_public
|
54
|
+
final_num_of_dir = dir_in_app_folder().size()
|
55
|
+
assert_equal final_num_of_dir, initial_num_of_dir + 1
|
56
|
+
assert_not_nil dir_in_app_folder.index("public")
|
57
|
+
end
|
58
|
+
|
59
|
+
should 'copy the .autotest file to app folder' do
|
60
|
+
@script.copy_autotest_file
|
61
|
+
assert File.exists?("#{@app_name}/.autotest")
|
62
|
+
end
|
63
|
+
|
64
|
+
should 'create the app file' do
|
65
|
+
@script.create_app_file
|
66
|
+
assert File.exists?("#{@app_name}/#{@app_name}.rb")
|
67
|
+
end
|
68
|
+
|
69
|
+
teardown do
|
70
|
+
FileUtils.rmtree @app_name
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context "raise exception when app name is nil or empty" do
|
76
|
+
|
77
|
+
should 'raise an error if there is no app_name is empty' do
|
78
|
+
assert_raises(RuntimeError) {@script = Dedoct::Dscript.new('')}
|
79
|
+
end
|
80
|
+
|
81
|
+
should 'raise an error if there is no app_name is nil' do
|
82
|
+
assert_raises(RuntimeError) {@script = Dedoct::Dscript.new(nil)}
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: andhapp-decoct
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anuj Dutta
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-19 00:00:00 -07:00
|
13
|
+
default_executable: decoct
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: ZenTest
|
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
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: ruby-snarl
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: redgreen
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rcov
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
description: Sinatra Rspec project generator
|
66
|
+
email: anuj@andhapp.com
|
67
|
+
executables:
|
68
|
+
- decoct
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- README.markdown
|
73
|
+
files:
|
74
|
+
- README.markdown
|
75
|
+
- Rakefile
|
76
|
+
- VERSION.yml
|
77
|
+
- bin/decoct
|
78
|
+
- decoct.gemspec
|
79
|
+
- lib/dconstants.rb
|
80
|
+
- lib/dscript.rb
|
81
|
+
- test/templates/generic_app.rb
|
82
|
+
- test/templates/spec/rcov.opts
|
83
|
+
- test/templates/spec/spec.opts
|
84
|
+
- test/templates/spec/spec_helper.rb
|
85
|
+
- test/ts_script.rb
|
86
|
+
has_rdoc: true
|
87
|
+
homepage: http://github.com/andhapp/decoct
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options:
|
90
|
+
- --charset=UTF-8
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 1.2.0
|
109
|
+
signing_key:
|
110
|
+
specification_version: 2
|
111
|
+
summary: Its a simple gem which creates a project structure for sinatra to work with rspec, ZenTest, Snarl(on Windows), RedGreen, Rcov
|
112
|
+
test_files:
|
113
|
+
- test/templates/generic_app.rb
|
114
|
+
- test/templates/spec/spec_helper.rb
|
115
|
+
- test/ts_script.rb
|