finatra 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/{fin → finatra} +0 -0
- data/finatra.gemspec +6 -5
- data/lib/finatra.rb +26 -3
- data/lib/templates/App.scala.tt +34 -7
- data/lib/templates/Spec.scala.tt +39 -0
- data/lib/templates/project/README.markdown +8 -6
- data/lib/templates/project/pom.xml.tt +29 -23
- data/lib/templates/timeline.mustache.tt +5 -0
- metadata +17 -16
- data/lib/templates/project/templates/example.mustache +0 -1
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.11
|
data/bin/{fin → finatra}
RENAMED
File without changes
|
data/finatra.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "finatra"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["twoism"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-07-13"
|
13
13
|
s.description = "Project Generator for Finatra"
|
14
14
|
s.email = "signalstatic@gmail.com"
|
15
|
-
s.executables = ["
|
15
|
+
s.executables = ["finatra"]
|
16
16
|
s.extra_rdoc_files = [
|
17
17
|
"LICENSE.txt",
|
18
18
|
"README.md"
|
@@ -27,15 +27,16 @@ Gem::Specification.new do |s|
|
|
27
27
|
"README.md",
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
|
-
"bin/
|
30
|
+
"bin/finatra",
|
31
31
|
"finatra.gemspec",
|
32
32
|
"lib/finatra.rb",
|
33
33
|
"lib/templates/App.scala.tt",
|
34
|
+
"lib/templates/Spec.scala.tt",
|
34
35
|
"lib/templates/project/Procfile.tt",
|
35
36
|
"lib/templates/project/README.markdown",
|
36
37
|
"lib/templates/project/pom.xml.tt",
|
37
38
|
"lib/templates/project/public/dealwithit.gif",
|
38
|
-
"lib/templates/
|
39
|
+
"lib/templates/timeline.mustache.tt",
|
39
40
|
"spec/finatra-gem_spec.rb",
|
40
41
|
"spec/spec_helper.rb"
|
41
42
|
]
|
data/lib/finatra.rb
CHANGED
@@ -5,19 +5,21 @@ class Finatra < Thor
|
|
5
5
|
include Thor::Actions
|
6
6
|
|
7
7
|
def self.source_root
|
8
|
-
File.expand_path(File.dirname(__FILE__))
|
8
|
+
File.expand_path(File.dirname(__FILE__))
|
9
9
|
end
|
10
10
|
|
11
11
|
desc "new <MyAppName>", "Create a new Finatra app"
|
12
12
|
def new(name)
|
13
|
-
@app_name = name.to_s.gsub(/[^a-zA-Z0-9]/,'')
|
14
|
-
@dir_name = name.downcase.to_s.gsub(/[^a-zA-Z0-9]/,'')
|
13
|
+
@app_name = name.to_s.gsub(/[^a-zA-Z0-9]/,'')
|
14
|
+
@dir_name = name.downcase.to_s.gsub(/[^a-zA-Z0-9]/,'')
|
15
15
|
@org_name = ask 'Org Name (com.<username>)' while @org_name.to_s.empty?
|
16
16
|
|
17
17
|
log "Creating #{@app_name} in #{Dir.pwd}..."
|
18
18
|
|
19
19
|
copy_project_files
|
20
20
|
create_controller
|
21
|
+
create_controller_test
|
22
|
+
create_template
|
21
23
|
end
|
22
24
|
|
23
25
|
desc "console", "Starts a scala console"
|
@@ -35,6 +37,11 @@ class Finatra < Thor
|
|
35
37
|
exec "mvn scala:run"
|
36
38
|
end
|
37
39
|
|
40
|
+
desc "test", "Run the tests"
|
41
|
+
def test
|
42
|
+
exec "mvn test"
|
43
|
+
end
|
44
|
+
|
38
45
|
desc "package", "Package a jar for your app"
|
39
46
|
def package
|
40
47
|
exec "mvn package"
|
@@ -50,10 +57,26 @@ class Finatra < Thor
|
|
50
57
|
template "templates/App.scala.tt", "#{src_dir}/#{@app_name}.scala"
|
51
58
|
end
|
52
59
|
|
60
|
+
def create_controller_test
|
61
|
+
template "templates/Spec.scala.tt", "#{test_dir}/#{@app_name}Spec.scala"
|
62
|
+
end
|
63
|
+
|
64
|
+
def create_template
|
65
|
+
template "templates/timeline.mustache.tt", "#{resource_dir}/timeline.mustache"
|
66
|
+
end
|
67
|
+
|
53
68
|
def src_dir
|
54
69
|
"#{@dir_name}/src/main/scala/#{@org_name.gsub('.','/')}/#{@dir_name}"
|
55
70
|
end
|
56
71
|
|
72
|
+
def resource_dir
|
73
|
+
"#{@dir_name}/src/main/resources"
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_dir
|
77
|
+
"#{@dir_name}/src/test/scala/#{@org_name.gsub('.','/')}/#{@dir_name}"
|
78
|
+
end
|
79
|
+
|
57
80
|
def log(msg)
|
58
81
|
puts "[finatra] :: #{msg}"
|
59
82
|
end
|
data/lib/templates/App.scala.tt
CHANGED
@@ -1,24 +1,51 @@
|
|
1
1
|
package <%= @org_name %>.<%= @dir_name %>
|
2
2
|
|
3
|
-
import com.
|
4
|
-
|
3
|
+
import com.twitter.finatra.{Controller, FinatraServer, View}
|
4
|
+
|
5
|
+
|
6
|
+
case class Tweet(status:String)
|
7
|
+
|
8
|
+
class TimelineView(val tweets:List[Tweet]) extends View {
|
9
|
+
val template = "timeline.mustache"
|
10
|
+
}
|
5
11
|
|
6
12
|
object App {
|
7
13
|
|
8
|
-
class
|
14
|
+
class <%= @app_name %> extends Controller {
|
15
|
+
|
16
|
+
def tweets = List(new Tweet("hey!"), new Tweet("lol"))
|
17
|
+
|
18
|
+
get("/tweets.json") { request =>
|
19
|
+
render.json(tweets)
|
20
|
+
}
|
21
|
+
|
22
|
+
get("/tweets") { request =>
|
23
|
+
val tweetsView = new TimelineView(tweets)
|
24
|
+
|
25
|
+
render.view(tweetsView)
|
26
|
+
}
|
27
|
+
|
28
|
+
get("/status/:status") { request =>
|
29
|
+
val statusCode = request.params("status").toInt
|
30
|
+
|
31
|
+
render.nothing.status(statusCode)
|
32
|
+
}
|
33
|
+
|
34
|
+
get("/not_found") { request =>
|
35
|
+
render.nothing.notFound
|
36
|
+
}
|
9
37
|
|
10
|
-
get("/") { request =>
|
11
|
-
|
38
|
+
get("/headers") { request =>
|
39
|
+
render.nothing.header("X-GitSHA", "1ecd6b1")
|
12
40
|
}
|
13
41
|
|
14
42
|
}
|
15
43
|
|
16
44
|
def main(args: Array[String]) {
|
17
|
-
val port = util.Properties.envOrElse("PORT", "7070").toInt
|
18
45
|
val app = new <%= @app_name %>
|
19
46
|
|
20
47
|
FinatraServer.register(app)
|
21
|
-
FinatraServer.start(
|
48
|
+
FinatraServer.start()
|
22
49
|
}
|
23
50
|
|
24
51
|
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
package <%= @org_name %>.<%= @dir_name %>.test
|
2
|
+
|
3
|
+
import com.twitter.finatra.test.SpecHelper
|
4
|
+
import <%= @org_name %>.<%= @dir_name %>.App
|
5
|
+
|
6
|
+
import org.junit.runner.RunWith
|
7
|
+
import org.scalatest.junit.JUnitRunner
|
8
|
+
|
9
|
+
@RunWith(classOf[JUnitRunner])
|
10
|
+
class AppSpec extends SpecHelper {
|
11
|
+
|
12
|
+
def app = { new App.<%= @app_name %> }
|
13
|
+
|
14
|
+
"GET /tweets.json" should "respond 200" in {
|
15
|
+
get("/tweets.json")
|
16
|
+
response.code should equal (200)
|
17
|
+
}
|
18
|
+
|
19
|
+
"GET /tweets" should "respond 200" in {
|
20
|
+
get("/tweets")
|
21
|
+
response.code should equal (200)
|
22
|
+
response.body should include ("lol")
|
23
|
+
}
|
24
|
+
|
25
|
+
"GET /status/401" should "respond 401" in {
|
26
|
+
get("/status/401")
|
27
|
+
response.code should equal (401)
|
28
|
+
}
|
29
|
+
|
30
|
+
"GET /not_found" should "respond 404" in {
|
31
|
+
get("/not_found")
|
32
|
+
response.code should equal (404)
|
33
|
+
}
|
34
|
+
|
35
|
+
"GET /headers" should "respond with headers" in {
|
36
|
+
get("/headers")
|
37
|
+
response.getHeader("X-GitSHA") should equal ("1ecd6b1")
|
38
|
+
}
|
39
|
+
}
|
@@ -1,13 +1,15 @@
|
|
1
|
-
#
|
1
|
+
#Finatra#
|
2
2
|
|
3
|
-
|
3
|
+
## Running the Server
|
4
4
|
|
5
|
-
|
5
|
+
```finatra start```
|
6
6
|
|
7
|
-
|
7
|
+
## Start a console
|
8
8
|
|
9
|
-
|
9
|
+
```finatra console```
|
10
10
|
|
11
|
-
|
11
|
+
## Running tests
|
12
|
+
|
13
|
+
```finatra test```
|
12
14
|
|
13
15
|
It'll be running on http://localhost:7070
|
@@ -14,11 +14,11 @@
|
|
14
14
|
</license>
|
15
15
|
</licenses>
|
16
16
|
|
17
|
-
|
17
|
+
<properties>
|
18
18
|
<maven.compiler.source>1.5</maven.compiler.source>
|
19
19
|
<maven.compiler.target>1.5</maven.compiler.target>
|
20
20
|
<encoding>UTF-8</encoding>
|
21
|
-
<scala.version>2.9.
|
21
|
+
<scala.version>2.9.2</scala.version>
|
22
22
|
</properties>
|
23
23
|
|
24
24
|
<repositories>
|
@@ -41,11 +41,27 @@
|
|
41
41
|
</pluginRepository>
|
42
42
|
</pluginRepositories>
|
43
43
|
<dependencies>
|
44
|
+
|
44
45
|
<dependency>
|
45
|
-
<groupId>com.
|
46
|
+
<groupId>com.twitter</groupId>
|
46
47
|
<artifactId>finatra</artifactId>
|
47
|
-
<version>
|
48
|
+
<version>0.1.7</version>
|
48
49
|
</dependency>
|
50
|
+
|
51
|
+
<dependency>
|
52
|
+
<groupId>junit</groupId>
|
53
|
+
<artifactId>junit</artifactId>
|
54
|
+
<version>4.8.1</version>
|
55
|
+
<scope>test</scope>
|
56
|
+
</dependency>
|
57
|
+
|
58
|
+
<dependency>
|
59
|
+
<groupId>org.scalatest</groupId>
|
60
|
+
<artifactId>scalatest_${scala.version}</artifactId>
|
61
|
+
<version>1.7.2</version>
|
62
|
+
<scope>test</scope>
|
63
|
+
</dependency>
|
64
|
+
|
49
65
|
</dependencies>
|
50
66
|
|
51
67
|
<build>
|
@@ -65,6 +81,8 @@
|
|
65
81
|
<!-- you could define other launcher -->
|
66
82
|
</launchers>
|
67
83
|
</configuration>
|
84
|
+
|
85
|
+
|
68
86
|
<executions>
|
69
87
|
<execution>
|
70
88
|
<goals>
|
@@ -81,31 +99,19 @@
|
|
81
99
|
</execution>
|
82
100
|
</executions>
|
83
101
|
</plugin>
|
84
|
-
<plugin>
|
85
|
-
<groupId>org.apache.maven.plugins</groupId>
|
86
|
-
<artifactId>maven-dependency-plugin</artifactId>
|
87
|
-
<version>2.4</version>
|
88
|
-
<executions>
|
89
|
-
<execution>
|
90
|
-
<id>copy-dependencies</id>
|
91
|
-
<phase>package</phase>
|
92
|
-
<goals><goal>copy-dependencies</goal></goals>
|
93
|
-
</execution>
|
94
|
-
</executions>
|
95
|
-
</plugin>
|
96
102
|
<plugin>
|
97
103
|
<groupId>org.apache.maven.plugins</groupId>
|
98
104
|
<artifactId>maven-surefire-plugin</artifactId>
|
99
|
-
<version>2.
|
105
|
+
<version>2.12</version>
|
100
106
|
<configuration>
|
101
|
-
<
|
102
|
-
<
|
103
|
-
<!-- If you have classpath issue like NoDefClassError,... -->
|
104
|
-
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
|
107
|
+
<useSystemClassLoader>false</useSystemClassLoader>
|
108
|
+
<argLine>-Xmx1024m</argLine>
|
105
109
|
<includes>
|
106
|
-
<include>**/*
|
107
|
-
<include>**/*Suite.*</include>
|
110
|
+
<include>**/*Spec.java</include>
|
108
111
|
</includes>
|
112
|
+
<excludes>
|
113
|
+
<exclude>**/*Test.java</exclude>
|
114
|
+
</excludes>
|
109
115
|
</configuration>
|
110
116
|
</plugin>
|
111
117
|
</plugins>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70231312211700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70231312211700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70231312211180 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.8.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70231312211180
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &70231312210700 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.12'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70231312210700
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70231312210200 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70231312210200
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &70231312209720 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,11 +65,11 @@ dependencies:
|
|
65
65
|
version: 1.8.3
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70231312209720
|
69
69
|
description: Project Generator for Finatra
|
70
70
|
email: signalstatic@gmail.com
|
71
71
|
executables:
|
72
|
-
-
|
72
|
+
- finatra
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files:
|
75
75
|
- LICENSE.txt
|
@@ -84,15 +84,16 @@ files:
|
|
84
84
|
- README.md
|
85
85
|
- Rakefile
|
86
86
|
- VERSION
|
87
|
-
- bin/
|
87
|
+
- bin/finatra
|
88
88
|
- finatra.gemspec
|
89
89
|
- lib/finatra.rb
|
90
90
|
- lib/templates/App.scala.tt
|
91
|
+
- lib/templates/Spec.scala.tt
|
91
92
|
- lib/templates/project/Procfile.tt
|
92
93
|
- lib/templates/project/README.markdown
|
93
94
|
- lib/templates/project/pom.xml.tt
|
94
95
|
- lib/templates/project/public/dealwithit.gif
|
95
|
-
- lib/templates/
|
96
|
+
- lib/templates/timeline.mustache.tt
|
96
97
|
- spec/finatra-gem_spec.rb
|
97
98
|
- spec/spec_helper.rb
|
98
99
|
homepage: http://github.com/twoism/finatra-gem
|
@@ -110,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
111
|
version: '0'
|
111
112
|
segments:
|
112
113
|
- 0
|
113
|
-
hash:
|
114
|
+
hash: 3840495853745466210
|
114
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
116
|
none: false
|
116
117
|
requirements:
|
@@ -1 +0,0 @@
|
|
1
|
-
sup {{foo}}
|