scala-bootstrapper 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kyle Maxwell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,8 @@
1
+ This creates a standard environment for your twitter-centric sbt/scala thrift service.
2
+
3
+ Usage:
4
+
5
+ :$ mkdir foo
6
+ :$ cd foo
7
+ :$ scala-bootstrapper foo
8
+ :$ sbt update test
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "scala-bootstrapper"
8
+ gem.summary = %Q{Twitter scala project init}
9
+ gem.description = %Q{Twitter scala project init}
10
+ gem.email = "kmaxwell@twitter.com"
11
+ gem.homepage = "http://github.com/fizx/scala-bootstrapper"
12
+ gem.authors = ["Kyle Maxwell"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "scala-bootstrapper #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/bin/sbt ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ exec "java","-Xmx2g", "-XX:+CMSClassUnloadingEnabled", "-XX:MaxPermSize=256m", "-jar", File.dirname(__FILE__) + "/../vendor/sbt-launch-0.7.4.jar", *ARGV
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if ARGV.length < 1
4
+ puts "Usage: #{$0} [public] PROJECT_NAME"
5
+ exit 1
6
+ end
7
+
8
+ class String
9
+ def camelize(first_letter_in_uppercase = false)
10
+ if first_letter_in_uppercase
11
+ gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
12
+ else
13
+ self[0].chr.downcase + camelize(self)[1..-1]
14
+ end
15
+ end
16
+ end
17
+
18
+ def gsub_birds(haystack, name)
19
+ haystack.gsub("BirdName", name).gsub("birdname", name.downcase)
20
+ end
21
+
22
+ require "erb"
23
+ require "fileutils"
24
+ include FileUtils
25
+
26
+ project_name = ARGV.pop.camelize(true)
27
+ is_public = ARGV.pop == "public"
28
+
29
+ root = File.expand_path(File.dirname(__FILE__) + "/../lib/template")
30
+
31
+ Dir["#{root}/**/*"].select{|path| File.file?(path)}.each do |path|
32
+ relative = path.sub("#{root}/", "")
33
+ content = File.read(path)
34
+ template = ERB.new(content, nil, nil, "@output")
35
+ target_path = gsub_birds(relative, project_name).sub(/\.erb$/, '')
36
+ if File.exists?(target_path) && !$overwrite_all
37
+ print "File exists `#{relative}`, replace? ([Y]es, [N]o, [A]ll, [Q]uit)"
38
+ $stdout.flush
39
+ case STDIN.gets
40
+ when /^y/i: # continue
41
+ when /^n/i: next
42
+ when /^a/i: $overwrite_all = true
43
+ when /^q/i: exit(2)
44
+ else
45
+ retry
46
+ end
47
+ end
48
+ puts "writing #{target_path}"
49
+ mkdir_p(File.dirname(target_path))
50
+ File.open(target_path, "w") {|f| f.print(gsub_birds(template.result(binding), project_name)) }
51
+ end
@@ -0,0 +1,10 @@
1
+ *.class
2
+ *.log
3
+
4
+ # sbt specific
5
+ dist/*
6
+ target/
7
+ lib_managed/
8
+ src_managed/
9
+ project/boot/
10
+ project/plugins/project/
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.dirname(__FILE__) + "/../target/gen-rb"
3
+ require "rubygems"
4
+ require "thrift"
5
+ require "thrift_client"
6
+ require "bird_name_service"
7
+ require "irb"
8
+
9
+ class BirdNameClient < ThriftClient
10
+ DEFAULTS = { :transport_wrapper => Thrift::FramedTransport }
11
+ def initialize(servers = nil, options = {})
12
+ if servers.nil? or servers.empty?
13
+ STDERR.puts "No servers specified, using 127.0.0.1:13007"
14
+ servers = ['127.0.0.1:13007']
15
+ else
16
+ servers = Array(servers)
17
+ end
18
+
19
+ super(BirdName::BirdNameService::Client, servers, DEFAULTS.merge(options))
20
+ end
21
+ end
22
+
23
+ puts "Hint: the client is in the variable `$client`"
24
+ $client = BirdNameClient.new ARGV.shift
25
+
26
+ IRB.start
@@ -0,0 +1,7 @@
1
+ import com.twitter.birdname._
2
+
3
+ new BirdNameServiceConfig {
4
+ // TODO: Please implement environment-specific config, e.g.:
5
+ //
6
+ // override val thriftPort = 31337
7
+ }
@@ -0,0 +1,7 @@
1
+ import com.twitter.birdname._
2
+
3
+ new BirdNameServiceConfig {
4
+ // TODO: Please implement environment-specific config, e.g.:
5
+ //
6
+ // override val thriftPort = 31337
7
+ }
@@ -0,0 +1,7 @@
1
+ import com.twitter.birdname._
2
+
3
+ new BirdNameServiceConfig {
4
+ // TODO: Please implement environment-specific config, e.g.:
5
+ //
6
+ // override val thriftPort = 31337
7
+ }
@@ -0,0 +1,7 @@
1
+ import com.twitter.birdname._
2
+
3
+ new BirdNameServiceConfig {
4
+ // TODO: Please implement environment-specific config, e.g.:
5
+ //
6
+ // override val thriftPort = 31337
7
+ }
@@ -0,0 +1,38 @@
1
+ import sbt._
2
+ import Process._
3
+ import com.twitter.sbt._
4
+
5
+ class BirdNameProject(info: ProjectInfo) extends StandardProject(info)
6
+ with CompileScalaWrappers
7
+ with SubversionPublisher
8
+ with NoisyDependencies
9
+ with DefaultRepos
10
+ with LibDirClasspath
11
+ with PackageDist
12
+ with AdhocInlines {
13
+
14
+ val scalaTools = "org.scala-lang" % "scala-compiler" % "2.8.1"
15
+
16
+ val util = "com.twitter" % "util" % "1.6.10"
17
+
18
+ val finagleC = "com.twitter" % "finagle-core" % "1.1.23"
19
+ val finagleT = "com.twitter" % "finagle-thrift" % "1.1.23"
20
+ val finagleO = "com.twitter" % "finagle-ostrich3" % "1.1.23"
21
+
22
+ val ostrich = "com.twitter" % "ostrich" % "3.0.5"
23
+
24
+ val slf4jVersion = "1.5.11"
25
+ val slf4jApi = "org.slf4j" % "slf4j-api" % slf4jVersion withSources() intransitive()
26
+ val slf4jBindings = "org.slf4j" % "slf4j-jdk14" % slf4jVersion withSources() intransitive()
27
+
28
+ val specs = "org.scala-tools.testing" % "specs_2.8.1" % "1.6.7" % "test" withSources()
29
+ val jmock = "org.jmock" % "jmock" % "2.4.0" % "test"
30
+
31
+ val scalaThriftTargetNamespace = "com.twitter.birdname"
32
+ val rubyThriftNamespace = "BirdName"
33
+
34
+ override def mainClass = Some("com.twitter.birdname.Main")
35
+
36
+
37
+ override def subversionRepository = Some("http://svn.local.twitter.com/maven<%= '-public' if is_public %>")
38
+ }
@@ -0,0 +1,8 @@
1
+ #Project properties
2
+ #Thu Feb 24 16:45:35 PST 2011
3
+ project.organization=com.twitter
4
+ project.name=BirdName
5
+ sbt.version=0.7.4
6
+ project.version=0.1
7
+ build.scala.versions=2.8.1
8
+ project.initialize=false
@@ -0,0 +1,6 @@
1
+ import sbt._
2
+
3
+ class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
4
+ val twitterMaven = "twitter.com" at "http://maven.twttr.com/"
5
+ val defaultProject = "com.twitter" % "standard-project" % "0.10.2-scala"
6
+ }
@@ -0,0 +1,24 @@
1
+ package com.twitter.birdname
2
+
3
+ import com.twitter.admin.config._
4
+ import com.twitter.admin._
5
+
6
+ class BirdNameServiceConfig extends ServerConfig[BirdNameService] {
7
+
8
+ val thriftPort = 1337
9
+ admin.httpPort = Some(9999)
10
+
11
+ // TODO: Please implement application-specific config.
12
+
13
+ /**
14
+ * Used if you need to integrate synchronous clients, e.g. querulous. If you
15
+ * are using an async client like cassie, you can ignore this.
16
+ *
17
+ * val threadPoolSize = 10
18
+ */
19
+
20
+ /**
21
+ * This is a factory method that will construct the related service.
22
+ */
23
+ def apply(env: RuntimeEnvironment) = new BirdNameServiceImpl(this)
24
+ }
@@ -0,0 +1,31 @@
1
+ package com.twitter.birdname
2
+
3
+ import com.twitter.util._
4
+ import java.util.concurrent._
5
+
6
+ class BirdNameServiceImpl(config: BirdNameServiceConfig) extends BirdNameService {
7
+ val serverName = "BirdName"
8
+ val thriftPort = config.thriftPort
9
+
10
+ /**
11
+ * These services are based on finagle, which implements a nonblocking server. If you
12
+ * are making blocking rpc calls, it's really important that you run these actions in
13
+ * a thread pool, so that you don't block the main event loop. This thread pool is only
14
+ * needed for these blocking actions. The code looks like:
15
+ *
16
+ * // Depends on com.twitter.util >= 1.6.10
17
+ * val futurePool = new FuturePool(Executors.newFixedThreadPool(config.threadPoolSize))
18
+ *
19
+ * def hello() = futurePool {
20
+ * someService.blockingRpcCall
21
+ * }
22
+ *
23
+ */
24
+
25
+ // TODO: Please implement your api. You should have already created your thrift definition.
26
+
27
+ def hello() = {
28
+ Future("world")
29
+ }
30
+
31
+ }
@@ -0,0 +1,12 @@
1
+ package com.twitter.birdname
2
+
3
+ import com.twitter.admin._
4
+
5
+ object Main {
6
+ def main(args: Array[String]) {
7
+ val env = RuntimeEnvironment(this, args)
8
+ val impl = env.loadRuntimeConfig[BirdNameService]
9
+ impl.start
10
+ }
11
+ }
12
+
@@ -0,0 +1,12 @@
1
+ namespace java com.twitter.birdname.thrift
2
+ namespace rb BirdName
3
+
4
+ exception BirdNameException {
5
+ 1: string description
6
+ }
7
+
8
+ service BirdNameService {
9
+ // TODO: Please implement your externally accessible API
10
+
11
+ string hello() throws(1: BirdNameException ex)
12
+ }
@@ -0,0 +1,24 @@
1
+ package com.twitter.birdname
2
+
3
+ import org.specs.Specification
4
+ import com.twitter.admin._
5
+
6
+ class BirdNameServiceSpec extends Specification {
7
+ // If you do multiple integration tests, you might want to factor this
8
+ // into a superclass.
9
+ val env = RuntimeEnvironment(this, Array("-f", "config/test.scala"))
10
+ val impl = env.loadRuntimeConfig[BirdNameService]
11
+
12
+ // You don't really want the thrift server active, particularly if you
13
+ // are running repetitively via ~test
14
+ ServiceTracker.shutdown // all services
15
+
16
+ "BirdNameService" should {
17
+
18
+ // TODO: Please implement your own tests
19
+
20
+ "hello world" in {
21
+ impl.hello.get() mustEqual "world"
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,65 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{scala-bootstrapper}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kyle Maxwell"]
12
+ s.date = %q{2011-02-25}
13
+ s.description = %q{Twitter scala project init}
14
+ s.email = %q{kmaxwell@twitter.com}
15
+ s.executables = ["sbt", "scala-bootstrapper"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".gitignore",
23
+ "LICENSE",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "bin/sbt",
28
+ "bin/scala-bootstrapper",
29
+ "lib/template/.gitignore",
30
+ "lib/template/bin/console.erb",
31
+ "lib/template/config/development.scala.erb",
32
+ "lib/template/config/production.scala.erb",
33
+ "lib/template/config/staging.scala.erb",
34
+ "lib/template/config/test.scala.erb",
35
+ "lib/template/project/build.properties",
36
+ "lib/template/project/build/BirdNameProject.scala.erb",
37
+ "lib/template/project/plugins/Plugins.scala.erb",
38
+ "lib/template/src/main/scala/com/twitter/birdname/BirdNameServiceConfig.scala.erb",
39
+ "lib/template/src/main/scala/com/twitter/birdname/BirdNameServiceImpl.scala.erb",
40
+ "lib/template/src/main/scala/com/twitter/birdname/Main.scala.erb",
41
+ "lib/template/src/main/thrift/birdname.thrift.erb",
42
+ "lib/template/src/test/scala/com/twitter/birdname/BirdNameServiceSpec.scala",
43
+ "scala-bootstrapper.gemspec",
44
+ "vendor/sbt-launch-0.7.4.jar"
45
+ ]
46
+ s.homepage = %q{http://github.com/fizx/scala-bootstrapper}
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.6}
50
+ s.summary = %q{Twitter scala project init}
51
+
52
+ if s.respond_to? :specification_version then
53
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
+ s.specification_version = 3
55
+
56
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
58
+ else
59
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
60
+ end
61
+ else
62
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
63
+ end
64
+ end
65
+
Binary file
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scala-bootstrapper
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 1
9
+ version: 0.1.1
10
+ platform: ruby
11
+ authors:
12
+ - Kyle Maxwell
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-25 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: thoughtbot-shoulda
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ description: Twitter scala project init
33
+ email: kmaxwell@twitter.com
34
+ executables:
35
+ - sbt
36
+ - scala-bootstrapper
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - LICENSE
41
+ - README.rdoc
42
+ files:
43
+ - .document
44
+ - .gitignore
45
+ - LICENSE
46
+ - README.rdoc
47
+ - Rakefile
48
+ - VERSION
49
+ - bin/sbt
50
+ - bin/scala-bootstrapper
51
+ - lib/template/.gitignore
52
+ - lib/template/bin/console.erb
53
+ - lib/template/config/development.scala.erb
54
+ - lib/template/config/production.scala.erb
55
+ - lib/template/config/staging.scala.erb
56
+ - lib/template/config/test.scala.erb
57
+ - lib/template/project/build.properties
58
+ - lib/template/project/build/BirdNameProject.scala.erb
59
+ - lib/template/project/plugins/Plugins.scala.erb
60
+ - lib/template/src/main/scala/com/twitter/birdname/BirdNameServiceConfig.scala.erb
61
+ - lib/template/src/main/scala/com/twitter/birdname/BirdNameServiceImpl.scala.erb
62
+ - lib/template/src/main/scala/com/twitter/birdname/Main.scala.erb
63
+ - lib/template/src/main/thrift/birdname.thrift.erb
64
+ - lib/template/src/test/scala/com/twitter/birdname/BirdNameServiceSpec.scala
65
+ - scala-bootstrapper.gemspec
66
+ - vendor/sbt-launch-0.7.4.jar
67
+ has_rdoc: true
68
+ homepage: http://github.com/fizx/scala-bootstrapper
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ requirements: []
91
+
92
+ rubyforge_project:
93
+ rubygems_version: 1.3.6
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: Twitter scala project init
97
+ test_files: []
98
+