bushido_stub 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc ADDED
@@ -0,0 +1,15 @@
1
+ = Description
2
+
3
+ Stub all the Bushido API methods
4
+
5
+ == Configuration
6
+
7
+ In your config/application.rb file
8
+
9
+ config.bushido_stub_env = {
10
+ 'APP_TLD' => 'bushi.do',
11
+ 'BUSHIDO_APP' => 'san_francisco',
12
+ 'BUSHIDO_HOST' => 'bushi.do',
13
+ 'LOCOMOTIVE_SITE_NAME' => 'Locomotive TEST',
14
+ 'BUSHIDO_CLAIMED' => 'true'
15
+ }
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+
3
+ require 'rake'
4
+ require 'rake/gempackagetask'
5
+
6
+ require 'bundler'
7
+ Bundler.setup
8
+
9
+ gemspec = eval(File.read('bushido_stub.gemspec'))
10
+ Rake::GemPackageTask.new(gemspec) do |pkg|
11
+ pkg.gem_spec = gemspec
12
+ end
13
+
14
+ desc 'build the gem and release it to rubygems.org'
15
+ task :release => :gem do
16
+ sh "gem push pkg/bushido_stub-#{gemspec.version}.gem"
17
+ end
data/lib/bushido.rb ADDED
@@ -0,0 +1,73 @@
1
+ require 'active_support'
2
+ require 'ostruct'
3
+
4
+ module Bushido
5
+
6
+ mattr_accessor :domains, :subdomain, :last_command_successful, :claimed, :last_event
7
+
8
+ def self.set_env(options = {})
9
+ options = {
10
+ :last_command_successful => true,
11
+ :domains => [],
12
+ :subdomain => 'san_francisco',
13
+ :claimed => false,
14
+ :last_event => {
15
+ :category => 'user',
16
+ :name => 'create',
17
+ :data => { 'email' => 'san_francisco@bushi.do', 'id' => 4242 }
18
+ }
19
+ }.merge(options)
20
+
21
+ @@domains = options.delete(:domains)
22
+ @@subdomain = options.delete(:subdomain)
23
+ @@last_command_successful = options.delete(:last_command_successful)
24
+ @@claimed = options.delete(:claimed)
25
+
26
+ ENV['BUSHIDO_CLAIMED'] = @@claimed.to_s
27
+
28
+ @@last_event = OpenStruct.new(options.delete(:last_event))
29
+
30
+ options.each { |k, v| ENV[k] = v }
31
+ end
32
+
33
+ module Command
34
+
35
+ def self.last_command_successful?
36
+ ::Bushido.last_command_successful
37
+ end
38
+
39
+ def self.add_domain(name)
40
+ ::Bushido.domains << name
41
+ end
42
+
43
+ def self.remove_domain(name)
44
+ ::Bushido.domains.delete(name)
45
+ end
46
+
47
+ end
48
+
49
+ module App
50
+
51
+ def self.domains
52
+ ::Bushido.domains
53
+ end
54
+
55
+ def self.subdomain
56
+ ::Bushido.subdomain
57
+ end
58
+
59
+ def self.set_subdomain(domain)
60
+ ::Bushido.subdomain
61
+ end
62
+
63
+ def self.claimed?
64
+ ::Bushido.claimed
65
+ end
66
+
67
+ def self.last_event
68
+ ::Bushido.last_event
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,9 @@
1
+ require 'bushido'
2
+
3
+ if defined?(Rails)
4
+ if Rails::VERSION::MAJOR >= 3
5
+ require 'bushido_stub/railtie'
6
+ else
7
+ puts "[Warning] BushidoStub does not work with Rails < 3"
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module BushidoStub
2
+
3
+ class Railtie < Rails::Railtie
4
+
5
+ config.bushido_stub_env = {}
6
+
7
+ initializer 'bushido_stub.initialize' do |app|
8
+ if !app.config.bushido_stub_env.nil? && app.config.bushido_stub_env != false
9
+ Bushido.set_env(app.config.bushido_stub_env)
10
+ end
11
+ end
12
+ end
13
+
14
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bushido_stub
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.2
6
+ platform: ruby
7
+ authors:
8
+ - Didier Lafforgue
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: activesupport
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.7
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ description: Best tool ever for Bushido developers
27
+ email: didier@nocoffee.fr
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README.rdoc
34
+ files:
35
+ - lib/bushido.rb
36
+ - lib/bushido_stub/railtie.rb
37
+ - lib/bushido_stub.rb
38
+ - README.rdoc
39
+ - Rakefile
40
+ homepage: http://bushi.do
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: -3874642435453488185
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.6
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.5
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Stub all the Bushido API methods
70
+ test_files: []
71
+