eldarscrolls 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/.gitignore +8 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +6 -0
  4. data/ChangeLog.md +63 -0
  5. data/Gemfile +3 -0
  6. data/Guardfile +18 -0
  7. data/MIT_LICENSE +20 -0
  8. data/README.md +157 -0
  9. data/Rakefile +78 -0
  10. data/bin/eldar +7 -0
  11. data/bin/eldarscrolls +7 -0
  12. data/eldarscrolls.gemspec +32 -0
  13. data/features/step_definitions/common_steps.rb +211 -0
  14. data/features/support/common.rb +51 -0
  15. data/features/support/env.rb +18 -0
  16. data/lib/eldarscrolls.rb +10 -0
  17. data/lib/eldarscrolls/command.rb +85 -0
  18. data/lib/eldarscrolls/config.rb +86 -0
  19. data/lib/eldarscrolls/scroll.rb +106 -0
  20. data/lib/eldarscrolls/scrolls.rb +38 -0
  21. data/lib/eldarscrolls/template.rb +67 -0
  22. data/lib/rails/generators/.DS_Store +0 -0
  23. data/lib/rails/generators/run_template/USAGE +13 -0
  24. data/lib/rails/generators/run_template/run_template_generator.rb +13 -0
  25. data/sample.rb +74 -0
  26. data/scrolls/active_admin.rb +19 -0
  27. data/scrolls/capybara.rb +34 -0
  28. data/scrolls/cucumber.rb +21 -0
  29. data/scrolls/delayed_job.rb +94 -0
  30. data/scrolls/env_yaml.rb +53 -0
  31. data/scrolls/eycloud.rb +72 -0
  32. data/scrolls/eycloud_recipes_on_deploy.rb +20 -0
  33. data/scrolls/git.rb +17 -0
  34. data/scrolls/github.rb +38 -0
  35. data/scrolls/guard.rb +75 -0
  36. data/scrolls/jquery.rb +11 -0
  37. data/scrolls/mysql.rb +51 -0
  38. data/scrolls/passenger.rb +11 -0
  39. data/scrolls/postgresql.rb +54 -0
  40. data/scrolls/prototype.rb +21 -0
  41. data/scrolls/puma.rb +11 -0
  42. data/scrolls/rails_basics.rb +54 -0
  43. data/scrolls/redis.rb +19 -0
  44. data/scrolls/resque.rb +59 -0
  45. data/scrolls/rspec.rb +21 -0
  46. data/scrolls/simple_form.rb +19 -0
  47. data/scrolls/split.rb +35 -0
  48. data/scrolls/spork.rb +19 -0
  49. data/scrolls/sqlite3.rb +10 -0
  50. data/scrolls/test_unit.rb +11 -0
  51. data/scrolls/thin.rb +10 -0
  52. data/scrolls/twitter_bootstrap.rb +41 -0
  53. data/scrolls/unicorn.rb +10 -0
  54. data/scrolls/zzz/activerecord.rb +69 -0
  55. data/scrolls/zzz/cancan.rb +16 -0
  56. data/scrolls/zzz/carrierwave.rb +42 -0
  57. data/scrolls/zzz/carrierwave_direct.rb +13 -0
  58. data/scrolls/zzz/cartographer.rb +33 -0
  59. data/scrolls/zzz/devise.rb +52 -0
  60. data/scrolls/zzz/devise_invitable.rb +23 -0
  61. data/scrolls/zzz/event_calendar.rb +12 -0
  62. data/scrolls/zzz/factory_girl.rb +38 -0
  63. data/scrolls/zzz/ffaker.rb +22 -0
  64. data/scrolls/zzz/fixture_builder.rb +35 -0
  65. data/scrolls/zzz/forgery.rb +15 -0
  66. data/scrolls/zzz/haml.rb +11 -0
  67. data/scrolls/zzz/heroku.rb +58 -0
  68. data/scrolls/zzz/hoptoad.rb +34 -0
  69. data/scrolls/zzz/inherited_resources.rb +12 -0
  70. data/scrolls/zzz/intercom.rb +35 -0
  71. data/scrolls/zzz/jammit.rb +43 -0
  72. data/scrolls/zzz/jasmine.rb +12 -0
  73. data/scrolls/zzz/mini_magick.rb +13 -0
  74. data/scrolls/zzz/mongo_mapper.rb +20 -0
  75. data/scrolls/zzz/mongohq.rb +61 -0
  76. data/scrolls/zzz/mongoid.rb +20 -0
  77. data/scrolls/zzz/mootools.rb +23 -0
  78. data/scrolls/zzz/newrelic.rb +11 -0
  79. data/scrolls/zzz/nifty_generators.rb +21 -0
  80. data/scrolls/zzz/oa_oauth.rb +12 -0
  81. data/scrolls/zzz/omniauth.rb +55 -0
  82. data/scrolls/zzz/paper_trail.rb +17 -0
  83. data/scrolls/zzz/pow.rb +12 -0
  84. data/scrolls/zzz/rails_admin.rb +22 -0
  85. data/scrolls/zzz/rails_dev_tweaks.rb +10 -0
  86. data/scrolls/zzz/rails_erd.rb +9 -0
  87. data/scrolls/zzz/rails_footnotes.rb +14 -0
  88. data/scrolls/zzz/ransack.rb +32 -0
  89. data/scrolls/zzz/rmagick.rb +13 -0
  90. data/scrolls/zzz/sass.rb +13 -0
  91. data/scrolls/zzz/sequel.rb +13 -0
  92. data/scrolls/zzz/settingslogic.rb +43 -0
  93. data/scrolls/zzz/shoulda_matchers.rb +11 -0
  94. data/scrolls/zzz/sidekiq.rb +23 -0
  95. data/scrolls/zzz/slim.rb +11 -0
  96. data/scrolls/zzz/thinking_sphinx.rb +14 -0
  97. data/scrolls/zzz/vanity.rb +35 -0
  98. data/spec/eldarscrolls/config_spec.rb +99 -0
  99. data/spec/eldarscrolls/scroll_spec.rb +103 -0
  100. data/spec/eldarscrolls/scrolls/sanity_spec.rb +30 -0
  101. data/spec/eldarscrolls/scrolls_spec.rb +24 -0
  102. data/spec/eldarscrolls/template_spec.rb +57 -0
  103. data/spec/spec_helper.rb +11 -0
  104. data/spec/support/rails_directory.rb +17 -0
  105. data/spec/support/template_runner.rb +28 -0
  106. data/templates/helpers.erb +45 -0
  107. data/templates/layout.erb +43 -0
  108. data/templates/new_scroll.erb +28 -0
  109. data/templates/scroll.erb +10 -0
  110. data/version.rb +3 -0
  111. metadata +299 -0
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ ./test_run
5
+ dist/*
6
+ .idea
7
+ .rvmrc
8
+
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format=progress
2
+ --colour
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - jruby
5
+ - rbx
6
+ - ree
@@ -0,0 +1,63 @@
1
+ # ChangeLog
2
+
3
+ New
4
+
5
+ * `split` - AB testing promoed in RailsCasts
6
+ * `spork` - clean running of tests
7
+ * `resque` - always includes admin dashboard
8
+
9
+ Fixed
10
+
11
+ * `cucumber` - creates databases before running installer
12
+
13
+ Internal
14
+
15
+ * Replace ZenTest with Guard
16
+ * Add 'rake list:categories' task
17
+
18
+ ## v0.6
19
+
20
+ * `twitter_bootstrap` - automatically includes `simple_form`; includes flash msg
21
+ * `github` - asks for a new repo name if cannot create a repository
22
+ * `rails_basics` - default flash message
23
+ * `jquery` & `prototype` - former is already default in Rails 3.1+ now
24
+
25
+ New
26
+ * `guard` - guard support for all supported scrolls
27
+ * `postgresql`
28
+ * All untested scrolls moved into scrolls/zzz
29
+
30
+ ## v0.5
31
+
32
+ * `twitter_bootstrap` - based on public RailsCast
33
+ * `eycloud` - now using `ey_cli` to create/boot environments
34
+
35
+ ## v0.4
36
+
37
+ * SCROLLS ARE IN, "recipes" are out. Wizards use scrolls. Alchemists use recipes.
38
+ * Scrolls have no dependencies on `eycloud` or `eycloud_recipes_on_deploy`; these are optional
39
+ * `github` - GitHub repository creation
40
+ * `resque` + `delayed_job` can install their admin consoles
41
+ * `sidekiq` - high performance, low cost alternative to `resque` or `delayed_job`
42
+
43
+ ## v0.3
44
+
45
+ * Engine Yard support - Resque
46
+ * Removed a bunch of recipes that didn't see useful/common
47
+
48
+ ### v0.3.1
49
+
50
+ * Resque recipe works a treat.
51
+
52
+ Try this on EY Cloud! `eldarscrolls new demomysql -r sqlite3 mysql resque rails_basics git`
53
+
54
+ ## v0.2
55
+
56
+ Merged lots of branches/forks
57
+
58
+ ## v0.2.1
59
+
60
+ * Cleaned up many recipes
61
+ * Added :website attribute to recipes
62
+ * Convert all recipes to use supported categories
63
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,18 @@
1
+ guard 'cucumber' do
2
+ watch(%r{^features/.+\.feature$})
3
+ watch(%r{^features/support/.+$}) { 'features' }
4
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
5
+ end
6
+
7
+ guard 'rspec', :version => 2 do
8
+ watch(%r{^spec/.+_spec\.rb$})
9
+ watch(%r{^scrolls/(.+)\.rb$}) { |m| "spec/eldarscrolls/scrolls/sanity_spec.rb" }
10
+ watch(%r{^lib/eldarscrolls/(.+)\.rb$}) { |m| "spec/eldarscrolls/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
13
+
14
+ guard 'bundler' do
15
+ watch('Gemfile')
16
+ watch(/^.+\.gemspec/)
17
+ end
18
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dr Nic Williams and Engine Yard LLC
2
+ Copyright (c) 2010 Michael Bleigh and Intridea, Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
@@ -0,0 +1,157 @@
1
+ # The Eldar Scrolls for creating and transforming Rails apps
2
+
3
+ ```
4
+ ______ __ ____ ____
5
+ / __/ /__/ /__ _____ / __/__________ / / /__
6
+ / _// / _ / _ `/ __/ _\ \/ __/ __/ _ \/ / (_-<
7
+ /___/_/\_,_/\_,_/_/ /___/\__/_/ \___/_/_/___/
8
+ ```
9
+
10
+ The Eldar Scrolls is a magical tool to generate new Rails and modify existing Rails applications (coming) to include your favourite, powerful magic. Authentication, testing, persistence, javascript, css, deployment, and templating - there's a magical scroll for you.
11
+
12
+ * Follow on twitter [@eldarscrolls][9]
13
+
14
+ An example application that was built by the Eldar Scrolls is at [https://github.com/drnic/mydemoapp][14]. The generated README shows all the scrolls that were included.
15
+
16
+ ## Installation
17
+
18
+ Installation is simple:
19
+
20
+ gem install eldarscrolls
21
+
22
+ ## Usage
23
+
24
+ The primary usage of the `eldarscrolls` gem is to utilize its interactive terminal command to build a new Rails application. To get started, you can simply run the command thusly:
25
+
26
+ eldar new APP_NAME
27
+ eldarscrolls new APP_NAME
28
+
29
+ Where `APP_NAME` is the directory in which you wish to create the app (it mirrors the Rails creation syntax). You will then be guided through the scroll selection process and subsequently the Rails app generator will automatically run with the template and all appropriate command line options included.
30
+
31
+ To transform an existing Rails app, you ... wait, that's not implemented yet. But since the "apply template" feature of `rails new APP_NAME -m template.rb` is implemented in Thor, I mean, how hard could it be?*
32
+
33
+ ### Specifying Scrolls
34
+
35
+ If you wish to skip the interactive scroll selector, you may provide instead a list of scrolls with the `-s` or `--scrolls` option:
36
+
37
+ eldar new APP_NAME -s twitter_bootstrap mysql resque
38
+ eldar new APP_NAME --scrolls postgresql github eycloud
39
+
40
+ This will automatically generate a Rails template with the provided scrolls and begin the app generator.
41
+
42
+ ### Listing Scrolls
43
+
44
+ You can also print out a simple list of scrolls:
45
+
46
+ eldar list
47
+
48
+ Or print out a list of scrolls for a specific category:
49
+
50
+ eldar list persistence
51
+
52
+ ## Deployment Support
53
+
54
+ Web applications are boring if they aren't running proudly on the internet. The Eldar Scrolls make this automatic for your favourite providers!
55
+
56
+ ### Engine Yard
57
+
58
+ Scroll: `eycloud`
59
+
60
+ If you choose the `eycloud` scroll, your application will be automatically deployed to [Engine Yard Cloud][6]. Your code will also be automatically stored on a private/public GitHub repository.
61
+
62
+ The `eycloud` scroll magically transforms many other scrolls to work specifically for [Engine Yard Cloud][6]. For example:
63
+
64
+ * `postgresql` - the environment will have PostgreSQL selected instead of MySQL
65
+ * `resque` - the environment will have Resque and Redis
66
+
67
+ ### Heroku
68
+
69
+ The Eldar Scrolls needs a Heroku Master to support Heroku for the Eldar Scrolls.
70
+
71
+ There is some initial work in the [current scrolls][11] and the [archived/unsupported scrolls][12]
72
+
73
+ ### CloudFoundry
74
+
75
+ The Eldar Scrolls needs a CloudFoundry Master to support CloudFoundry for the Eldar Scrolls.
76
+
77
+ ## Authoring Scrolls of Magical Mystery
78
+
79
+ Create new scrolls using:
80
+
81
+ rake new NAME=scroll-name
82
+
83
+ Submitting a scroll is actually a very straightforward process. Scrolls are made of up **template code** and **YAML back-matter** stored in a ruby file. The `__END__` parsing convention is used so that each scroll is actually a valid, parseable Ruby file. The structure of a scroll looks something like this:
84
+
85
+ ```ruby
86
+ gem 'supergem'
87
+
88
+ after_bundler do
89
+ generate "supergem:install"
90
+ end
91
+
92
+ __END__
93
+
94
+ category: templating
95
+ name: SuperGem
96
+ description: Installs SuperGem which is useful for things
97
+ author: mbleigh
98
+ ```
99
+
100
+ It's really that simple. The gem has RSpec tests that automatically validate each scroll in the repository, so you should run `rake spec` as a basic sanity check before submitting a pull request. Note that these don't verify that your scroll code itself works, just that Eldar Scrolls could properly parse and understand your scroll file.
101
+
102
+ ## History
103
+
104
+ This project is an old fashioned fork of [Michael Bleigh][5]'s [Rails Wizard][4]. A new name, new project, and new purpose.
105
+
106
+ This project wouldn't exist without Michael having created [Rails Wizard][4] during Rails Rumble and maintaining and upgrading it for a long time. Sadly support dropped off, several recipes did not work with Rails 3.1+,
107
+
108
+ [Dr Nic][7] originally worked on [Rails Wizard][4] to provide [Engine Yard Cloud][6] support, his employer and his favourite hosting platform. He also merged in a lot of recipes from other forks, and added new recipes for modern projects.
109
+
110
+ Support for Engine Yard Cloud meant integration with Chef Recipes. This meant confusing language - Rails Wizard Recipes and Chef Recipes. He decided that wizards don't use recipes - they use scrolls. Alchemists use recipes. And screw alchemists and their dinky potions. Recipes became Scrolls.
111
+
112
+ "Eldar Scrolls" is a deliberate misspelling of the popular [Elder Scrolls][8] computer game. Ok, it was accidental but "eldarscrolls" and "eldarscrolls" should now be much easier to search for on Twitter and Google; and [@eldarscrolls][9] [eldarscrolls.org][1] were available
113
+
114
+ ## Future
115
+
116
+ * Automatically setup Continuous Integration for new applications - branches "jenkins"
117
+ * Interactive mode is a wizard by categories "pick A, B, C or none"
118
+ * Apply scrolls to existing Rails applications - branch "[apply_scrolls][13]"*
119
+ * Scrolls work or fail fast on Heroku
120
+ * Scrolls work or fail fast on CloudFoundry
121
+ * Scrolls generate their own README - branch "readmes"
122
+ * 3rd party services/add-ons enabled within deployment platform or directly with service
123
+ * Padrino / Sinatra applications
124
+ * Non-Ruby applications (Lithium for PHP, etc)
125
+
126
+ Missing scrolls
127
+
128
+ * MongoDB - branch "mongodb"
129
+ * OmniAuth - branch "omniauth"
130
+ * Sidekiq - branch "sidekiq"
131
+
132
+ How hard could it be?
133
+
134
+ * `*` 'How hard could it be to transform applications?' - pretty hard. Scrolls need to be aware of the current code base, rather than merely the list of other scrolls being used to create a new app. Scrolls also need to know about versions of Rails rather than just latest rails.
135
+
136
+ ## Thanks
137
+
138
+ ASCII banner - http://www.network-science.de/ascii/ using 'smslant' font.
139
+
140
+ ## License
141
+
142
+ Eldar Scrolls and its scrolls are distributed under the MIT License. See [MIT_LICENSE][10] for the actual words.
143
+
144
+ [1]:http://eldarscrolls.org/
145
+ [2]:https://github.com/drnic/eldarscrolls
146
+ [2]:https://github.com/drnic/eldarscrolls/tree/master/scrolls
147
+ [4]:https://github.com/intridea/rails_wizard
148
+ [5]:https://github.com/mbleigh
149
+ [6]:http://www.engineyard.com/products/cloud
150
+ [7]:http://drnicwilliams.com
151
+ [8]:http://www.elderscrolls.com/
152
+ [9]:https://twitter.com/elderscrolls
153
+ [10]:https://github.com/drnic/eldarscrolls/blob/master/MIT_LICENSE
154
+ [11]:https://github.com/drnic/eldarscrolls/tree/master/scrolls
155
+ [12]:https://github.com/drnic/eldarscrolls/tree/master/scrolls/zzz
156
+ [13]:https://github.com/drnic/eldarscrolls/tree/apply_scrolls
157
+ [14]:https://github.com/drnic/mydemoapp
@@ -0,0 +1,78 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc "run specs"
6
+ RSpec::Core::RakeTask.new
7
+
8
+ task :default => :spec
9
+
10
+
11
+ desc "Remove the test_run Rails app (if it's there)"
12
+ task :clean do
13
+ system 'rm -rf test_run'
14
+ end
15
+
16
+ desc "Execute a test run with the specified scrolls."
17
+ task :run => :clean do
18
+ scrolls = ENV['SCROLLS'].split(',')
19
+
20
+ require 'tempfile'
21
+ require 'eldarscrolls'
22
+
23
+ template = EldarScrolls::Template.new(scrolls)
24
+
25
+ begin
26
+ dir = Dir.mktmpdir "rails_template"
27
+ Dir.chdir(dir) do
28
+ file = File.open('template.rb', 'w')
29
+ file.write template.compile
30
+ file.close
31
+
32
+ system "rails new test_run -m template.rb #{template.args.join(' ')}"
33
+
34
+ puts "\n\n cd #{dir} # look at the app"
35
+ puts "#{ENV['EDITOR']} #{dir} # edit the app"
36
+ end
37
+ end
38
+ end
39
+
40
+ desc "Prints out a template from the provided scrolls."
41
+ task :print do
42
+ require 'eldarscrolls'
43
+
44
+ scrolls = ENV['SCROLLS'].split(',')
45
+ puts EldarScrolls::Template.new(scrolls).compile
46
+ end
47
+
48
+ desc "Create a new scroll"
49
+ task :new do
50
+ unless (name = ENV['NAME']) && name.size > 0
51
+ $stderr.puts "USAGE: rake new NAME=scroll-name"
52
+ exit 1
53
+ end
54
+ require 'active_support/inflector'
55
+ require 'erb'
56
+ require 'eldarscrolls/template'
57
+ scroll = EldarScrolls::Template.render("new_scroll", binding)
58
+ scroll_path = "scrolls/#{name}.rb"
59
+ File.open(scroll_path, "w") { |file| file << scroll }
60
+ `open #{scroll_path}`
61
+ end
62
+
63
+ namespace :list do
64
+ desc "Display scrolls by category"
65
+ task :categories do
66
+ require 'eldarscrolls'
67
+ categories = EldarScrolls::Scrolls.categories.sort
68
+ categories = (categories - ["other"]) + ["other"]
69
+ categories.each do |category|
70
+ puts "#{category}: #{EldarScrolls::Scrolls.for(category).join(", ")}"
71
+ end
72
+ end
73
+
74
+ # desc "Display scrolls by exclusion"
75
+ # task :exclusions do
76
+ #
77
+ # end
78
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.dirname(__FILE__) + '/../lib'
3
+
4
+ require 'rubygems'
5
+ require 'eldarscrolls/command'
6
+
7
+ EldarScrolls::Command.start
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $:.push File.dirname(__FILE__) + '/../lib'
3
+
4
+ require 'rubygems'
5
+ require 'eldarscrolls/command'
6
+
7
+ EldarScrolls::Command.start
@@ -0,0 +1,32 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require File.dirname(__FILE__) + "/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "eldarscrolls"
7
+ s.version = EldarScrolls::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Michael Bleigh", "Dr Nic Williams"]
10
+ s.email = ["michael@intridea.com", "drnicwilliams@gmail.com"]
11
+ s.homepage = "http://eldarscrolls.org/"
12
+ s.summary = %q{The Eldar Scrolls is a magical tool to generate new Rails and modify existing Rails applications (coming) to include your favourite, powerful magic. }
13
+ s.description = %q{The Eldar Scrolls is a magical tool to generate new Rails and modify existing Rails applications (coming) to include your favourite, powerful magic. }
14
+
15
+ s.add_dependency "i18n"
16
+ s.add_dependency "json", "1.6.5"
17
+ s.add_dependency "activesupport", "~> 3.0"
18
+ s.add_dependency "thor"
19
+ s.add_development_dependency "rspec", "~> 2.5.0"
20
+ s.add_development_dependency "guard-rspec"
21
+ s.add_development_dependency "cucumber"
22
+ s.add_development_dependency "guard-cucumber"
23
+ s.add_development_dependency "bundler", "~> 1.1.0"
24
+ s.add_development_dependency "guard-bundler"
25
+ s.add_development_dependency "rails", "~> 3.0"
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+ end
32
+
@@ -0,0 +1,211 @@
1
+ Given /^this project is active project folder/ do
2
+ @active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
3
+ end
4
+
5
+ Given /^env variable \$([\w_]+) set to( project path|) "(.*)"/ do |env_var, path, value|
6
+ in_project_folder {
7
+ value = File.expand_path(value)
8
+ } unless path.empty?
9
+ ENV[env_var] = value
10
+ end
11
+
12
+ Given /"(.*)" folder is deleted/ do |folder|
13
+ in_project_folder { FileUtils.rm_rf folder }
14
+ end
15
+
16
+ When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
17
+ @stdout = StringIO.new
18
+ in_project_folder do
19
+ if Object.const_defined?("APP_ROOT")
20
+ APP_ROOT.replace(FileUtils.pwd)
21
+ else
22
+ APP_ROOT = FileUtils.pwd
23
+ end
24
+ run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
25
+ end
26
+ File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
27
+ @stdout.rewind
28
+ f << @stdout.read
29
+ end
30
+ end
31
+
32
+ When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
33
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
34
+ in_project_folder do
35
+ system "#{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
36
+ end
37
+ end
38
+
39
+ When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
40
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
41
+ in_project_folder do
42
+ system "ruby -rubygems #{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
43
+ end
44
+ end
45
+
46
+ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
47
+ if executable == "eldarscrolls"
48
+ require 'eldarscrolls'
49
+ require 'eldarscrolls/command'
50
+ in_project_folder do
51
+ stdout, stderr = capture_stdios do
52
+ Engineyard::Jenkins::CLI.start(arguments.split(/ /))
53
+ end
54
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
55
+ File.open(@stdout, "w") {|f| f << stdout; f << stderr}
56
+ end
57
+ else
58
+ @stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
59
+ executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
60
+ in_project_folder do
61
+ system "ruby -rubygems #{executable.inspect} #{arguments} > #{@stdout.inspect} 2> #{@stdout.inspect}"
62
+ end
63
+ end
64
+ end
65
+
66
+ When /^I invoke task "rake (.*)"/ do |task|
67
+ @stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
68
+ in_project_folder do
69
+ system "bundle exec rake #{task} --trace > #{@stdout.inspect} 2> #{@stdout.inspect}"
70
+ end
71
+ end
72
+
73
+ Then /^folder "(.*)" (is|is not) created/ do |folder, is|
74
+ in_project_folder do
75
+ File.exists?(folder).should(is == 'is' ? be_true : be_false)
76
+ end
77
+ end
78
+
79
+ Then /^file "(.*)" (is|is not) created/ do |file, is|
80
+ in_project_folder do
81
+ File.exists?(file).should(is == 'is' ? be_true : be_false)
82
+ end
83
+ end
84
+
85
+ Then /^file with name matching "(.*)" is created/ do |pattern|
86
+ in_project_folder do
87
+ Dir[pattern].should_not be_empty
88
+ end
89
+ end
90
+
91
+ Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
92
+ in_project_folder do
93
+ actual_output = File.read(file)
94
+ (does == 'does') ?
95
+ actual_output.should(match(/#{regex}/)) :
96
+ actual_output.should_not(match(/#{regex}/))
97
+ end
98
+ end
99
+
100
+ Then /^file "([^"]*)" contains "([^"]*)"$/ do |file, text|
101
+ in_project_folder do
102
+ actual_output = File.read(file)
103
+ actual_output.should contain(text)
104
+ end
105
+ end
106
+
107
+
108
+ Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
109
+ File.exists?(gem_file).should be_true
110
+ File.exists?(project_file).should be_true
111
+ gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
112
+ project_file_contents = File.read(File.join(@active_project_folder, project_file))
113
+ project_file_contents.should == gem_file_contents
114
+ end
115
+
116
+ Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
117
+ actual_output = get_command_output
118
+ does_invoke == "does" ?
119
+ actual_output.should(match(/dependency\s+#{generator}/)) :
120
+ actual_output.should_not(match(/dependency\s+#{generator}/))
121
+ end
122
+
123
+ Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
124
+ actual_output = get_command_output
125
+ actual_output.should match(/#{opt1}/)
126
+ actual_output.should match(/#{opt2}/)
127
+ end
128
+
129
+ Then /^I should see "([^\"]*)"$/ do |text|
130
+ actual_output = get_command_output
131
+ actual_output.should contain(text)
132
+ end
133
+
134
+ Then /^I should not see "([^\"]*)"$/ do |text|
135
+ actual_output =
136
+ actual_output.should_not contain(text)
137
+ end
138
+
139
+ Then /^I should see$/ do |text|
140
+ actual_output = get_command_output
141
+ actual_output.should contain(text)
142
+ end
143
+
144
+ Then /^I should not see$/ do |text|
145
+ actual_output = get_command_output
146
+ actual_output.should_not contain(text)
147
+ end
148
+
149
+ Then /^I should see exactly$/ do |text|
150
+ actual_output = get_command_output
151
+ actual_output.should == text
152
+ end
153
+
154
+ Then /^I should see all (\d+) tests pass/ do |expected_test_count|
155
+ expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
156
+ actual_output = get_command_output
157
+ actual_output.should match(expected)
158
+ end
159
+
160
+ Then /^I should see all (\d+) examples pass/ do |expected_test_count|
161
+ expected = %r{^#{expected_test_count} examples?, 0 failures}
162
+ actual_output = get_command_output
163
+ actual_output.should match(expected)
164
+ end
165
+
166
+ Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
167
+ in_project_folder do
168
+ yaml = eval yaml
169
+ YAML.load(File.read(file)).should == yaml
170
+ end
171
+ end
172
+
173
+ Then /^Rakefile can display tasks successfully/ do
174
+ @stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
175
+ in_project_folder do
176
+ system "rake -T > #{@stdout.inspect} 2> #{@stdout.inspect}"
177
+ end
178
+ actual_output = get_command_output
179
+ actual_output.should match(/^rake\s+\w+\s+#\s.*/)
180
+ end
181
+
182
+ Then /^task "rake (.*)" is executed successfully/ do |task|
183
+ @stdout.should_not be_nil
184
+ actual_output = get_command_output
185
+ actual_output.should_not match(/^Don't know how to build task '#{task}'/)
186
+ actual_output.should_not match(/Error/i)
187
+ end
188
+
189
+ Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
190
+ in_project_folder do
191
+ gem_file = Dir["pkg/*.gem"].first
192
+ gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
193
+ spec_value = gem_spec.send(key.to_sym)
194
+ spec_value.to_s.should match(/#{regex}/)
195
+ end
196
+ end
197
+
198
+ Then /^the file "([^\"]*)" is a valid gemspec$/ do |filename|
199
+ spec = eval(File.read(filename))
200
+ spec.validate
201
+ end
202
+
203
+ When /^I create a new node with the following options on "http:\/\/(.+?):(\d+)":$/ do |host, port, table|
204
+ options = table.raw.inject({}) do |options, (key, value)|
205
+ options[(key.to_sym rescue key) || key] = value
206
+ options
207
+ end
208
+
209
+ Jenkins::Api.setup_base_url(:host => host, :port => port.to_i)
210
+ Jenkins::Api.add_node(options)
211
+ end