rory 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e05de9c3d6f0a76318d9caed584c858f6432819f
4
- data.tar.gz: e178e368a1a4b614a4bc4b23086e325dcd086bbd
3
+ metadata.gz: 08a956b5ad20d37deb355ac86022eccc32d34b4c
4
+ data.tar.gz: fdce7d3b965c84e124a062c1c316db4863808e01
5
5
  SHA512:
6
- metadata.gz: 0cef8af9eda07834faec41228bd5e6a8bc0dfbea13744ff47db9ceef058a57d736205530b8faf61af5dbd967ad62c35fd8adb0093b74fefd73059912f1250d4b
7
- data.tar.gz: 1ce9adbb38f34bdaf3e6e6b25dc4978e973ef32c4bdc1c7b37a34663562a74c9d58dbc15c9d1d5ecf7bb2f4a1e6f6802086149f771ec9d61334d84a1db6c6c8f
6
+ metadata.gz: 2be8cabd2076c605e897bb75488cb58ced01d7d873bf29a7c5179267d68ba5b695e1625cc87e3a8704191aef700f9ccb4a5ae2a257eceba277ecdb85b4a3ed95
7
+ data.tar.gz: a3cb5d88bb4bc5b31aa19c861089452f308e5d4306c0aed99337d3411eff248e371150cbf1af120ac1560780d1e9876b6acf42cb06820f09b9715d0b741685ff
@@ -59,7 +59,7 @@ module Rory
59
59
  initializer_default_middleware
60
60
 
61
61
  def auto_require_paths
62
- @auto_require_paths ||= %w(models controllers helpers)
62
+ @auto_require_paths ||= %w(config/initializers models controllers helpers)
63
63
  end
64
64
 
65
65
  def require_all_files
@@ -0,0 +1,10 @@
1
+ require "thor"
2
+ require_relative "cli/root"
3
+
4
+ module Rory
5
+ module CLI
6
+ def self.start
7
+ Root.start
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require "thor"
2
+ require_relative "generators/application"
3
+
4
+ module Rory
5
+ module CLI
6
+ class Generate < Thor
7
+ register Generators::Application, "app", "app [APP_NAME]", "Create a new Rory application"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,42 @@
1
+ require "rory/support"
2
+
3
+ module Rory
4
+ module CLI
5
+ module Generators
6
+ class Application < Thor::Group
7
+ include Thor::Actions
8
+
9
+ argument :name
10
+ class_option :rspec, type: :boolean
11
+
12
+ def self.source_root
13
+ File.join(File.dirname(__FILE__), "templates")
14
+ end
15
+
16
+ def apply_app_template
17
+ directory "app", tokenized_app_name, exclude_pattern: exclude_pattern
18
+ end
19
+
20
+ private
21
+
22
+ def exclude_pattern
23
+ patterns = [].tap { |patterns|
24
+ unless options[:rspec]
25
+ patterns << "spec\/spec_helper\.rb"
26
+ patterns << ".rspec"
27
+ end
28
+ }
29
+ patterns.empty? ? nil : /#{patterns.join("|")}/
30
+ end
31
+
32
+ def camelized_app_name
33
+ @camelized_app_name ||= Rory::Support.camelize(name)
34
+ end
35
+
36
+ def tokenized_app_name
37
+ @tokenized_app_name ||= Rory::Support.tokenize(name)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rory"
4
+ gem "thin"
5
+
6
+ group :development, :test do
7
+ gem "rake"
8
+ <% if options[:rspec] -%>
9
+ gem "rspec"
10
+ <% end -%>
11
+ gem "shotgun"
12
+ end
@@ -0,0 +1,11 @@
1
+ ENV["RORY_ENV"] ||= ENV["RACK_ENV"] || "development"
2
+
3
+ require "bundler/setup"
4
+ require "rory/tasks"
5
+
6
+ Rake::TaskManager.record_task_metadata = true
7
+
8
+ task :environment do
9
+ require_relative "config/application"
10
+ RORY_APP = <%= camelized_app_name %>::Application
11
+ end
@@ -0,0 +1,5 @@
1
+ ENV['RORY_ENV'] ||= ENV['RACK_ENV'] || 'development'
2
+
3
+ require_relative "config/application"
4
+
5
+ run <%= camelized_app_name %>::Application
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+
3
+ Bundler.require
4
+
5
+ module <%= camelized_app_name %>
6
+ class Application < Rory::Application
7
+ end
8
+ end
9
+
10
+ <%= camelized_app_name %>::Application.root = File.expand_path(File.join("..", ".."), __FILE__)
11
+ <%= camelized_app_name %>::Application.require_all_files
@@ -0,0 +1,3 @@
1
+ <%= camelized_app_name %>::Application.set_routes do
2
+ # match "path/with/:params", to: "controller#action", methods: [:get]
3
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < Rory::Controller
2
+ end
@@ -0,0 +1,6 @@
1
+ ENV['RORY_ENV'] = 'test'
2
+ require 'rspec'
3
+ require 'rory'
4
+
5
+ RSpec.configure do |config|
6
+ end
@@ -0,0 +1,17 @@
1
+ require "thor"
2
+ require_relative "generate"
3
+
4
+ module Rory
5
+ module CLI
6
+ class Root < Thor
7
+ desc "version", "Display version of installed Rory"
8
+ map %w[-v --version] => :version
9
+ def version
10
+ say "rory #{Rory::VERSION}"
11
+ end
12
+
13
+ register Generators::Application, "new", "new [APP_NAME]", "Create a new Rory application"
14
+ register Generate, "generate", "generate [COMMAND]", "Delegate to generate command"
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Rory
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
@@ -27,12 +27,14 @@ EOF
27
27
  %w(LICENSE.txt Rakefile README.md rory.gemspec)
28
28
  s.licenses = ["MIT"]
29
29
  s.require_paths = ["lib"]
30
+ s.bindir = "bin"
30
31
 
31
32
  s.add_runtime_dependency 'rack', '~> 1.0'
32
33
  s.add_runtime_dependency 'rack-contrib', '~> 1.2'
33
34
  s.add_runtime_dependency 'sequel', '~> 4.0'
34
35
  s.add_runtime_dependency 'thin', '~> 1.0'
35
36
  s.add_runtime_dependency 'thread-inheritable_attributes', '~> 0.1'
37
+ s.add_runtime_dependency 'thor', '~> 0.19'
36
38
 
37
39
  s.add_development_dependency 'rake', '~> 10.4'
38
40
  s.add_development_dependency 'rspec', '~> 3'
@@ -238,13 +238,13 @@ RSpec.describe Rory::Application do
238
238
  subject.instance.instance_variable_set(:@auto_require_paths, nil)
239
239
  end
240
240
 
241
- it 'includes models, controllers, and helpers by default' do
242
- expect(subject.auto_require_paths).to eq(['models', 'controllers', 'helpers'])
241
+ it 'includes initializers, models, controllers, and helpers by default' do
242
+ expect(subject.auto_require_paths).to eq(['config/initializers', 'models', 'controllers', 'helpers'])
243
243
  end
244
244
 
245
245
  it 'accepts new paths' do
246
246
  subject.auto_require_paths << 'chocolates'
247
- expect(subject.auto_require_paths).to eq(['models', 'controllers', 'helpers', 'chocolates'])
247
+ expect(subject.auto_require_paths).to eq(['config/initializers', 'models', 'controllers', 'helpers', 'chocolates'])
248
248
  end
249
249
  end
250
250
 
@@ -0,0 +1,16 @@
1
+ require "rory/cli"
2
+
3
+ RSpec.describe Rory::CLI::Generate do
4
+ describe "#app" do
5
+ it "starts Generators::Application" do
6
+ proxy = instance_double(Rory::CLI::Generators::Application)
7
+ allow(proxy).to receive(:parent_options=).with({})
8
+ allow(Rory::CLI::Generators::Application).to receive(:new).
9
+ with(["frog"], any_args).
10
+ and_return(proxy)
11
+
12
+ expect(proxy).to receive(:invoke_all)
13
+ subject.app("frog")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ require "rory/cli"
2
+
3
+ describe Rory::CLI::Generators::Application do
4
+ let(:options) { {} }
5
+ let(:args) { ["an app"] }
6
+ subject { described_class.new(args, options, :destination_root => sandbox_directory) }
7
+
8
+ after(:each) do
9
+ FileUtils.rm_rf sandbox_directory
10
+ end
11
+
12
+ context "with default options" do
13
+ it "generates a new application directory with no optional files" do
14
+ capture_output { subject.invoke_all }
15
+ expect(sandbox_directory.join("an_app")).to be_a_directory
16
+ expect(sandbox_directory.join("an_app", "config.ru")).to be_a_file
17
+ expect(sandbox_directory.join("an_app", ".rspec")).not_to be_a_file
18
+ end
19
+
20
+ it "logs the output" do
21
+ result = capture_output { subject.invoke_all }
22
+ expect(result).to include("create an_app")
23
+ end
24
+ end
25
+
26
+ context "with default options" do
27
+ let(:options) { { rspec: true } }
28
+
29
+ it "adds rspec files" do
30
+ capture_output { subject.invoke_all }
31
+ expect(sandbox_directory.join("an_app", ".rspec")).to be_a_file
32
+ expect(sandbox_directory.join("an_app", "spec", "spec_helper.rb")).to be_a_file
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,30 @@
1
+ require "rory/cli"
2
+
3
+ RSpec.describe Rory::CLI::Root do
4
+ describe "#version" do
5
+ it "says the current Rory VERSION constant" do
6
+ expect(subject).to receive(:say).with("rory #{Rory::VERSION}")
7
+ subject.version
8
+ end
9
+ end
10
+
11
+ describe "#generate" do
12
+ it "delegates to generate" do
13
+ expect(Rory::CLI::Root.subcommand_classes["generate"]).
14
+ to eq(Rory::CLI::Generate)
15
+ end
16
+ end
17
+
18
+ describe "#new" do
19
+ it "starts Generators::Application" do
20
+ proxy = instance_double(Rory::CLI::Generators::Application)
21
+ allow(proxy).to receive(:parent_options=).with({})
22
+ allow(Rory::CLI::Generators::Application).to receive(:new).
23
+ with(["frog"], any_args).
24
+ and_return(proxy)
25
+
26
+ expect(proxy).to receive(:invoke_all)
27
+ subject.new("frog")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,10 @@
1
+ require "rory/cli"
2
+
3
+ RSpec.describe Rory::CLI do
4
+ describe "#start" do
5
+ it "delegates to Root class" do
6
+ allow(Rory::CLI::Root).to receive(:start).and_return(:started)
7
+ expect(described_class.start).to eq :started
8
+ end
9
+ end
10
+ end
@@ -21,4 +21,5 @@ Capybara.app = Fixture::Application
21
21
 
22
22
  RSpec.configure do |config|
23
23
  config.order = "random"
24
+ config.include GenerationHelpers
24
25
  end
@@ -0,0 +1,19 @@
1
+ module GenerationHelpers
2
+ def sandbox_directory
3
+ Pathname.new(
4
+ File.join(File.dirname(__FILE__), "..", "sandbox")
5
+ )
6
+ end
7
+
8
+ def capture_output
9
+ begin
10
+ $stdout = StringIO.new
11
+ yield
12
+ result = $stdout.string
13
+ ensure
14
+ $stdout = STDOUT
15
+ end
16
+
17
+ result
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Gadad
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-03-01 00:00:00.000000000 Z
14
+ date: 2016-09-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -83,6 +83,20 @@ dependencies:
83
83
  - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0.1'
86
+ - !ruby/object:Gem::Dependency
87
+ name: thor
88
+ requirement: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '0.19'
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.19'
86
100
  - !ruby/object:Gem::Dependency
87
101
  name: rake
88
102
  requirement: !ruby/object:Gem::Requirement
@@ -228,6 +242,17 @@ files:
228
242
  - Rakefile
229
243
  - lib/rory.rb
230
244
  - lib/rory/application.rb
245
+ - lib/rory/cli.rb
246
+ - lib/rory/cli/generate.rb
247
+ - lib/rory/cli/generators/application.rb
248
+ - lib/rory/cli/generators/templates/app/Gemfile.tt
249
+ - lib/rory/cli/generators/templates/app/Rakefile.tt
250
+ - lib/rory/cli/generators/templates/app/config.ru.tt
251
+ - lib/rory/cli/generators/templates/app/config/application.rb.tt
252
+ - lib/rory/cli/generators/templates/app/config/routes.rb.tt
253
+ - lib/rory/cli/generators/templates/app/controllers/application_controller.rb
254
+ - lib/rory/cli/generators/templates/app/spec/spec_helper.rb
255
+ - lib/rory/cli/root.rb
231
256
  - lib/rory/controller.rb
232
257
  - lib/rory/dispatcher.rb
233
258
  - lib/rory/initializers.rb
@@ -269,6 +294,10 @@ files:
269
294
  - spec/fixture_app/views/test/nested.html.erb
270
295
  - spec/fixture_app/views/test/static.html.erb
271
296
  - spec/lib/rory/application_spec.rb
297
+ - spec/lib/rory/cli/generate_spec.rb
298
+ - spec/lib/rory/cli/generators/application_spec.rb
299
+ - spec/lib/rory/cli/root_spec.rb
300
+ - spec/lib/rory/cli_spec.rb
272
301
  - spec/lib/rory/controller_spec.rb
273
302
  - spec/lib/rory/dispatcher_spec.rb
274
303
  - spec/lib/rory/initializers_spec.rb
@@ -285,6 +314,7 @@ files:
285
314
  - spec/lib/rory_spec.rb
286
315
  - spec/requests/controller_spec.rb
287
316
  - spec/spec_helper.rb
317
+ - spec/support/generation_helpers.rb
288
318
  - spec/support/shared_examples/path_generation.rb
289
319
  homepage: http://github.com/screamingmuse/rory
290
320
  licenses:
@@ -306,9 +336,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
336
  version: 1.3.6
307
337
  requirements: []
308
338
  rubyforge_project:
309
- rubygems_version: 2.2.5
339
+ rubygems_version: 2.5.1
310
340
  signing_key:
311
341
  specification_version: 4
312
342
  summary: Another Ruby web framework. Just what the world needs.
313
343
  test_files: []
314
- has_rdoc: