upscrn-client 0.1.0

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
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rest-client"
4
+ gem "json"
5
+
6
+ group :development do
7
+ gem "rspec", "~> 2.3.0"
8
+ gem "bundler", "~> 1.0.0"
9
+ gem "jeweler", "~> 1.6.4"
10
+ gem "rcov", ">= 0"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.6.4)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ json (1.5.4)
11
+ mime-types (1.16)
12
+ rake (0.9.2)
13
+ rcov (0.9.10)
14
+ rest-client (1.6.7)
15
+ mime-types (>= 1.16)
16
+ rspec (2.3.0)
17
+ rspec-core (~> 2.3.0)
18
+ rspec-expectations (~> 2.3.0)
19
+ rspec-mocks (~> 2.3.0)
20
+ rspec-core (2.3.1)
21
+ rspec-expectations (2.3.0)
22
+ diff-lcs (~> 1.1.2)
23
+ rspec-mocks (2.3.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.0.0)
30
+ jeweler (~> 1.6.4)
31
+ json
32
+ rcov
33
+ rest-client
34
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Yeti Media
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.mdown ADDED
@@ -0,0 +1,36 @@
1
+ # upscrn-client
2
+
3
+ This is a client for the [upscrn](http://upscrn.com) api.
4
+
5
+
6
+ ## Usage
7
+
8
+ Get the api token from upscrn.com.
9
+
10
+ Upload a screenshot with:
11
+
12
+ UpscrnClient::Client.upload_screenshot(filename, auth_token)
13
+
14
+ To upload a screenshot to a specific project, use:
15
+
16
+ UpscrnClient::Client.upload_screenshot(filename, auth_token, :project_id => 12345)
17
+
18
+ For a list of a user's projects, use:
19
+
20
+ UpscrnClient::Client.projects(auth_token)
21
+
22
+ ## Contributing to upscrn-client
23
+
24
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
25
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
26
+ * Fork the project
27
+ * Start a feature/bugfix branch
28
+ * Commit and push until you are happy with your contribution
29
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
30
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
31
+
32
+ ## Copyright
33
+
34
+ Copyright (c) 2011 Yeti Media. See LICENSE.txt for
35
+ further details.
36
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "upscrn-client"
18
+ gem.homepage = "https://github.com/Yeti-Media/upscrn-client"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{client library for accessing the upscrn api}
21
+ gem.description = %Q{client library for accessing the upscrn api}
22
+ gem.email = "madcowley@gmail.com"
23
+ gem.authors = ["Matt Cowley"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "upscrn-client #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'json'
4
+ require 'rest_client'
5
+ require File.dirname(__FILE__) + '/upscrn_client/client'
6
+
7
+ module UpscrnClient
8
+ end
@@ -0,0 +1,58 @@
1
+ module UpscrnClient
2
+ class Client
3
+ class << self
4
+
5
+
6
+ # Upload a screenshot to the upscrn server.
7
+ # Pass :project_id in the options to upload to a particular project
8
+
9
+ def upload_screenshot(filename, auth_token, options = {})
10
+ puts "filepath: #{filepath}"
11
+ @result = Hash.new
12
+ @result['success'] = true
13
+ file = File.open filename, 'r'
14
+ begin
15
+ if options[:project_id]
16
+ post_response = perform("post", "projects/#{project}/screenshots", auth_token, {:screenshot => {:image => @image}})
17
+ else
18
+ post_response = perform('post', 'screenshots', auth_token, {:screenshot => {:image => file}})
19
+ end
20
+
21
+ puts "response: #{post_response}"
22
+ @url = post_response["url"]
23
+ @result['success'] = true
24
+ @result['url'] = @url
25
+ #clickable_link = NSAttributedString.hyperlinkFromString("See on upscrn", withURL:nsurl)
26
+ puts "url = #{@url}"
27
+ #@url_label.stringValue = nsurl
28
+ #show_screenshot_url(@url, nsurl)
29
+ @url
30
+ rescue Exception => e
31
+ puts "Exception! #{e.message}"
32
+ @result['success'] = false
33
+ puts "1"
34
+ @result['error'] = e.message.to_s
35
+ puts "set result"
36
+ #@url_label.stringValue = e.message
37
+ end
38
+ @result
39
+ end
40
+
41
+
42
+ # return a list of projects for a given user
43
+ # list is returned in json format
44
+ def projects(auth_token)
45
+ perform('get', 'projects', auth_token)
46
+ end
47
+
48
+ def perform(verb,action,auth_token, params={})
49
+ action = [action, 'json'].join('.')
50
+ url = ['http://upscrn.com', action].join('/')
51
+ #url = ['http://127.0.0.1:3000', action].join('/')
52
+ url = url + "?auth_token=#{auth_token}"
53
+ #p url
54
+ JSON.parse(RestClient.send(verb,url,params).body)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'upscrn-client'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "UpscrnClient" do
4
+ it "fails" do
5
+ fail "hey buddy, you should probably rename this file and start specing for real"
6
+ end
7
+ end
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{upscrn-client}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = [%q{Matt Cowley}]
12
+ s.date = %q{2011-09-15}
13
+ s.description = %q{client library for accessing the upscrn api}
14
+ s.email = %q{madcowley@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.mdown"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "README.mdown",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/upscrn-client.rb",
29
+ "lib/upscrn_client/client.rb",
30
+ "spec/spec_helper.rb",
31
+ "spec/upscrn-client_spec.rb",
32
+ "upscrn-client.gemspec"
33
+ ]
34
+ s.homepage = %q{https://github.com/Yeti-Media/upscrn-client}
35
+ s.licenses = [%q{MIT}]
36
+ s.require_paths = [%q{lib}]
37
+ s.rubygems_version = %q{1.8.8}
38
+ s.summary = %q{client library for accessing the upscrn api}
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
45
+ s.add_runtime_dependency(%q<json>, [">= 0"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
49
+ s.add_development_dependency(%q<rcov>, [">= 0"])
50
+ else
51
+ s.add_dependency(%q<rest-client>, [">= 0"])
52
+ s.add_dependency(%q<json>, [">= 0"])
53
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
54
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
56
+ s.add_dependency(%q<rcov>, [">= 0"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<rest-client>, [">= 0"])
60
+ s.add_dependency(%q<json>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
64
+ s.add_dependency(%q<rcov>, [">= 0"])
65
+ end
66
+ end
67
+
metadata ADDED
@@ -0,0 +1,167 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: upscrn-client
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Matt Cowley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ name: rest-client
31
+ prerelease: false
32
+ type: :runtime
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ hash: 3
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ name: json
45
+ prerelease: false
46
+ type: :runtime
47
+ requirement: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 2
57
+ - 3
58
+ - 0
59
+ version: 2.3.0
60
+ name: rspec
61
+ prerelease: false
62
+ type: :development
63
+ requirement: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ version_requirements: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ hash: 23
71
+ segments:
72
+ - 1
73
+ - 0
74
+ - 0
75
+ version: 1.0.0
76
+ name: bundler
77
+ prerelease: false
78
+ type: :development
79
+ requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ hash: 7
87
+ segments:
88
+ - 1
89
+ - 6
90
+ - 4
91
+ version: 1.6.4
92
+ name: jeweler
93
+ prerelease: false
94
+ type: :development
95
+ requirement: *id005
96
+ - !ruby/object:Gem::Dependency
97
+ version_requirements: &id006 !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ hash: 3
103
+ segments:
104
+ - 0
105
+ version: "0"
106
+ name: rcov
107
+ prerelease: false
108
+ type: :development
109
+ requirement: *id006
110
+ description: client library for accessing the upscrn api
111
+ email: madcowley@gmail.com
112
+ executables: []
113
+
114
+ extensions: []
115
+
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.mdown
119
+ files:
120
+ - .document
121
+ - .rspec
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.mdown
126
+ - Rakefile
127
+ - VERSION
128
+ - lib/upscrn-client.rb
129
+ - lib/upscrn_client/client.rb
130
+ - spec/spec_helper.rb
131
+ - spec/upscrn-client_spec.rb
132
+ - upscrn-client.gemspec
133
+ homepage: https://github.com/Yeti-Media/upscrn-client
134
+ licenses:
135
+ - MIT
136
+ post_install_message:
137
+ rdoc_options: []
138
+
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 3
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ hash: 3
156
+ segments:
157
+ - 0
158
+ version: "0"
159
+ requirements: []
160
+
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.8
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: client library for accessing the upscrn api
166
+ test_files: []
167
+