Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit a70749038b1cfe09f98e8fae2b919a7499e23452 Emmanuel Oga committed May 20, 2010
@@ -0,0 +1,21 @@
+## MAC OS
+.DS_Store
+
+## TEXTMATE
+*.tmproj
+tmtags
+
+## EMACS
+*~
+\#*
+.\#*
+
+## VIM
+*.swp
+
+## PROJECT::GENERAL
+coverage
+rdoc
+pkg
+
+## PROJECT::SPECIFIC
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Emmanuel Oga
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
+= firering
+
+Campfire API interface powered by EventMachine and Yajl.
+
+== Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a
+ future version unintentionally.
+* Commit, do not mess with rakefile, version, or history.
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+* Send me a pull request. Bonus points for topic branches.
+
+== Copyright
+
+Copyright (c) 2009 Emmanuel Oga. See LICENSE for details.
143 Rakefile
@@ -0,0 +1,143 @@
+require 'rubygems'
+require 'rake'
+require 'date'
+
+#############################################################################
+#
+# Helper functions
+#
+#############################################################################
+
+def name
+ @name ||= Dir['*.gemspec'].first.split('.').first
+end
+
+def version
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
+end
+
+def date
+ Date.today.to_s
+end
+
+def rubyforge_project
+ name
+end
+
+def gemspec_file
+ "#{name}.gemspec"
+end
+
+def gem_file
+ "#{name}-#{version}.gem"
+end
+
+def replace_header(head, header_name)
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
+end
+
+#############################################################################
+#
+# Standard tasks
+#
+#############################################################################
+
+require 'spec/rake/spectask'
+
+Spec::Rake::SpecTask.new(:spec) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.spec_files = FileList['spec/**/*_spec.rb']
+end
+
+Spec::Rake::SpecTask.new(:rcov) do |spec|
+ spec.libs << 'lib' << 'spec'
+ spec.pattern = 'spec/**/*_spec.rb'
+ spec.rcov = true
+end
+
+task :default => :spec
+
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -rubygems -r ./lib/#{name}.rb"
+end
+
+#############################################################################
+#
+# Custom tasks (add your own tasks here)
+#
+#############################################################################
+
+begin
+ require 'yard'
+ YARD::Rake::YardocTask.new
+rescue LoadError
+ task :yardoc do
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
+ end
+end
+
+#############################################################################
+#
+# Packaging tasks
+#
+#############################################################################
+
+task :release => :build do
+ unless `git branch` =~ /^\* master$/
+ puts "You must be on the master branch to release!"
+ exit!
+ end
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
+ sh "git tag v#{version}"
+ sh "git push origin master"
+ sh "git push v#{version}"
+ sh "gem push pkg/#{name}-#{version}.gem"
+end
+
+task :build => :gemspec do
+ sh "mkdir -p pkg"
+ sh "gem build #{gemspec_file}"
+ sh "mv #{gem_file} pkg"
+end
+
+task :gemspec => :validate do
+ # read spec file and split out manifest section
+ spec = File.read(gemspec_file)
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
+
+ # replace name version and date
+ replace_header(head, :name)
+ replace_header(head, :version)
+ replace_header(head, :date)
+ #comment this out if your rubyforge_project has a different name
+ replace_header(head, :rubyforge_project)
+
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").
+ sort.
+ reject { |file| file =~ /^\./ }.
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
+ map { |file| " #{file}" }.
+ join("\n")
+
+ # piece file back together and write
+ manifest = " s.files = %w[\n#{files}\n ]\n"
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
+ puts "Updated #{gemspec_file}"
+end
+
+task :validate do
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
+ unless libfiles.empty?
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
+ exit!
+ end
+ unless Dir['VERSION*'].empty?
+ puts "A `VERSION` file at root level violates Gem best practices."
+ exit!
+ end
+end
@@ -0,0 +1,42 @@
+$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+
+require 'firering'
+
+EM.run do
+ Firering.authenticate("subdomain", "user", "password") do |user|
+
+ Firering.rooms do |rooms|
+ rooms.each do |room|
+ if room.name =~ /test/
+ Firering.room_join(room.id) do
+ Firering.stream(room.id) do |message|
+
+ case
+ when message.advertisement? then puts "Handle Ad"
+ when message.allow_guests? then puts "Handle Allow Guests"
+ when message.disallow_guests? then puts "Handle Disallow Guests"
+ when message.idle? then puts "Handle Idle"
+ when message.kick? then puts "Handle Kick"
+ when message.leave? then puts "Handle Leave"
+ when message.paste? then puts "Handle Paste"
+ when message.sound? then puts "Handle Sound"
+ when message.system? then puts "Handle System"
+ when message.text? then puts "Handle Text"
+ when message.timestamp? then puts "Handle Timestamp"
+ when message.topic_change? then puts "Handle Topic Change"
+ when message.unidle? then puts "Handle Un Idle"
+ when message.unlock? then puts "Handle Unlock"
+ when message.upload? then puts "Handle Upload"
+ end
+
+ puts message.to_s
+ end
+ end
+ end
+ end
+ end
+
+ end
+
+ trap("INT") { EM.stop }
+end
@@ -0,0 +1,29 @@
+$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+
+require 'firering'
+
+EM.run do
+ Firering.authenticate("subdomain", "user", "password") do |user|
+ Firering.rooms do |rooms|
+
+ rooms.each do |room|
+ puts "Users in room #{room.name} (#{room.topic})"
+
+ if room.users.empty?
+ puts " empty"
+ else
+ room.users.each do |u|
+ puts " #{ u.name }. Admin: #{ user.admin? }"
+ end
+ end
+
+ Firering.room_recent_messages(room.id) do |messages|
+ puts messages
+ end
+
+ end
+ end
+ end
+
+ trap("INT") { EM.stop }
+end
@@ -0,0 +1,31 @@
+$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+
+require 'firering'
+
+$count = 0
+
+EM.run do
+ Firering.authenticate("subdomain", "user", "password") do |user|
+
+ Firering.rooms do |rooms|
+
+ $count = rooms.length
+
+ rooms.each do |room|
+ $count -= 1
+
+ puts "Users in room #{room.name}"
+
+ if room.users.empty?
+ puts " empty"
+ else
+ room.users.each do |u|
+ puts " #{ u.name }"
+ end
+ end
+
+ EM.stop if $count == 0
+ end
+ end
+ end
+end
@@ -0,0 +1,42 @@
+$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
+
+require 'firering'
+
+EM.run do
+ Firering.authenticate("subdomain", "user", "password") do |user|
+
+ Firering.rooms do |rooms|
+
+ rooms.each do |room|
+
+ puts "Users in room #{room.name} (#{room.topic})"
+
+ if room.users.empty?
+ puts " empty"
+ else
+ room.users.each do |u|
+ puts " #{ u.name }. Admin: #{ user.admin? }"
+ end
+ end
+
+ if room.name =~ /test/
+ Firering.update_room(room.id, "topic" => "test test test") do |response|
+ puts " * Updating topic: "
+ puts response.response_header.status
+ end
+
+ Firering.text(room.id, "hola") do
+ puts "texted"
+ end
+
+ Firering.paste(room.id, "hola\nmundo") do
+ puts "pasted"
+ end
+
+ end
+ end
+ end
+ end
+
+ trap("INT") { EM.stop }
+end
@@ -0,0 +1,36 @@
+Gem::Specification.new do |s|
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.rubygems_version = '1.3.5'
+
+ s.name = 'firering'
+ s.version = '0.1.0'
+ s.date = '2010-05-20'
+ s.rubyforge_project = 'firering'
+
+ s.summary = "Campfire API interface powered by EventMachine and Yajl."
+ s.description = "Campfire API interface powered by EventMachine and Yajl."
+
+ s.authors = ["Emmanuel Oga"]
+ s.email = 'EmmanuelOga@gmail.com'
+ s.homepage = 'http://github.com/EmmanuelOga/firering'
+
+ s.require_paths = %w[lib]
+
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.extra_rdoc_files = %w[README.rdoc LICENSE]
+
+ s.add_dependency('eventmachine', [">= 0.12.10"])
+ s.add_dependency('em-http-request', [">= 0.2.7"])
+ s.add_dependency('yajl', [">= 0.7.6"])
+
+ s.add_development_dependency('rspec', [">= 1.3.0"])
+
+ # = MANIFEST =
+ s.files = %w[
+
+ ]
+ # = MANIFEST =
+
+ s.test_files = s.files.select { |path| path =~ /^spec/ }
+end
Oops, something went wrong.

0 comments on commit a707490

Please sign in to comment.