wix 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wix.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Scott Motte
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ 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.
@@ -0,0 +1,37 @@
1
+ # Wix Ruby Bindings
2
+
3
+ Rubygem to interact with Wix's add-on marketplace API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'wix'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install wix
18
+
19
+ Then in your application initialize the gem:
20
+
21
+ $ Wix.app_secret_key = "your_app_secret_key"
22
+ $ Wix.app_key = "your_app_key"
23
+
24
+
25
+ ## Usage
26
+
27
+ ### Parse Instance
28
+
29
+ $ Wix::Instance.parse("instance_parameter_from_wix")
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ require "wix/instance"
2
+ require "wix/version"
3
+
4
+ module Wix
5
+ extend self
6
+
7
+ def app_secret_key=(app_secret_key)
8
+ @app_secret_key = app_secret_key
9
+ end
10
+
11
+ def app_secret_key
12
+ return @app_secret_key if @app_secret_key
13
+ "missing_app_secret_key"
14
+ end
15
+
16
+ def app_key=(app_key)
17
+ @app_key = app_key
18
+ end
19
+
20
+ def app_key
21
+ return @app_key if @app_key
22
+ "missing_app_key"
23
+ end
24
+ end
@@ -0,0 +1,22 @@
1
+ module Wix
2
+ class Instance
3
+ def self.parse(wix_signed_instance)
4
+ signature, encoded_json = wix_signed_instance.split('.', 2)
5
+
6
+ raise "Invalid signature" if !valid_signature(signature, encoded_json)
7
+
8
+ encoded_json_hack = encoded_json + ('=' * (4 - encoded_json.length.modulo(4)))
9
+ json_string = Base64.urlsafe_decode64(encoded_json_hack)
10
+ hash = JSON.parse(json_string)
11
+
12
+ RecursiveOpenStruct.new(hash, :recurse_over_arrays => true)
13
+ end
14
+
15
+ def self.valid_signature(signature, encoded_json)
16
+ hmac = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, Wix.app_secret_key, encoded_json)
17
+ my_signature = Base64.urlsafe_encode64(hmac).gsub('=','')
18
+
19
+ signature == my_signature
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Wix
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'pry'
4
+ require 'wix'
5
+
6
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ config.before(:suite) do
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wix do
4
+ subject { Wix }
5
+
6
+ describe "defaults" do
7
+ before do
8
+ subject.app_secret_key = nil
9
+ subject.app_key = nil
10
+ end
11
+
12
+ it { subject.app_secret_key.should eq "missing_app_secret_key" }
13
+ it { subject.app_key.should eq "missing_app_key" }
14
+ end
15
+
16
+ describe "setting values" do
17
+ let(:app_secret_key) { "1234-5678" }
18
+ let(:app_key) { "5678-9012" }
19
+
20
+ before do
21
+ subject.app_secret_key = app_secret_key
22
+ subject.app_key = app_key
23
+ end
24
+
25
+ it { subject.app_secret_key.should eq app_secret_key }
26
+ it { subject.app_key.should eq app_key }
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'wix/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "wix"
8
+ gem.version = Wix::VERSION
9
+ gem.authors = ["scottmotte"]
10
+ gem.email = ["scott@scottmotte.com"]
11
+ gem.description = %q{Rubygem to interact with Wix's add-on marketplace API.}
12
+ gem.summary = %q{Rubygem to interact with Wix's add-on marketplace API.}
13
+ gem.homepage = "http://github.com/scottmotte/wix"
14
+
15
+ gem.add_dependency "recursive-open-struct"
16
+
17
+ gem.add_development_dependency "foreman"
18
+ gem.add_development_dependency "pry"
19
+ gem.add_development_dependency "rake"
20
+ gem.add_development_dependency "rspec"
21
+
22
+ gem.files = `git ls-files`.split($/)
23
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
24
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
25
+ gem.require_paths = ["lib"]
26
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wix
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - scottmotte
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: recursive-open-struct
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: foreman
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '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: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '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: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
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: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
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: Rubygem to interact with Wix's add-on marketplace API.
95
+ email:
96
+ - scott@scottmotte.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - Gemfile
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - lib/wix.rb
108
+ - lib/wix/instance.rb
109
+ - lib/wix/version.rb
110
+ - spec/spec_helper.rb
111
+ - spec/wix_spec.rb
112
+ - wix.gemspec
113
+ homepage: http://github.com/scottmotte/wix
114
+ licenses: []
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ segments:
126
+ - 0
127
+ hash: 2201631256068211097
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: 2201631256068211097
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 1.8.23
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: Rubygem to interact with Wix's add-on marketplace API.
143
+ test_files:
144
+ - spec/spec_helper.rb
145
+ - spec/wix_spec.rb