happy 0.1.0.pre.2 → 0.1.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -1 +1,2 @@
1
1
  --color
2
+ --format=documentation
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - jruby-18mode # JRuby in 1.9 mode
7
+ - rbx-18mode
8
+ - jruby-19mode # JRuby in 1.9 mode
9
+ - rbx-19mode
10
+ script: bundle exec rake
data/.watchr ADDED
@@ -0,0 +1,15 @@
1
+ def run(cmd, msg = nil)
2
+ puts "=== %s" % msg if msg
3
+ puts "=== %s" % cmd
4
+ system cmd
5
+ puts "\n"
6
+ end
7
+
8
+ watch("spec/.*_spec\.rb") { |m| run("bundle exec rspec %s" % m[0]) }
9
+ watch("lib/happy/(.*)\.rb") { |m| run("bundle exec rspec spec/%s_spec.rb" % m[1]) }
10
+ watch('^spec/(spec_helper|factories)\.rb') { |f| run "bundle exec rake spec", "%s.rb has been modified" % f }
11
+
12
+ # Ctrl-\
13
+ Signal.trap('QUIT') { run("bundle exec rake spec") }
14
+ # Ctrl-C
15
+ Signal.trap('INT') { abort("\nQuitting.") }
data/happy.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency 'rspec', '~> 2.8'
25
25
  gem.add_development_dependency 'rspec-html-matchers'
26
26
  gem.add_development_dependency 'rack-test'
27
+ gem.add_development_dependency 'watchr'
27
28
  end
data/lib/happy/context.rb CHANGED
@@ -22,8 +22,10 @@ module Happy
22
22
  old_controller = self.controller
23
23
  self.controller = new_controller
24
24
 
25
- # execute permissions block
26
- controller.class.permissions_blk.try(:call, permissions, self)
25
+ # execute permissions block SMELL - better integration
26
+ if controller.class.respond_to?(:permissions_blk)
27
+ controller.class.permissions_blk.try(:call, permissions, self)
28
+ end
27
29
 
28
30
  # execute block
29
31
  yield
@@ -50,6 +50,12 @@ module Happy
50
50
  def context_class
51
51
  Happy::Context
52
52
  end
53
+
54
+ def build(&blk)
55
+ Class.new(self).tap do |klass|
56
+ klass.instance_eval &blk
57
+ end
58
+ end
53
59
  end
54
60
  end
55
61
  end
data/lib/happy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Happy
2
- VERSION = "0.1.0.pre.2"
2
+ VERSION = "0.1.0.pre.3"
3
3
  end
@@ -2,6 +2,39 @@ require 'spec_helper'
2
2
 
3
3
  module Happy
4
4
  describe Controller do
5
- it "should have more specs"
5
+ describe ".build" do
6
+ subject do
7
+ Controller.build do
8
+ route { serve! "yay!" }
9
+ end
10
+ end
11
+
12
+ def app
13
+ subject
14
+ end
15
+
16
+ it "creates a new controller class" do
17
+ subject.ancestors.should include(Controller)
18
+ end
19
+
20
+ it "should use the passed block to initialize the new controller class" do
21
+ get "/"
22
+ last_response.body.should == 'yay!'
23
+ end
24
+ end
25
+
26
+ it "is also a Rack app" do
27
+ def app
28
+ Controller.build do
29
+ route do
30
+ serve! "it works"
31
+ end
32
+ end
33
+ end
34
+
35
+ get '/'
36
+ last_response.body.should == 'it works'
37
+ end
38
+
6
39
  end
7
40
  end
data/spec/spec_helper.rb CHANGED
@@ -7,3 +7,7 @@ require 'bundler/setup'
7
7
  require 'rack/test'
8
8
 
9
9
  require 'happy'
10
+
11
+ RSpec.configure do |conf|
12
+ conf.include Rack::Test::Methods
13
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.2
4
+ version: 0.1.0.pre.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70265405180720 !ruby/object:Gem::Requirement
16
+ requirement: &70362048389880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70265405180720
24
+ version_requirements: *70362048389880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack
27
- requirement: &70265405180020 !ruby/object:Gem::Requirement
27
+ requirement: &70362048389020 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '1.4'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70265405180020
35
+ version_requirements: *70362048389020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: happy-helpers
38
- requirement: &70265405178080 !ruby/object:Gem::Requirement
38
+ requirement: &70362048388280 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70265405178080
46
+ version_requirements: *70362048388280
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: allowance
49
- requirement: &70265405175720 !ruby/object:Gem::Requirement
49
+ requirement: &70362048386840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.1.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70265405175720
57
+ version_requirements: *70362048386840
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70265405174800 !ruby/object:Gem::Requirement
60
+ requirement: &70362048386200 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70265405174800
68
+ version_requirements: *70362048386200
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70265405173920 !ruby/object:Gem::Requirement
71
+ requirement: &70362048385440 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.8'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70265405173920
79
+ version_requirements: *70362048385440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec-html-matchers
82
- requirement: &70265405172780 !ruby/object:Gem::Requirement
82
+ requirement: &70362048384620 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70265405172780
90
+ version_requirements: *70362048384620
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rack-test
93
- requirement: &70265405170780 !ruby/object:Gem::Requirement
93
+ requirement: &70362048384120 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,18 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70265405170780
101
+ version_requirements: *70362048384120
102
+ - !ruby/object:Gem::Dependency
103
+ name: watchr
104
+ requirement: &70362048383520 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70362048383520
102
113
  description: A happy little toolkit for writing web applications.
103
114
  email:
104
115
  - hendrik@mans.de
@@ -108,6 +119,8 @@ extra_rdoc_files: []
108
119
  files:
109
120
  - .gitignore
110
121
  - .rspec
122
+ - .travis.yml
123
+ - .watchr
111
124
  - .yardopt
112
125
  - Gemfile
113
126
  - LICENSE