spacer 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.5.1 / 2008-02-15
2
+
3
+ * Removed dependency on ActiveSupport
4
+ * Addeded dependency on json gem
5
+
1
6
  == 0.5.0 / 2008-02-09
2
7
 
3
8
  * Initial release
@@ -19,6 +19,16 @@ lib/spacer/models/status.rb
19
19
  lib/spacer/models/user.rb
20
20
  lib/spacer/models/video.rb
21
21
  tasks/annotations.rake
22
+ tasks/archive/annotations.rake
23
+ tasks/archive/doc.rake
24
+ tasks/archive/gem.rake
25
+ tasks/archive/manifest.rake
26
+ tasks/archive/post_load.rake
27
+ tasks/archive/rubyforge.rake
28
+ tasks/archive/setup.rb
29
+ tasks/archive/spec.rake
30
+ tasks/archive/svn.rake
31
+ tasks/archive/test.rake
22
32
  tasks/doc.rake
23
33
  tasks/gem.rake
24
34
  tasks/manifest.rake
data/Rakefile CHANGED
@@ -14,6 +14,8 @@ PROJ.authors = 'Shane Vitarana'
14
14
  PROJ.email = 'shanev@gmail.com'
15
15
  PROJ.url = 'http://shanesbrain.net'
16
16
  PROJ.rubyforge_name = 'spacer'
17
+ PROJ.version = Spacer::VERSION
18
+ PROJ.dependencies = ['oauth', 'json']
17
19
 
18
20
  PROJ.spec_opts << '--color'
19
21
 
@@ -6,13 +6,17 @@ unless defined? Spacer
6
6
 
7
7
  require 'rubygems'
8
8
  require 'oauth/consumer'
9
- require 'activesupport'
9
+ require 'json'
10
+ require 'logger'
10
11
  require 'spacer/model'
11
12
 
12
13
  module Spacer
13
14
 
15
+ # Change this to false to run tests over the network and not use stubs
16
+ STUB_NETWORK = true
17
+
14
18
  # :stopdoc:
15
- VERSION = '0.5.0'
19
+ VERSION = '0.5.1'
16
20
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
17
21
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
18
22
  # :startdoc:
@@ -27,8 +27,14 @@ module Spacer
27
27
  @profile = Profile.from_hash(response)
28
28
  end
29
29
 
30
+ # Optional attributes:
31
+ #
32
+ # +page+: (default = 40),
33
+ # +page_size+: (max size = 3000),
34
+ # +list+: (:top || :online)
35
+ #
30
36
  def friends(user_id, page=nil, page_size=nil, list=nil)
31
- response = do_request "users/#{user_id}/friends.#{FORMAT.to_s}?page=#{page}&page_size=#{page_size}&list=#{list}"
37
+ response = do_request "users/#{user_id}/friends.#{FORMAT.to_s}?page=#{page}&page_size=#{page_size}&list=#{list.to_s}"
32
38
  @friends = response['friends'].map do |friend|
33
39
  User.from_hash_with_client(friend, self)
34
40
  end
@@ -127,11 +133,15 @@ module Spacer
127
133
  request = Net::HTTP::Get.new(request_uri.path)
128
134
  request = @auth.process_request(http, request)
129
135
  @log.debug "REQUEST PATH: #{request.path}"
130
-
131
136
  response = http.request(request)
132
137
  @log.debug "RESPONSE BODY: #{response.body}\n"
138
+ response.value
133
139
 
134
- ActiveSupport::JSON.decode(response.body)
140
+ hash = parse(response.body)
141
+ end
142
+
143
+ def parse(json)
144
+ JSON.parse(json)
135
145
  end
136
146
 
137
147
  def request_uri(query)
@@ -1,26 +1,27 @@
1
- ## Graciously stolen from Facebooker
2
- #
3
- # Copyright (c) 2007 Chad Fowler <chad@infoether.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- # this software and associated documentation files (the "Software"), to deal in the
7
- # Software without restriction, including without limitation the rights to use,
8
- # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
9
- # Software, and to permit persons to whom the Software is furnished to do so,
10
- # subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19
- # AN ACTION 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.
21
-
22
1
  module Spacer
2
+
3
+ ## Graciously stolen from Facebooker
4
+ #
5
+ # Copyright (c) 2007 Chad Fowler <chad@infoether.com>
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ # this software and associated documentation files (the "Software"), to deal in the
9
+ # Software without restriction, including without limitation the rights to use,
10
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11
+ # Software, and to permit persons to whom the Software is furnished to do so,
12
+ # subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in all
15
+ # copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21
+ # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  ##
24
+
24
25
  # helper methods primarily supporting the management of Ruby objects which are populatable via Hashes.
25
26
  # Since most Facebook API calls accept and return hashes of data (as XML), the Model module allows us to
26
27
  # directly populate a model's attributes given a Hash with matching key names.
@@ -0,0 +1,30 @@
1
+ # $Id$
2
+
3
+ if HAVE_BONES
4
+
5
+ desc "Enumerate all annotations"
6
+ task :notes do
7
+ Bones::AnnotationExtractor.enumerate(
8
+ PROJ, "OPTIMIZE|FIXME|TODO", :tag => true)
9
+ end
10
+
11
+ namespace :notes do
12
+ desc "Enumerate all OPTIMIZE annotations"
13
+ task :optimize do
14
+ Bones::AnnotationExtractor.enumerate(PROJ, "OPTIMIZE")
15
+ end
16
+
17
+ desc "Enumerate all FIXME annotations"
18
+ task :fixme do
19
+ Bones::AnnotationExtractor.enumerate(PROJ, "FIXME")
20
+ end
21
+
22
+ desc "Enumerate all TODO annotations"
23
+ task :todo do
24
+ Bones::AnnotationExtractor.enumerate(PROJ, "TODO")
25
+ end
26
+ end
27
+
28
+ end # if HAVE_BONES
29
+
30
+ # EOF
@@ -0,0 +1,49 @@
1
+ # $Id$
2
+
3
+ require 'rake/rdoctask'
4
+
5
+ namespace :doc do
6
+
7
+ desc 'Generate RDoc documentation'
8
+ Rake::RDocTask.new do |rd|
9
+ rd.main = PROJ.rdoc_main
10
+ rd.rdoc_dir = PROJ.rdoc_dir
11
+
12
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
13
+ excl = Regexp.new(PROJ.rdoc_exclude.join('|'))
14
+ files = PROJ.files.find_all do |fn|
15
+ case fn
16
+ when excl; false
17
+ when incl; true
18
+ else false end
19
+ end
20
+ rd.rdoc_files.push(*files)
21
+
22
+ title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
+ title = "#{PROJ.rubyforge_name}'s " + title if PROJ.rubyforge_name != title
24
+
25
+ rd.options << "-t #{title}"
26
+ rd.options.concat(PROJ.rdoc_opts)
27
+ end
28
+
29
+ desc 'Generate ri locally for testing'
30
+ task :ri => :clobber_ri do
31
+ sh "#{RDOC} --ri -o ri ."
32
+ end
33
+
34
+ desc 'Remove ri products'
35
+ task :clobber_ri do
36
+ rm_r 'ri' rescue nil
37
+ end
38
+
39
+ end # namespace :doc
40
+
41
+ desc 'Alias to doc:rdoc'
42
+ task :doc => 'doc:rdoc'
43
+
44
+ desc 'Remove all build products'
45
+ task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
46
+
47
+ remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
48
+
49
+ # EOF
@@ -0,0 +1,89 @@
1
+ # $Id$
2
+
3
+ require 'rake/gempackagetask'
4
+
5
+ namespace :gem do
6
+
7
+ PROJ.spec = Gem::Specification.new do |s|
8
+ s.name = PROJ.name
9
+ s.version = PROJ.version
10
+ s.summary = PROJ.summary
11
+ s.authors = Array(PROJ.authors)
12
+ s.email = PROJ.email
13
+ s.homepage = Array(PROJ.url).first
14
+ s.rubyforge_project = PROJ.rubyforge_name
15
+
16
+ s.description = PROJ.description
17
+
18
+ PROJ.dependencies.each do |dep|
19
+ s.add_dependency(*dep)
20
+ end
21
+
22
+ s.files = PROJ.files
23
+ s.executables = PROJ.executables.map {|fn| File.basename(fn)}
24
+ s.extensions = PROJ.files.grep %r/extconf\.rb$/
25
+
26
+ s.bindir = 'bin'
27
+ dirs = Dir["{#{PROJ.libs.join(',')}}"]
28
+ s.require_paths = dirs unless dirs.empty?
29
+
30
+ incl = Regexp.new(PROJ.rdoc_include.join('|'))
31
+ excl = PROJ.rdoc_exclude.dup.concat %w[\.rb$ ^(\.\/|\/)?ext]
32
+ excl = Regexp.new(excl.join('|'))
33
+ rdoc_files = PROJ.files.find_all do |fn|
34
+ case fn
35
+ when excl; false
36
+ when incl; true
37
+ else false end
38
+ end
39
+ s.rdoc_options = PROJ.rdoc_opts + ['--main', PROJ.rdoc_main]
40
+ s.extra_rdoc_files = rdoc_files
41
+ s.has_rdoc = true
42
+
43
+ if test ?f, PROJ.test_file
44
+ s.test_file = PROJ.test_file
45
+ else
46
+ s.test_files = PROJ.tests.to_a
47
+ end
48
+
49
+ # Do any extra stuff the user wants
50
+ # spec_extras.each do |msg, val|
51
+ # case val
52
+ # when Proc
53
+ # val.call(s.send(msg))
54
+ # else
55
+ # s.send "#{msg}=", val
56
+ # end
57
+ # end
58
+ end
59
+
60
+ desc 'Show information about the gem'
61
+ task :debug do
62
+ puts PROJ.spec.to_ruby
63
+ end
64
+
65
+ Rake::GemPackageTask.new(PROJ.spec) do |pkg|
66
+ pkg.need_tar = PROJ.need_tar
67
+ pkg.need_zip = PROJ.need_zip
68
+ end
69
+
70
+ desc 'Install the gem'
71
+ task :install => [:clobber, :package] do
72
+ sh "#{SUDO} #{GEM} install pkg/#{PROJ.spec.full_name}"
73
+ end
74
+
75
+ desc 'Uninstall the gem'
76
+ task :uninstall do
77
+ sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
78
+ end
79
+
80
+ end # namespace :gem
81
+
82
+ desc 'Alias to gem:package'
83
+ task :gem => 'gem:package'
84
+
85
+ task :clobber => 'gem:clobber_package'
86
+
87
+ remove_desc_for_task %w(gem:clobber_package)
88
+
89
+ # EOF
@@ -0,0 +1,55 @@
1
+ # $Id$
2
+
3
+ require 'find'
4
+
5
+ namespace :manifest do
6
+
7
+ desc 'Verify the manifest'
8
+ task :check do
9
+ fn = 'Manifest.tmp'
10
+ files = []
11
+ exclude = Regexp.new(PROJ.exclude.join('|'))
12
+ Find.find '.' do |path|
13
+ path.sub! %r/^(\.\/|\/)/o, ''
14
+ next unless test ?f, path
15
+ next if path =~ exclude
16
+ files << path
17
+ end
18
+
19
+ File.open(fn, 'w') {|fp| fp.puts files.sort}
20
+ lines = %x(#{DIFF} -du Manifest.txt #{fn}).split("\n")
21
+ if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
22
+ lines.map! do |line|
23
+ case line
24
+ when %r/^(-{3}|\+{3})/; nil
25
+ when %r/^@/; Console::ANSICode.blue line
26
+ when %r/^\+/; Console::ANSICode.green line
27
+ when %r/^\-/; Console::ANSICode.red line
28
+ else line end
29
+ end
30
+ end
31
+ puts lines.compact
32
+ rm fn rescue nil
33
+ end
34
+
35
+ desc 'Create a new manifest'
36
+ task :create do
37
+ fn = 'Manifest.txt'
38
+ files = []
39
+ exclude = Regexp.new(PROJ.exclude.join('|'))
40
+ Find.find '.' do |path|
41
+ path.sub! %r/^(\.\/|\/)/o, ''
42
+ next unless test ?f, path
43
+ next if path =~ exclude
44
+ files << path
45
+ end
46
+
47
+ files << fn unless test ?f, fn
48
+ File.open(fn, 'w') {|fp| fp.puts files.sort}
49
+ end
50
+ end # namespace :manifest
51
+
52
+ desc 'Alias to manifest:check'
53
+ task :manifest => 'manifest:check'
54
+
55
+ # EOF
@@ -0,0 +1,18 @@
1
+ # $Id$
2
+
3
+ # This file does not define any rake tasks. It is used to load some project
4
+ # settings if they are not defined by the user.
5
+
6
+ unless PROJ.changes
7
+ PROJ.changes = paragraphs_of('History.txt', 0..1).join("\n\n")
8
+ end
9
+
10
+ unless PROJ.description
11
+ PROJ.description = paragraphs_of('README.txt', 'description').join("\n\n")
12
+ end
13
+
14
+ unless PROJ.summary
15
+ PROJ.summary = PROJ.description.split('.').first
16
+ end
17
+
18
+ # EOF
@@ -0,0 +1,57 @@
1
+ # $Id$
2
+
3
+ if PROJ.rubyforge_name && HAVE_RUBYFORGE
4
+
5
+ require 'rubyforge'
6
+ require 'rake/contrib/sshpublisher'
7
+
8
+ namespace :gem do
9
+ desc 'Package and upload to RubyForge'
10
+ task :release => [:clobber, :package] do |t|
11
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
12
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
13
+ pkg = "pkg/#{PROJ.spec.full_name}"
14
+
15
+ if $DEBUG then
16
+ puts "release_id = rf.add_release #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, #{PROJ.version.inspect}, \"#{pkg}.tgz\""
17
+ puts "rf.add_file #{PROJ.rubyforge_name.inspect}, #{PROJ.name.inspect}, release_id, \"#{pkg}.gem\""
18
+ end
19
+
20
+ rf = RubyForge.new
21
+ puts 'Logging in'
22
+ rf.login
23
+
24
+ c = rf.userconfig
25
+ c['release_notes'] = PROJ.description if PROJ.description
26
+ c['release_changes'] = PROJ.changes if PROJ.changes
27
+ c['preformatted'] = true
28
+
29
+ files = [(PROJ.need_tar ? "#{pkg}.tgz" : nil),
30
+ (PROJ.need_zip ? "#{pkg}.zip" : nil),
31
+ "#{pkg}.gem"].compact
32
+
33
+ puts "Releasing #{PROJ.name} v. #{PROJ.version}"
34
+ rf.add_release PROJ.rubyforge_name, PROJ.name, PROJ.version, *files
35
+ end
36
+ end # namespace :gem
37
+
38
+
39
+ namespace :doc do
40
+ desc "Publish RDoc to RubyForge"
41
+ task :release => %w(doc:clobber_rdoc doc:rdoc) do
42
+ config = YAML.load(
43
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
44
+ )
45
+
46
+ host = "#{config['username']}@rubyforge.org"
47
+ remote_dir = "/var/www/gforge-projects/#{PROJ.rubyforge_name}/"
48
+ remote_dir << PROJ.rdoc_remote_dir if PROJ.rdoc_remote_dir
49
+ local_dir = PROJ.rdoc_dir
50
+
51
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
52
+ end
53
+ end # namespace :doc
54
+
55
+ end # if HAVE_RUBYFORGE
56
+
57
+ # EOF
@@ -0,0 +1,189 @@
1
+ # $Id$
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'fileutils'
6
+ require 'ostruct'
7
+
8
+ PROJ = OpenStruct.new
9
+
10
+ PROJ.name = nil
11
+ PROJ.summary = nil
12
+ PROJ.description = nil
13
+ PROJ.changes = nil
14
+ PROJ.authors = nil
15
+ PROJ.email = nil
16
+ PROJ.url = nil
17
+ PROJ.version = ENV['VERSION'] || '0.0.0'
18
+ PROJ.rubyforge_name = nil
19
+ PROJ.exclude = %w(tmp$ bak$ ~$ CVS .svn/ ^pkg/ ^doc/)
20
+
21
+ # Rspec
22
+ PROJ.specs = FileList['spec/**/*_spec.rb']
23
+ PROJ.spec_opts = []
24
+
25
+ # Test::Unit
26
+ PROJ.tests = FileList['test/**/test_*.rb']
27
+ PROJ.test_file = 'test/all.rb'
28
+ PROJ.test_opts = []
29
+
30
+ # Rcov
31
+ PROJ.rcov_opts = ['--sort', 'coverage', '-T']
32
+
33
+ # Rdoc
34
+ PROJ.rdoc_opts = []
35
+ PROJ.rdoc_include = %w(^lib/ ^bin/ ^ext/ .txt$)
36
+ PROJ.rdoc_exclude = %w(extconf.rb$ ^Manifest.txt$)
37
+ PROJ.rdoc_main = 'README.txt'
38
+ PROJ.rdoc_dir = 'doc'
39
+ PROJ.rdoc_remote_dir = nil
40
+
41
+ # Extensions
42
+ PROJ.extensions = FileList['ext/**/extconf.rb']
43
+ PROJ.ruby_opts = %w(-w)
44
+ PROJ.libs = []
45
+ %w(lib ext).each {|dir| PROJ.libs << dir if test ?d, dir}
46
+
47
+ # Gem Packaging
48
+ PROJ.files =
49
+ if test ?f, 'Manifest.txt'
50
+ files = File.readlines('Manifest.txt').map {|fn| fn.chomp.strip}
51
+ files.delete ''
52
+ files
53
+ else [] end
54
+ PROJ.executables = PROJ.files.find_all {|fn| fn =~ %r/^bin/}
55
+ PROJ.dependencies = []
56
+ PROJ.need_tar = true
57
+ PROJ.need_zip = false
58
+
59
+ # File Annotations
60
+ PROJ.annotation_exclude = []
61
+ PROJ.annotation_extensions = %w(.txt .rb .erb) << ''
62
+
63
+ # Subversion Repository
64
+ PROJ.svn = false
65
+ PROJ.svn_root = nil
66
+ PROJ.svn_trunk = 'trunk'
67
+ PROJ.svn_tags = 'tags'
68
+ PROJ.svn_branches = 'branches'
69
+
70
+ # Load the other rake files in the tasks folder
71
+ rakefiles = Dir.glob('tasks/*.rake').sort
72
+ rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
73
+ import(*rakefiles)
74
+
75
+ # Setup some constants
76
+ WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
77
+
78
+ DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
79
+
80
+ def quiet( &block )
81
+ io = [STDOUT.dup, STDERR.dup]
82
+ STDOUT.reopen DEV_NULL
83
+ STDERR.reopen DEV_NULL
84
+ block.call
85
+ ensure
86
+ STDOUT.reopen io.first
87
+ STDERR.reopen io.last
88
+ end
89
+
90
+ DIFF = if WIN32 then 'diff.exe'
91
+ else
92
+ if quiet {system "gdiff", __FILE__, __FILE__} then 'gdiff'
93
+ else 'diff' end
94
+ end unless defined? DIFF
95
+
96
+ SUDO = if WIN32 then ''
97
+ else
98
+ if quiet {system 'which sudo'} then 'sudo'
99
+ else '' end
100
+ end
101
+
102
+ RCOV = WIN32 ? 'rcov.cmd' : 'rcov'
103
+ GEM = WIN32 ? 'gem.cmd' : 'gem'
104
+
105
+ %w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
106
+ begin
107
+ require lib
108
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
109
+ rescue LoadError
110
+ Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", false}
111
+ end
112
+ end
113
+
114
+ # Reads a file at +path+ and spits out an array of the +paragraphs+
115
+ # specified.
116
+ #
117
+ # changes = paragraphs_of('History.txt', 0..1).join("\n\n")
118
+ # summary, *description = paragraphs_of('README.txt', 3, 3..8)
119
+ #
120
+ def paragraphs_of( path, *paragraphs )
121
+ title = String === paragraphs.first ? paragraphs.shift : nil
122
+ ary = File.read(path).delete("\r").split(/\n\n+/)
123
+
124
+ result = if title
125
+ tmp, matching = [], false
126
+ rgxp = %r/^=+\s*#{Regexp.escape(title)}/i
127
+ paragraphs << (0..-1) if paragraphs.empty?
128
+
129
+ ary.each do |val|
130
+ if val =~ rgxp
131
+ break if matching
132
+ matching = true
133
+ rgxp = %r/^=+/i
134
+ elsif matching
135
+ tmp << val
136
+ end
137
+ end
138
+ tmp
139
+ else ary end
140
+
141
+ result.values_at(*paragraphs)
142
+ end
143
+
144
+ # Adds the given gem _name_ to the current project's dependency list. An
145
+ # optional gem _version_ can be given. If omitted, the newest gem version
146
+ # will be used.
147
+ #
148
+ def depend_on( name, version = nil )
149
+ spec = Gem.source_index.find_name(name).last
150
+ version = spec.version.to_s if version.nil? and !spec.nil?
151
+
152
+ PROJ.dependencies << (version.nil? ? [name] : [name, ">= #{version}"])
153
+ end
154
+
155
+ # Adds the given arguments to the include path if they are not already there
156
+ #
157
+ def ensure_in_path( *args )
158
+ args.each do |path|
159
+ path = File.expand_path(path)
160
+ $:.unshift(path) if test(?d, path) and not $:.include?(path)
161
+ end
162
+ end
163
+
164
+ # Find a rake task using the task name and remove any description text. This
165
+ # will prevent the task from being displayed in the list of available tasks.
166
+ #
167
+ def remove_desc_for_task( names )
168
+ Array(names).each do |task_name|
169
+ task = Rake.application.tasks.find {|t| t.name == task_name}
170
+ next if task.nil?
171
+ task.instance_variable_set :@comment, nil
172
+ end
173
+ end
174
+
175
+ # Change working directories to _dir_, call the _block_ of code, and then
176
+ # change back to the original working directory (the current directory when
177
+ # this method was called).
178
+ #
179
+ def in_directory( dir, &block )
180
+ curdir = pwd
181
+ begin
182
+ cd dir
183
+ return block.call
184
+ ensure
185
+ cd curdir
186
+ end
187
+ end
188
+
189
+ # EOF
@@ -0,0 +1,43 @@
1
+ # $Id$
2
+
3
+ if HAVE_SPEC_RAKE_SPECTASK
4
+
5
+ namespace :spec do
6
+
7
+ desc 'Run all specs with basic output'
8
+ Spec::Rake::SpecTask.new(:run) do |t|
9
+ t.spec_opts = PROJ.spec_opts
10
+ t.spec_files = PROJ.specs
11
+ t.libs += PROJ.libs
12
+ end
13
+
14
+ desc 'Run all specs with text output'
15
+ Spec::Rake::SpecTask.new(:specdoc) do |t|
16
+ t.spec_opts = PROJ.spec_opts + ['--format', 'specdoc']
17
+ t.spec_files = PROJ.specs
18
+ t.libs += PROJ.libs
19
+ end
20
+
21
+ if HAVE_RCOV
22
+ desc 'Run all specs with RCov'
23
+ Spec::Rake::SpecTask.new(:rcov) do |t|
24
+ t.spec_opts = PROJ.spec_opts
25
+ t.spec_files = PROJ.specs
26
+ t.libs += PROJ.libs
27
+ t.rcov = true
28
+ t.rcov_opts = PROJ.rcov_opts + ['--exclude', 'spec']
29
+ end
30
+ end
31
+
32
+ end # namespace :spec
33
+
34
+ desc 'Alias to spec:run'
35
+ task :spec => 'spec:run'
36
+
37
+ task :clobber => 'spec:clobber_rcov' if HAVE_RCOV
38
+
39
+ remove_desc_for_task %w(spec:clobber_rcov)
40
+
41
+ end # if HAVE_SPEC_RAKE_SPECTASK
42
+
43
+ # EOF
@@ -0,0 +1,44 @@
1
+ # $Id$
2
+
3
+
4
+ if PROJ.svn and system("svn --version 2>&1 > #{DEV_NULL}")
5
+
6
+ unless PROJ.svn_root
7
+ info = %x/svn info ./
8
+ m = %r/^Repository Root:\s+(.*)$/.match(info)
9
+ PROJ.svn_root = (m.nil? ? '' : m[1])
10
+ end
11
+ PROJ.svn_root = File.join(PROJ.svn_root, PROJ.svn) if String === PROJ.svn
12
+
13
+ namespace :svn do
14
+
15
+ desc 'Show tags from the SVN repository'
16
+ task :show_tags do |t|
17
+ tags = %x/svn list #{File.join(PROJ.svn_root, PROJ.svn_tags)}/
18
+ tags.gsub!(%r/\/$/, '')
19
+ puts tags
20
+ end
21
+
22
+ desc 'Create a new tag in the SVN repository'
23
+ task :create_tag do |t|
24
+ v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
25
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PROJ.version
26
+
27
+ trunk = File.join(PROJ.svn_root, PROJ.svn_trunk)
28
+ tag = "%s-%s" % [PROJ.name, PROJ.version]
29
+ tag = File.join(PROJ.svn_root, PROJ.svn_tags, tag)
30
+ msg = "Creating tag for #{PROJ.name} version #{PROJ.version}"
31
+
32
+ puts "Creating SVN tag '#{tag}'"
33
+ unless system "svn cp -m '#{msg}' #{trunk} #{tag}"
34
+ abort "Tag creation failed"
35
+ end
36
+ end
37
+
38
+ end # namespace :svn
39
+
40
+ task 'gem:release' => 'svn:create_tag'
41
+
42
+ end # if PROJ.svn
43
+
44
+ # EOF
@@ -0,0 +1,40 @@
1
+ # $Id$
2
+
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+
7
+ Rake::TestTask.new(:run) do |t|
8
+ t.libs = PROJ.libs
9
+ t.test_files = if test ?f, PROJ.test_file then [PROJ.test_file]
10
+ else PROJ.tests end
11
+ t.ruby_opts += PROJ.ruby_opts
12
+ t.ruby_opts += PROJ.test_opts
13
+ end
14
+
15
+ if HAVE_RCOV
16
+ desc 'Run rcov on the unit tests'
17
+ task :rcov => :clobber_rcov do
18
+ opts = PROJ.rcov_opts.join(' ')
19
+ files = if test ?f, PROJ.test_file then [PROJ.test_file]
20
+ else PROJ.tests end
21
+ files = files.join(' ')
22
+ sh "#{RCOV} #{files} #{opts}"
23
+ end
24
+
25
+ desc 'Remove rcov products'
26
+ task :clobber_rcov do
27
+ rm_r 'coverage' rescue nil
28
+ end
29
+ end
30
+
31
+ end # namespace :test
32
+
33
+ desc 'Alias to test:run'
34
+ task :test => 'test:run'
35
+
36
+ task :clobber => 'test:clobber_rcov' if HAVE_RCOV
37
+
38
+ remove_desc_for_task %w(test:clobber_rcov)
39
+
40
+ # EOF
@@ -5,8 +5,6 @@ require 'rake'
5
5
  require 'fileutils'
6
6
  require 'ostruct'
7
7
 
8
- ENV['VERSION'] = "0.5.0"
9
-
10
8
  PROJ = OpenStruct.new
11
9
 
12
10
  PROJ.name = nil
@@ -1,13 +1,10 @@
1
1
  # $Id$
2
2
 
3
- STUB_NETWORK = true
4
-
5
3
  require File.join(File.dirname(__FILE__), %w[test_helper])
6
4
  require 'test/unit'
7
- require 'mocha'
8
5
 
9
6
  class TestClient < Test::Unit::TestCase
10
-
7
+
11
8
  def setup
12
9
  api_key = 'http://www.myspace.com/appname'
13
10
  secret_key = 'secretkey'
@@ -2,11 +2,15 @@
2
2
 
3
3
  require File.expand_path(
4
4
  File.join(File.dirname(__FILE__), %w[.. lib spacer]))
5
+
6
+ require 'mocha'
5
7
 
6
8
  def stubbing_http_response_with(xml_or_json_response)
7
- if STUB_NETWORK
8
- response = stub(:body => xml_or_json_response)
9
- Net::HTTP.any_instance.stubs(:request).returns(response)
9
+ if defined? Spacer::STUB_NETWORK
10
+ if Spacer::STUB_NETWORK
11
+ response = stub(:body => xml_or_json_response, :value => nil)
12
+ Net::HTTP.any_instance.stubs(:request).returns(response)
13
+ end
10
14
  end
11
15
  yield
12
16
  end
@@ -1,7 +1,5 @@
1
1
  # $Id$
2
2
 
3
- STUB_NETWORK = true
4
-
5
3
  require File.join(File.dirname(__FILE__), %w[test_helper])
6
4
  require 'test/unit'
7
5
  require 'mocha'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: spacer
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2008-02-09 00:00:00 -06:00
6
+ version: 0.5.1
7
+ date: 2008-02-15 00:00:00 -06:00
8
8
  summary: Ruby API for the MySpace Platform REST API
9
9
  require_paths:
10
10
  - lib
@@ -50,6 +50,16 @@ files:
50
50
  - lib/spacer/models/user.rb
51
51
  - lib/spacer/models/video.rb
52
52
  - tasks/annotations.rake
53
+ - tasks/archive/annotations.rake
54
+ - tasks/archive/doc.rake
55
+ - tasks/archive/gem.rake
56
+ - tasks/archive/manifest.rake
57
+ - tasks/archive/post_load.rake
58
+ - tasks/archive/rubyforge.rake
59
+ - tasks/archive/setup.rb
60
+ - tasks/archive/spec.rake
61
+ - tasks/archive/svn.rake
62
+ - tasks/archive/test.rake
53
63
  - tasks/doc.rake
54
64
  - tasks/gem.rake
55
65
  - tasks/manifest.rake
@@ -81,5 +91,22 @@ extensions: []
81
91
 
82
92
  requirements: []
83
93
 
84
- dependencies: []
85
-
94
+ dependencies:
95
+ - !ruby/object:Gem::Dependency
96
+ name: oauth
97
+ version_requirement:
98
+ version_requirements: !ruby/object:Gem::Version::Requirement
99
+ requirements:
100
+ - - ">"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.0.0
103
+ version:
104
+ - !ruby/object:Gem::Dependency
105
+ name: json
106
+ version_requirement:
107
+ version_requirements: !ruby/object:Gem::Version::Requirement
108
+ requirements:
109
+ - - ">"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.0.0
112
+ version: