ourkudos 0.0.21 → 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.21
1
+ 0.0.29
@@ -34,19 +34,19 @@ module OurKudos
34
34
  class Client
35
35
 
36
36
  cattr_accessor :api_key, :base_uri
37
-
37
+ attr_accessor :resource
38
38
  include OurKudos::ResourceEditor
39
39
 
40
40
  #configuration hash
41
- OurKudosClientOptions = { 'api_key' => nil,
42
- 'base_uri' => "http://localhost:3000/api/" } if !Object.const_defined? :ClientOptions # :nodoc:
41
+ OurKudosClientOptions = { :api_key => nil,
42
+ :base_uri => "http://localhost:3000/api/" } if !Object.const_defined? :ClientOptions # :nodoc:
43
43
 
44
44
 
45
45
  #load settings from yaml file, if file is found
46
46
  if File.exists? OurKudos.config_file_path
47
47
  config = YAML.load_file OurKudos.config_file_path
48
- @@base_uri = OurKudosClientOptions['base_uri'] = config['base_uri']
49
- @@api_key = OurKudosClientOptions['api_key'] = config['api_key']
48
+ @@base_uri = OurKudosClientOptions[:base_uri] = config[:base_uri]
49
+ @@api_key = OurKudosClientOptions[:api_key] = config[:api_key]
50
50
  end
51
51
 
52
52
  # CLASS METHODS #
@@ -56,14 +56,14 @@ module OurKudos
56
56
  def api_key= api_key = nil
57
57
  return @@api_key unless api_key
58
58
 
59
- @@api_key = OurKudosClientOptions['api_key'] = api_key
59
+ @@api_key = OurKudosClientOptions[:api_key] = api_key
60
60
  end
61
61
 
62
62
  #sets base url
63
63
  def base_uri= base_uri = nil
64
64
  return @@base_uri unless base_uri
65
65
 
66
- @@base_uri = OurKudosClientOptions['base_uri'] = base_uri
66
+ @@base_uri = OurKudosClientOptions[:base_uri] = base_uri
67
67
  end
68
68
 
69
69
  end
@@ -71,13 +71,13 @@ module OurKudos
71
71
  # INSTANCE METHODS #
72
72
 
73
73
  #sets resource to read/edit/delete
74
- def resource_name= resource
75
- OurKudos::ResourceEditor.resource_name = resource
74
+ def resource= resource
75
+ OurKudos::ResourceEditor.resource = resource
76
76
  end
77
77
 
78
78
  #displays current resource
79
- def resource_name
80
- OurKudos::ResourceEditor.resource_name
79
+ def resource
80
+ OurKudos::ResourceEditor.resource
81
81
  end
82
82
 
83
83
  # general restuful post method - creates an item
@@ -1,11 +1,10 @@
1
1
  require 'rails'
2
2
  module Ourkudos
3
- class Ourkudos < Rails::Railtie
3
+ class Railtie < ::Rails::Railtie
4
4
 
5
5
  rake_tasks do
6
- path = File.expand_path(File.dirname(File.dirname(__FILE__)))
7
- load File.join path, "tasks/ourkudos.rake"
6
+ load File.dirname(__FILE__) + '/tasks/ourkudos.rb'
8
7
  end
9
-
10
- end
8
+
9
+ end
11
10
  end
@@ -1,28 +1,28 @@
1
1
  module OurKudos
2
2
  module ResourceEditor
3
3
 
4
- def self.resource_name= name
5
- @@resource_name = name
4
+ def self.resource= name
5
+ @@resource = name
6
6
  end
7
7
 
8
- def self.resource_name
9
- @@resource_name
8
+ def self.resource
9
+ @@resource
10
10
  end
11
11
 
12
12
  def create fields = {}
13
- post(:path => "#{@@resource_name}s.json", :params => {:user => fields})
13
+ post(:path => "#{self.resource}s.json", :params => {resource.to_sym => fields})
14
14
  end
15
15
 
16
- def edit(id, fields = {})
17
- put(:path => "#{@@resource_name}s/#{id.to_s}.json", :params => {:user => fields })
16
+ def update(id, fields = {})
17
+ put(:path => "#{self.resource}s/#{id.to_s}.json", :params => {resource.to_sym => fields })
18
18
  end
19
19
 
20
- def show id
21
- get(:path => "#{@@resource_name}s/#{id.to_s}.json", :params => {})
20
+ def read id
21
+ get(:path => "#{self.resource}s/#{id.to_s}.json", :params => {})
22
22
  end
23
23
 
24
- def delete id
25
- delete(:path => "#{@@resource_name}s/#{id.to_s}.json", :params => {})
24
+ def destroy id
25
+ delete(:path => "#{self.resource}s/#{id.to_s}.json", :params => {})
26
26
  end
27
27
 
28
28
 
@@ -2,17 +2,19 @@ module OurKudos
2
2
  class ResponseCodes
3
3
 
4
4
  CODES_MAP = {
5
- :I1 => 'User created',
6
- :I2 => 'User updated',
5
+ :I1 => 'Resource created',
6
+ :I2 => 'Resource updated',
7
7
  :E1 => 'No such api key',
8
8
  :E2 => "Api key expired",
9
9
  :E3 => 'This app / site is blocked',
10
- :E4 => "Cannot save this user",
10
+ :E4 => "Cannot save this resource",
11
11
  :E5 => 'Server error',
12
- :E6 => 'Unable to update user',
12
+ :E6 => 'Unable to update resource',
13
13
  :E7 => "Unable to process request, server responded with error",
14
14
  :E8 => "No such record",
15
- :E9 => "No such action / resource"
15
+ :E9 => "No such action / resource",
16
+ :I3 => "Resource removed",
17
+ :E10 => "Unable to remove resource"
16
18
  }
17
19
 
18
20
  def self.[](code)
@@ -1,12 +1,17 @@
1
+ require 'rake'
1
2
  namespace :ourkudos do
2
3
  namespace :config do
3
- namespace :generate => :environment do
4
+ task :generate => :environment do
4
5
 
5
6
  config = {:base_uri => "http://ourkudos.com",
6
7
  :api_key => "your api key"
7
8
  }
8
-
9
- File.open(File.join(Rails.root,'config', 'ourkudos.yml'), 'w') do |f|
9
+
10
+ file_path = File.join(Rails.root,'config', 'ourkudos.yml')
11
+
12
+ puts "Generating config file to #{file_path}. \nPlease update it with correct api key"
13
+
14
+ File.open(file_path, 'w') do |f|
10
15
  method = config.respond_to?(:ya2yaml) ? :ya2yaml : :to_yaml
11
16
  string = config.deep_stringify_keys.send(method)
12
17
  f.write string.gsub("!ruby/symbol ", ":").gsub("---","").split("\n").map(&:rstrip).join("\n").strip
data/lib/ourkudos.rb CHANGED
@@ -2,4 +2,5 @@ require 'ourkudos/response_codes'
2
2
  require 'ourkudos/extensions'
3
3
  require 'ourkudos/resource_editor'
4
4
  require 'ourkudos/our_kudos'
5
- require 'ourkudos/railtie' if defined?(Rails)
5
+
6
+ require 'ourkudos/railtie' if defined?(Rails)
data/ourkudos.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ourkudos}
8
- s.version = "0.0.21"
8
+ s.version = "0.0.29"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marcin Walczak"]
12
- s.date = %q{2011-05-06}
12
+ s.date = %q{2011-05-21}
13
13
  s.description = %q{OurKudos client api gem}
14
14
  s.email = %q{marcin.walczak@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/ourkudos/railtie.rb",
31
31
  "lib/ourkudos/resource_editor.rb",
32
32
  "lib/ourkudos/response_codes.rb",
33
- "lib/tasks/ourkudos.rake",
33
+ "lib/ourkudos/tasks/ourkudos.rb",
34
34
  "ourkudos.gemspec",
35
35
  "spec/our_kudos_spec.rb",
36
36
  "spec/spec_helper.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ourkudos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-05-06 00:00:00.000000000 +02:00
12
+ date: 2011-05-21 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nestful
17
- requirement: &23051140 !ruby/object:Gem::Requirement
17
+ requirement: &15870800 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *23051140
25
+ version_requirements: *15870800
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &23050640 !ruby/object:Gem::Requirement
28
+ requirement: &15870140 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.3.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *23050640
36
+ version_requirements: *15870140
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &23050060 !ruby/object:Gem::Requirement
39
+ requirement: &15869260 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *23050060
47
+ version_requirements: *15869260
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: jeweler
50
- requirement: &23049520 !ruby/object:Gem::Requirement
50
+ requirement: &15868260 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *23049520
58
+ version_requirements: *15868260
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rcov
61
- requirement: &23049020 !ruby/object:Gem::Requirement
61
+ requirement: &15867640 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *23049020
69
+ version_requirements: *15867640
70
70
  description: OurKudos client api gem
71
71
  email: marcin.walczak@gmail.com
72
72
  executables: []
@@ -88,7 +88,7 @@ files:
88
88
  - lib/ourkudos/railtie.rb
89
89
  - lib/ourkudos/resource_editor.rb
90
90
  - lib/ourkudos/response_codes.rb
91
- - lib/tasks/ourkudos.rake
91
+ - lib/ourkudos/tasks/ourkudos.rb
92
92
  - ourkudos.gemspec
93
93
  - spec/our_kudos_spec.rb
94
94
  - spec/spec_helper.rb
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: 3383780129191898139
111
+ hash: -2283403688265526440
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: