sidestep 2.0.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0afc6a8ca66f3852e1e0d55ed9324a692d580a70
4
+ data.tar.gz: 54a2a93ee7c6e355e370e035e265ae36a1041604
5
+ SHA512:
6
+ metadata.gz: a49aa2db092260bb13349421ced92b82a00d2822e705f5127b60806c00bb388e74e764b8347f5905aaee945a4ead087de38cb9fb37f24bed650b25214f041bd9
7
+ data.tar.gz: bd6623bc0c345849604bf1b5df39df31ba54f8cbde373cda620b4239801de98b1d50c30cc09de353541a28db9fd1fa6fc7b1bd0ea0b734d94f6c0169ec8534bb
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # sidestep
2
+
3
+ Sidestep allows you to launch a specific controller of your app on demand. If you are working on a controller which requires several manual actions to access each time you build your app, you can use Sidestep to directly load this controller, and even set some args.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sidestep'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sidestep
18
+
19
+ ## Usage
20
+
21
+ You should now have access to a new rake task command :
22
+
23
+ rake sidestep[MyController]
24
+
25
+ You can also provide params to your controller (not available for android atm) :
26
+
27
+ rake sidestep[MyController] id=5
28
+
29
+ ## Custom behavior
30
+
31
+ If you need to add custom initialization (Google analytics SDK...) in the delegate before showing the controller, you can create your own `app_delegate.erb` (note: it's ERB not RB) at the root of the app. See this repository for example.
@@ -0,0 +1,78 @@
1
+ module Motion::Project
2
+ class Sidestep
3
+ if App.config.template == :ios
4
+ MAIN = "app_delegate"
5
+ else
6
+ MAIN = "main_activity"
7
+ end
8
+
9
+ def initialize(controller, keys)
10
+ @controller = controller
11
+ @keys = keys
12
+
13
+ FileUtils.mkdir_p("./tmp")
14
+ end
15
+
16
+ def replace
17
+ current_main = "./app/#{MAIN}.rb"
18
+
19
+ App.config.files -= [current_main]
20
+ new_main = prepare_tempfile(current_main)
21
+ content = write_erb(template, {controller: @controller, keys: @keys})
22
+ write_file(new_main, content)
23
+ App.config.files += [new_main]
24
+ end
25
+
26
+ protected
27
+
28
+ def template
29
+ specific = "./#{MAIN}.erb"
30
+ if File.exist?(specific)
31
+ return File.expand_path(specific)
32
+ end
33
+
34
+ File.expand_path("../#{MAIN}.erb", __FILE__)
35
+ end
36
+
37
+ def prepare_tempfile(path)
38
+ tempfile = File.join(File.dirname(App.config.project_dir), "tmp", File.basename(path))
39
+ if File.exists?(tempfile)
40
+ File.delete(tempfile)
41
+ end
42
+ tempfile
43
+ end
44
+
45
+ def write_erb(path, locals)
46
+ template_path = File.expand_path(path, __FILE__)
47
+ template = File.new(template_path).read
48
+ ERB.new(template).result(OpenStruct.new(locals).instance_eval { binding })
49
+ end
50
+
51
+ def write_file(path, content)
52
+ io = File.new(path, "w")
53
+ io.puts(content)
54
+ io.close
55
+ end
56
+ end
57
+ end
58
+
59
+ desc "Run a specific controller"
60
+ task :sidestep, [:controller] do |t, args|
61
+ if args[:controller]
62
+ controller = args[:controller]
63
+ else
64
+ App.fail("You have to provide a controller, eg: rake sidestep[MyController]")
65
+ end
66
+
67
+ ARGV.shift
68
+ keys = ARGV.map { |option| option.split("=") }.to_h
69
+
70
+ Motion::Project::Sidestep.new(controller, keys).replace
71
+
72
+ if App.config.template == :ios
73
+ Rake::Task[:simulator].invoke
74
+ else
75
+ App.config.sub_activities << controller.to_s
76
+ Rake::Task[:emulator].invoke
77
+ end
78
+ end
data/lib/sidestep.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'erb'
2
+ require 'fileutils'
3
+ require './../lib/motion/project/sidestep'
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sidestep
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Joffrey Jaffeux
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Simple gem to load one specific controller on demand
28
+ email:
29
+ - j.jaffeux@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/motion/project/sidestep.rb
36
+ - lib/sidestep.rb
37
+ homepage: ''
38
+ licenses:
39
+ - ''
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.2.2
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Simple gem to load one specific controller on demand
61
+ test_files: []
62
+ has_rdoc: