lessneglect 0.3.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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2-head@lessneglect-gem --create
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'rest-client'
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.4"
14
+ gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,32 @@
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
+ mime-types (1.17.2)
11
+ rake (0.9.2.2)
12
+ rcov (0.9.11)
13
+ rest-client (1.6.7)
14
+ mime-types (>= 1.16)
15
+ rspec (2.3.0)
16
+ rspec-core (~> 2.3.0)
17
+ rspec-expectations (~> 2.3.0)
18
+ rspec-mocks (~> 2.3.0)
19
+ rspec-core (2.3.1)
20
+ rspec-expectations (2.3.0)
21
+ diff-lcs (~> 1.1.2)
22
+ rspec-mocks (2.3.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.0.0)
29
+ jeweler (~> 1.6.4)
30
+ rcov
31
+ rest-client
32
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Christopher Gooley
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
+ = lessneglect
2
+
3
+ Gem to allow your ruby app to submit messages and actions to your LessNeglect project account.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2011-2012 Christopher Gooley. See LICENSE.txt for further details.
8
+
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 = "lessneglect"
18
+ gem.homepage = "http://github.com/cgooley/lessneglect-ruby"
19
+ gem.license = "MIT"
20
+ gem.summary = "LessNeglect client API"
21
+ gem.description = "API library to allow you to connect and submit messages and actions to your LessNeglect project account"
22
+ gem.email = "gooley@lessneglect.com"
23
+ gem.authors = ["Christopher Gooley"]
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 = "lessneglect #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.0
@@ -0,0 +1,71 @@
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 = "lessneglect"
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Christopher Gooley"]
12
+ s.date = "2012-09-07"
13
+ s.description = "API library to allow you to connect and submit messages and actions to your LessNeglect project account"
14
+ s.email = "gooley@lessneglect.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lessneglect.gemspec",
30
+ "lib/lessneglect.rb",
31
+ "lib/lessneglect/api_helpers.rb",
32
+ "lib/lessneglect/methods.rb",
33
+ "lib/lessneglect/objects/action_event.rb",
34
+ "lib/lessneglect/objects/api_object.rb",
35
+ "lib/lessneglect/objects/event.rb",
36
+ "lib/lessneglect/objects/message.rb",
37
+ "lib/lessneglect/objects/person.rb",
38
+ "spec/lessneglect_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = "http://github.com/cgooley/lessneglect-ruby"
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = "1.8.24"
45
+ s.summary = "LessNeglect client API"
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<rest-client>, [">= 0"])
52
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<rest-client>, [">= 0"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
61
+ s.add_dependency(%q<rcov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<rest-client>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ end
70
+ end
71
+
@@ -0,0 +1,28 @@
1
+ require 'lessneglect/api_helpers'
2
+ require 'lessneglect/methods'
3
+
4
+ require 'lessneglect/objects/api_object'
5
+ require 'lessneglect/objects/person'
6
+ require 'lessneglect/objects/event'
7
+ require 'lessneglect/objects/action_event'
8
+ require 'lessneglect/objects/message'
9
+
10
+
11
+ class LessNeglectApi
12
+
13
+ class Client
14
+
15
+ def initialize(opts = {})
16
+ @base_url = "http://beta.lessneglect.com/api/v2"
17
+
18
+ @project_code = opts[:code]
19
+ @project_secret = opts[:secret]
20
+
21
+ unless @project_code && @project_secret
22
+ raise StandardError.new "Must specify project_code and project_secret when initalizing the ApiClient"
23
+ end
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,36 @@
1
+ require 'multi_json'
2
+ require 'rest_client'
3
+
4
+ class LessNeglectApi
5
+ class Client
6
+
7
+ def post_request(method, params={})
8
+ params = sign_request(params)
9
+
10
+ res = RestClient.post @base_url + method, params.to_json, :content_type => :json, :accept => :json
11
+ data = MultiJson.decode(res.body)
12
+ end
13
+
14
+ def get_request(method, params={})
15
+ params = sign_request(params)
16
+
17
+ res = RestClient.get @base_url + method, { :params => params }
18
+ data = MultiJson.decode(res.body)
19
+ end
20
+
21
+ private
22
+ def sign_request(params = {})
23
+ timestamp = Time.now.to_i
24
+ token = rand(36**12).to_s(36)
25
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha256'), @project_secret, "#{timestamp}#{token}")
26
+
27
+ params.merge({
28
+ :project_code => @project_code,
29
+ :signature => signature,
30
+ :token => token,
31
+ :timestamp => timestamp,
32
+ :format => "json"
33
+ })
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,33 @@
1
+ class LessNeglectApi::Client
2
+
3
+ def create_message(person, message)
4
+ params = {
5
+ :person => person.as_json,
6
+ :event => message.as_json
7
+ }
8
+
9
+ data = post_request("/events", params)
10
+ end
11
+
12
+ def create_action_event(person, action_event)
13
+ params = {
14
+ :person => person.as_json,
15
+ :event => action_event.as_json
16
+ }
17
+
18
+ data = post_request("/events", params)
19
+ end
20
+
21
+ def update_person(person)
22
+ params = {
23
+ :person => person.as_json
24
+ }
25
+
26
+ data = post_request("/people", params)
27
+ end
28
+
29
+ def tickets
30
+ data = get_request("/tickets")
31
+ end
32
+
33
+ end
@@ -0,0 +1,26 @@
1
+ class LessNeglectApi
2
+ class ActionEvent < Event
3
+
4
+ attr_accessor :note, :links
5
+
6
+ def add_link(name, href)
7
+ self.links ||= []
8
+ self.links << ActionLink.new({ :name => name, :href => href })
9
+ end
10
+
11
+ def as_json(options={})
12
+ super.merge({
13
+ :klass => "actionevent",
14
+ :note => self.note,
15
+ :links => self.links.nil? ? nil : self.links.as_json
16
+ }).as_json(options)
17
+ end
18
+
19
+ end
20
+
21
+ class ActionLink < ApiObject
22
+
23
+ attr_accessor :name, :href
24
+
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ class LessNeglectApi
2
+ class ApiObject
3
+
4
+ def initialize(args={})
5
+ args.each do |k,v|
6
+ instance_variable_set("@#{k}", v) unless v.nil?
7
+ end
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ class LessNeglectApi
2
+ class Event < ApiObject
3
+
4
+ attr_accessor :name, :magnitude
5
+
6
+ def as_json(options={})
7
+ {
8
+ :name => self.name,
9
+ :magnitude => self.magnitude
10
+ }.as_json(options)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ class LessNeglectApi
2
+ class Message < Event
3
+
4
+ attr_accessor :subject, :body
5
+
6
+ def as_json(options={})
7
+ super.merge({
8
+ :klass => "message",
9
+ :subject => self.subject,
10
+ :body => self.body
11
+ }).as_json(options)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ class LessNeglectApi
2
+ class Person < ApiObject
3
+
4
+ attr_accessor :id, :name, :email, :external_identifier, :properties
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Lessneglect" 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,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'lessneglect'
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
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lessneglect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christopher Gooley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rest-client
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.3.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.6.4
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.6.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: rcov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: API library to allow you to connect and submit messages and actions to
95
+ your LessNeglect project account
96
+ email: gooley@lessneglect.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - LICENSE.txt
101
+ - README.rdoc
102
+ files:
103
+ - .document
104
+ - .rspec
105
+ - .rvmrc
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - README.rdoc
110
+ - Rakefile
111
+ - VERSION
112
+ - lessneglect.gemspec
113
+ - lib/lessneglect.rb
114
+ - lib/lessneglect/api_helpers.rb
115
+ - lib/lessneglect/methods.rb
116
+ - lib/lessneglect/objects/action_event.rb
117
+ - lib/lessneglect/objects/api_object.rb
118
+ - lib/lessneglect/objects/event.rb
119
+ - lib/lessneglect/objects/message.rb
120
+ - lib/lessneglect/objects/person.rb
121
+ - spec/lessneglect_spec.rb
122
+ - spec/spec_helper.rb
123
+ homepage: http://github.com/cgooley/lessneglect-ruby
124
+ licenses:
125
+ - MIT
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 1.8.24
145
+ signing_key:
146
+ specification_version: 3
147
+ summary: LessNeglect client API
148
+ test_files: []