codefumes 0.1.10 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/Gemfile +19 -0
  2. data/Gemfile.lock +135 -0
  3. data/History.txt +12 -0
  4. data/LICENSE +20 -0
  5. data/Manifest.txt +40 -19
  6. data/README.txt +11 -29
  7. data/Rakefile +15 -10
  8. data/bin/fumes +214 -0
  9. data/config/website.yml +2 -0
  10. data/cucumber.yml +2 -0
  11. data/features/claiming_a_project.feature +46 -0
  12. data/features/deleting_a_project.feature +32 -0
  13. data/features/releasing_a_project.feature +50 -0
  14. data/features/step_definitions/cli_steps.rb +98 -0
  15. data/features/step_definitions/common_steps.rb +168 -0
  16. data/features/step_definitions/filesystem_steps.rb +19 -0
  17. data/features/storing_user_api_key.feature +41 -0
  18. data/features/support/common.rb +29 -0
  19. data/features/support/env.rb +24 -0
  20. data/features/support/matchers.rb +11 -0
  21. data/features/synchronizing_repository_with_project.feature +33 -0
  22. data/lib/codefumes.rb +10 -8
  23. data/lib/codefumes/api.rb +20 -11
  24. data/lib/codefumes/api/build.rb +139 -0
  25. data/lib/codefumes/api/claim.rb +74 -0
  26. data/lib/codefumes/api/commit.rb +150 -0
  27. data/lib/codefumes/api/payload.rb +93 -0
  28. data/lib/codefumes/api/project.rb +158 -0
  29. data/lib/codefumes/cli_helpers.rb +54 -0
  30. data/lib/codefumes/config_file.rb +3 -2
  31. data/lib/codefumes/errors.rb +21 -0
  32. data/lib/codefumes/exit_codes.rb +10 -0
  33. data/lib/codefumes/harvester.rb +113 -0
  34. data/lib/codefumes/quick_build.rb +43 -0
  35. data/lib/codefumes/quick_metric.rb +20 -0
  36. data/lib/codefumes/source_control.rb +137 -0
  37. data/lib/integrity_notifier/codefumes.haml +11 -0
  38. data/lib/integrity_notifier/codefumes.rb +62 -0
  39. data/spec/codefumes/{build_spec.rb → api/build_spec.rb} +14 -24
  40. data/spec/codefumes/{claim_spec.rb → api/claim_spec.rb} +42 -3
  41. data/spec/codefumes/{commit_spec.rb → api/commit_spec.rb} +34 -24
  42. data/spec/codefumes/api/payload_spec.rb +148 -0
  43. data/spec/codefumes/api/project_spec.rb +286 -0
  44. data/spec/codefumes/api_spec.rb +38 -15
  45. data/spec/codefumes/config_file_spec.rb +69 -13
  46. data/spec/codefumes/harvester_spec.rb +118 -0
  47. data/spec/codefumes/source_control_spec.rb +199 -0
  48. data/spec/codefumes_service_helpers.rb +23 -19
  49. data/spec/fixtures/sample_project_dirs/no_scm/description +4 -0
  50. data/spec/spec_helper.rb +1 -0
  51. data/tasks/cucumber.rake +11 -0
  52. metadata +145 -60
  53. data/bin/cf_claim_project +0 -9
  54. data/bin/cf_release_project +0 -10
  55. data/bin/cf_store_credentials +0 -10
  56. data/lib/cf_claim_project/cli.rb +0 -95
  57. data/lib/cf_release_project/cli.rb +0 -76
  58. data/lib/cf_store_credentials/cli.rb +0 -50
  59. data/lib/codefumes/build.rb +0 -131
  60. data/lib/codefumes/claim.rb +0 -57
  61. data/lib/codefumes/commit.rb +0 -144
  62. data/lib/codefumes/payload.rb +0 -103
  63. data/lib/codefumes/project.rb +0 -129
  64. data/spec/cf_claim_project/cli_spec.rb +0 -17
  65. data/spec/cf_release_project/cli_spec.rb +0 -41
  66. data/spec/cf_store_credentials/cli_spec.rb +0 -28
  67. data/spec/codefumes/payload_spec.rb +0 -155
  68. data/spec/codefumes/project_spec.rb +0 -274
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source :gemcutter
2
+
3
+ gem 'activesupport', '2.3.5'
4
+ gem 'aruba', '0.2.1'
5
+ gem 'caleb-chronic', '0.3.0'
6
+ gem 'crack', '0.1.8'
7
+ gem 'cucumber', '0.8.5'
8
+ gem 'fakeweb', '1.2.8'
9
+ gem 'gherkin', '2.1.5'
10
+ gem 'gli', '1.1.1'
11
+ gem 'grit', '2.0'
12
+ gem 'hanna', '0.1.12'
13
+ gem 'hoe', '2.5.0'
14
+ gem 'hoe-git', '1.3.0'
15
+ gem 'httparty', '0.6.1'
16
+ gem 'rake', '0.8.7'
17
+ gem 'rspec', '1.3.0'
18
+ gem 'rubigen', '1.5.5'
19
+ gem 'ruby-debug'
data/Gemfile.lock ADDED
@@ -0,0 +1,135 @@
1
+ ---
2
+ dependencies:
3
+ ruby-debug:
4
+ group:
5
+ - :default
6
+ version: ">= 0"
7
+ fakeweb:
8
+ group:
9
+ - :default
10
+ version: = 1.2.8
11
+ httparty:
12
+ group:
13
+ - :default
14
+ version: = 0.6.1
15
+ rake:
16
+ group:
17
+ - :default
18
+ version: = 0.8.7
19
+ rspec:
20
+ group:
21
+ - :default
22
+ version: = 1.3.0
23
+ grit:
24
+ group:
25
+ - :default
26
+ version: = 2.0
27
+ crack:
28
+ group:
29
+ - :default
30
+ version: = 0.1.8
31
+ gli:
32
+ group:
33
+ - :default
34
+ version: = 1.1.1
35
+ aruba:
36
+ group:
37
+ - :default
38
+ version: = 0.2.1
39
+ gherkin:
40
+ group:
41
+ - :default
42
+ version: = 2.1.5
43
+ caleb-chronic:
44
+ group:
45
+ - :default
46
+ version: = 0.3.0
47
+ hoe-git:
48
+ group:
49
+ - :default
50
+ version: = 1.3.0
51
+ hoe:
52
+ group:
53
+ - :default
54
+ version: = 2.5.0
55
+ cucumber:
56
+ group:
57
+ - :default
58
+ version: = 0.8.5
59
+ activesupport:
60
+ group:
61
+ - :default
62
+ version: = 2.3.5
63
+ hanna:
64
+ group:
65
+ - :default
66
+ version: = 0.1.12
67
+ rubigen:
68
+ group:
69
+ - :default
70
+ version: = 1.5.5
71
+ specs:
72
+ - rake:
73
+ version: 0.8.7
74
+ - activesupport:
75
+ version: 2.3.5
76
+ - aruba:
77
+ version: 0.2.1
78
+ - builder:
79
+ version: 2.1.2
80
+ - caleb-chronic:
81
+ version: 0.3.0
82
+ - columnize:
83
+ version: 0.3.1
84
+ - crack:
85
+ version: 0.1.8
86
+ - diff-lcs:
87
+ version: 1.1.2
88
+ - trollop:
89
+ version: 1.16.2
90
+ - gherkin:
91
+ version: 2.1.5
92
+ - json_pure:
93
+ version: 1.4.6
94
+ - term-ansicolor:
95
+ version: 1.0.5
96
+ - cucumber:
97
+ version: 0.8.5
98
+ - fakeweb:
99
+ version: 1.2.8
100
+ - gemcutter:
101
+ version: 0.6.1
102
+ - gli:
103
+ version: 1.1.1
104
+ - mime-types:
105
+ version: "1.16"
106
+ - grit:
107
+ version: 2.0.0
108
+ - haml:
109
+ version: 2.2.24
110
+ - rdoc:
111
+ version: 2.3.0
112
+ - hanna:
113
+ version: 0.1.12
114
+ - rubyforge:
115
+ version: 2.0.4
116
+ - hoe:
117
+ version: 2.5.0
118
+ - hoe-git:
119
+ version: 1.3.0
120
+ - httparty:
121
+ version: 0.6.1
122
+ - linecache:
123
+ version: "0.43"
124
+ - rspec:
125
+ version: 1.3.0
126
+ - rubigen:
127
+ version: 1.5.5
128
+ - ruby-debug-base:
129
+ version: 0.10.3
130
+ - ruby-debug:
131
+ version: 0.10.3
132
+ hash: 3b81c08f31e7b6fea59ef7782384b348c7d2609a
133
+ sources:
134
+ - Rubygems:
135
+ uri: http://gemcutter.org
data/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 0.2.0 / 2010-08-15
2
+
3
+ * Merged CodeFumesHarvester gem content into this gem...the
4
+ CodeFumesHarvester gem will go away now...
5
+ * Removed cf-based executables and replaced with single git-style
6
+ 'fumes' executable (using gli gem...you should check it out)
7
+ * Refactored all classes to expect objects as arguments where it made
8
+ sense and was missing NOTE: Completely breaks previous API
9
+ * Added in cucumber for testing...mostly on 'fumes' executable
10
+ at this point
11
+ * Migrated to bundler for gem support
12
+
1
13
  === 0.1.10 / 21-APR-2010
2
14
 
3
15
  * Updated all gem dependencies to use only gems released to gemcutter (vs. older
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Tom Kersten
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 NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt CHANGED
@@ -1,31 +1,50 @@
1
+ Gemfile
2
+ Gemfile.lock
1
3
  History.txt
4
+ LICENSE
2
5
  Manifest.txt
3
6
  README.txt
4
7
  Rakefile
5
- bin/cf_claim_project
6
- bin/cf_release_project
7
- bin/cf_store_credentials
8
- lib/cf_claim_project/cli.rb
9
- lib/cf_release_project/cli.rb
10
- lib/cf_store_credentials/cli.rb
8
+ bin/fumes
9
+ config/website.yml
10
+ cucumber.yml
11
+ features/claiming_a_project.feature
12
+ features/deleting_a_project.feature
13
+ features/releasing_a_project.feature
14
+ features/step_definitions/cli_steps.rb
15
+ features/step_definitions/common_steps.rb
16
+ features/step_definitions/filesystem_steps.rb
17
+ features/storing_user_api_key.feature
18
+ features/support/common.rb
19
+ features/support/env.rb
20
+ features/support/matchers.rb
21
+ features/synchronizing_repository_with_project.feature
11
22
  lib/codefumes.rb
12
23
  lib/codefumes/api.rb
13
- lib/codefumes/build.rb
14
- lib/codefumes/claim.rb
15
- lib/codefumes/commit.rb
24
+ lib/codefumes/api/build.rb
25
+ lib/codefumes/api/claim.rb
26
+ lib/codefumes/api/commit.rb
27
+ lib/codefumes/api/payload.rb
28
+ lib/codefumes/api/project.rb
29
+ lib/codefumes/cli_helpers.rb
16
30
  lib/codefumes/config_file.rb
17
- lib/codefumes/payload.rb
18
- lib/codefumes/project.rb
19
- spec/cf_claim_project/cli_spec.rb
20
- spec/cf_release_project/cli_spec.rb
21
- spec/cf_store_credentials/cli_spec.rb
31
+ lib/codefumes/errors.rb
32
+ lib/codefumes/exit_codes.rb
33
+ lib/codefumes/harvester.rb
34
+ lib/codefumes/quick_build.rb
35
+ lib/codefumes/quick_metric.rb
36
+ lib/codefumes/source_control.rb
37
+ lib/integrity_notifier/codefumes.haml
38
+ lib/integrity_notifier/codefumes.rb
39
+ spec/codefumes/api/build_spec.rb
40
+ spec/codefumes/api/claim_spec.rb
41
+ spec/codefumes/api/commit_spec.rb
42
+ spec/codefumes/api/payload_spec.rb
43
+ spec/codefumes/api/project_spec.rb
22
44
  spec/codefumes/api_spec.rb
23
- spec/codefumes/build_spec.rb
24
- spec/codefumes/claim_spec.rb
25
- spec/codefumes/commit_spec.rb
26
45
  spec/codefumes/config_file_spec.rb
27
- spec/codefumes/payload_spec.rb
28
- spec/codefumes/project_spec.rb
46
+ spec/codefumes/harvester_spec.rb
47
+ spec/codefumes/source_control_spec.rb
29
48
  spec/codefumes_service_helpers.rb
30
49
  spec/fixtures/build.xml
31
50
  spec/fixtures/commit.xml
@@ -34,6 +53,8 @@ spec/fixtures/multiple_commits.xml
34
53
  spec/fixtures/payload.xml
35
54
  spec/fixtures/project.xml
36
55
  spec/fixtures/project_update.xml
56
+ spec/fixtures/sample_project_dirs/no_scm/description
37
57
  spec/spec.opts
38
58
  spec/spec_helper.rb
59
+ tasks/cucumber.rake
39
60
  tasks/rspec.rake
data/README.txt CHANGED
@@ -12,7 +12,8 @@ CodeFumes.com[http://codefumes.com] is a service intended to help people
12
12
  involved with software projects who are interested in tracking, sharing,
13
13
  and reviewing metrics/information about a project in relation to the
14
14
  commits of said project's repository. The site supports a small set of
15
- 'standard' metrics, but also provides a simple method of supplying
15
+ 'standard' metrics (# lines changed/commit, build status, build duration,
16
+ etc). Additionally, the service provides a simple method of supplying
16
17
  and retrieving custom metrics, allowing users to gather any metric they
17
18
  are interested in tracking.
18
19
 
@@ -21,10 +22,6 @@ CodeFumes.com[http://codefumes.com] API. The intention of the
21
22
  gem is to simplify integration with CodeFumes.com for developers of
22
23
  other libraries & and applications.
23
24
 
24
- For an example of another library using the current features of this
25
- gem, you can refer to the
26
- 'codefumes_harvester[http://codefumes.rubyforge.org/codefumes_harvester]' gem.
27
-
28
25
  == FEATURES/PROBLEMS:
29
26
 
30
27
  === Features
@@ -38,6 +35,8 @@ gem, you can refer to the
38
35
  using.
39
36
  * Interfaces with the CodeFumes config file (used to track projects a
40
37
  user has created on the site)
38
+ * Tracking & retrieving information about continuous integration server
39
+ builds (duration, status, etc).
41
40
 
42
41
  === Problems / Things to Note
43
42
 
@@ -48,7 +47,7 @@ gem, you can refer to the
48
47
  require 'codefumes'
49
48
 
50
49
  # Creating & finding a CodeFumes project
51
- p = Project.save # optionally providing a custom public key: :public_key => 'Abc3'
50
+ p = Project.create
52
51
  found_p = Project.find(p.public_key)
53
52
  p.public_key # => 'Abc3'
54
53
  p.api_uri # => 'http://codefumes.com/api/v1/xml/Abc3'
@@ -61,7 +60,6 @@ gem, you can refer to the
61
60
  # Custom attributes associated with a commit
62
61
  c.custom_attributes[:coverage] # => "80"
63
62
 
64
-
65
63
  # Payloads, used to break up large HTTP requests
66
64
  content = Payload.prepare(payload_content)
67
65
  content.each {|chunk| chunk.save}
@@ -69,34 +67,18 @@ gem, you can refer to the
69
67
  == REQUIREMENTS:
70
68
 
71
69
  * httparty (0.4.3)
70
+ * caleb-chronic (0.3.0)
71
+ * gli (1.1.1)
72
72
 
73
73
  == INSTALL:
74
74
 
75
75
  From Gemcutter:
76
76
 
77
- sudo gem install codefumes
77
+ gem install codefumes
78
78
 
79
79
  == LICENSE:
80
80
 
81
- (The MIT License)
82
-
83
- Copyright (c) 2009 Cosyn Technologies, Inc.
84
-
85
- Permission is hereby granted, free of charge, to any person obtaining
86
- a copy of this software and associated documentation files (the
87
- 'Software'), to deal in the Software without restriction, including
88
- without limitation the rights to use, copy, modify, merge, publish,
89
- distribute, sublicense, and/or sell copies of the Software, and to
90
- permit persons to whom the Software is furnished to do so, subject to
91
- the following conditions:
92
-
93
- The above copyright notice and this permission notice shall be
94
- included in all copies or substantial portions of the Software.
81
+ Refer to the LICENSE file
95
82
 
96
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
97
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
98
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
99
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
100
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
101
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
102
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
83
+ == Contributors
84
+ * Joe Banks
data/Rakefile CHANGED
@@ -1,4 +1,7 @@
1
- %w[hoe rake rake/clean fileutils rubigen hoe].each { |f| require f }
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ %w[hoe rake rake/clean fileutils].each { |f| require f }
2
5
 
3
6
  $LOAD_PATH.unshift('lib') unless $LOAD_PATH.include?('lib')
4
7
  require 'lib/codefumes'
@@ -9,25 +12,27 @@ rescue LoadError
9
12
  require 'rake/rdoctask'
10
13
  end
11
14
 
12
- # Load in the harvester ane metric_fu gems if available so we can collect metrics
15
+ # Load in the metric_fu gem if available so we can collect metrics
13
16
  begin
14
17
  require "metric_fu"
15
- require "codefumes_harvester"
16
18
  rescue LoadError
17
19
  end
18
20
 
19
- Hoe.plugin :website
20
21
  Hoe.plugin :git
21
22
 
22
23
  $hoe = Hoe.spec('codefumes') do
23
24
  self.summary = "A client-side implementation of the CodeFumes.com API."
24
- self.extra_dev_deps = [['metric_fu', ">= 1.3.0"],
25
- ['rubigen', ">= 1.5.2"],
26
- ['fakeweb', ">= 1.2.6"]
25
+ self.extra_dev_deps = [['metric_fu', "1.3.0"],
26
+ ['rubigen', "1.5.5"],
27
+ ['fakeweb', "1.2.8"],
28
+ ['activesupport', "2.3.5"],
29
+ ['rspec', ">= 1.2.6"],
30
+ ['cucumber', "0.8.5"],
31
+ ['aruba', "0.2.1"]
27
32
  ]
28
- self.extra_deps = [['httparty','>= 0.4.3'], ['caleb-chronic', '>= 0.3.0']]
29
- developer('Tom Kersten', 'tom.kersten@cosyntech.com')
30
- developer('Joe Banks', 'freemarmoset@gmail.com')
33
+ self.extra_deps = [['httparty','>= 0.6.1'], ['caleb-chronic', '>= 0.3.0'], ['gli', '1.1.1']]
34
+ self.extra_rdoc_files = ['LICENSE']
35
+ developer('Tom Kersten', 'tom.kersten@codefumes.com')
31
36
  end
32
37
 
33
38
  Dir['tasks/**/*.rake'].each { |t| load t}
data/bin/fumes ADDED
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'codefumes'
5
+ require 'codefumes/cli_helpers'
6
+
7
+ begin
8
+ require 'gli'
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ gem 'gli'
12
+ require 'gli'
13
+ end
14
+
15
+ include GLI
16
+ include CodeFumes
17
+ include CodeFumes::CLIHelpers
18
+
19
+
20
+ desc 'Synchronize local master branch history with a CodeFumes project'
21
+ command :sync do |c|
22
+ c.desc 'Public key of CodeFumes project'
23
+ c.arg_name 'pub-key-here'
24
+ c.default_value nil
25
+ c.flag [:p,:public_key]
26
+
27
+ c.desc 'API key of CodeFumes project'
28
+ c.arg_name 'api-key-here'
29
+ c.default_value nil
30
+ c.flag [:a,:api_key]
31
+
32
+ c.action do |global_options,options,args|
33
+ harvester = Harvester.new(:public_key => options[:p], :private_key => options[:a])
34
+
35
+ if (results = harvester.publish_data!) == false
36
+ puts "Error syncing with CodeFumes project. Please try again."
37
+ exit(1)
38
+ else
39
+ if results.empty?
40
+ puts "Local repository is in sync with server. No updates posted."
41
+ else
42
+ puts "Successfully saved #{results[:successful_count]} of #{results[:total_count]} payloads."
43
+ puts "Project saved to CodeFumes.com. Visit #{harvester.short_uri}"
44
+ end
45
+ puts "Exiting."
46
+ puts
47
+ end
48
+ end
49
+ end
50
+
51
+ desc 'Associate project(s) with your CodeFumes.com user account'
52
+ long_desc <<-DESC
53
+ Claiming a project links the specified key stored in the project
54
+ repository (or the key specified as an argument) with the account
55
+ credentials stored in your CodeFumes config file.
56
+ DESC
57
+ command :claim do |c|
58
+ c.desc 'Public key of CodeFumes project'
59
+ c.arg_name 'pub-key-here'
60
+ c.default_value nil
61
+ c.flag [:public_key, :p]
62
+
63
+ c.desc 'Claim all projects listed in your CodeFumes config file'
64
+ c.switch [:all, :a]
65
+
66
+ c.action do |global_options, options, args|
67
+ issue_project_commands("Claiming", public_keys_specified(options)) do |project|
68
+ wrap_with_standard_feedback(project) {project.claim}
69
+ end
70
+ end
71
+ end
72
+
73
+ desc "'Unclaim' project(s) on CodeFumes.com...relinquishing ownership"
74
+ long_desc <<-DESC
75
+ Releasing a project relinquishes ownership of the project...removing
76
+ it from your account and making it available for others to claim
77
+ ownership of (assuming they have the project's private key). Only
78
+ the 'owner' of a project can release it. Also note that this does
79
+ NOT delete any data associated with the project. To delete a project
80
+ and all associated data, use 'fumes delete'.
81
+ DESC
82
+ command :release do |c|
83
+ c.desc 'Public key of CodeFumes project'
84
+ c.arg_name 'pub-key-here'
85
+ c.default_value nil
86
+ c.flag [:public_key, :p]
87
+
88
+ c.desc 'Release all projects listed in your CodeFumes config file'
89
+ c.switch [:all, :a]
90
+
91
+ c.action do |global_options, options, args|
92
+ issue_project_commands("Releasing", public_keys_specified(options)) do |project|
93
+ wrap_with_standard_feedback(project) {project.release}
94
+ end
95
+ end
96
+ end
97
+
98
+ desc 'Delete project(s) on CodeFumes.com'
99
+ long_desc <<-DESC
100
+ Deleting a project will remove the project and all associated data
101
+ from CodeFumes.com. If the command is issued inside an existing
102
+ CodeFumes project, no flags are required. Note that this action
103
+ can't be reverted.
104
+ DESC
105
+ command :delete do |c|
106
+ c.desc 'Public key of CodeFumes project'
107
+ c.arg_name 'pub-key-here'
108
+ c.default_value nil
109
+ c.flag [:public_key, :p]
110
+
111
+ c.desc 'Delete all projects listed in your CodeFumes config file'
112
+ c.switch [:all, :a]
113
+
114
+ c.action do |global_options, options, args|
115
+ issue_project_commands("Deleting", public_keys_specified(options)) do |project|
116
+ wrap_with_standard_feedback(project) {project.delete}
117
+ end
118
+ end
119
+ end
120
+
121
+ desc 'Store (or clear) your api-key in the CodeFumes config file'
122
+ command :'api-key'do |c|
123
+ c.desc 'Clear the API key currently stored in your CodeFumes config file'
124
+ c.default_value false
125
+ c.switch [:clear, :c]
126
+
127
+ c.action do |global_options, options, args|
128
+ if !options[:clear] && args.empty?
129
+ raise Errors::NoApiKeySpecified
130
+ end
131
+
132
+ api_key = options[:clear] ? nil : args.first
133
+ ConfigFile.save_credentials(api_key)
134
+
135
+ if options[:clear]
136
+ puts "Your API key has been removed from your CodeFumes config file."
137
+ else
138
+ puts "Your API key has been saved to your CodeFumes config file."
139
+ end
140
+ end
141
+ end
142
+
143
+ desc "Open project page in your default browser (requires 'launchy' gem)"
144
+ command :open do |c|
145
+ c.desc 'Public key of CodeFumes project to open'
146
+ c.arg_name 'pub-key-here'
147
+ c.default_value nil
148
+ c.flag [:public_key, :p]
149
+
150
+ c.action do |global_options, options, args|
151
+ msg = 'Opening CodeFumes project page'
152
+ issue_project_commands(msg, public_keys_specified(options)) do |project|
153
+ open_in_browser project.short_uri
154
+ end
155
+ end
156
+ end
157
+
158
+ pre do |global,command,options,args|
159
+ unless API.mode?(:production) || command_doesnt_use_api?(command)
160
+ print_api_mode_notification
161
+ end
162
+ true
163
+ end
164
+
165
+ post do |global,command,options,args|
166
+ end
167
+
168
+ on_error do |exception|
169
+ case exception
170
+ when CodeFumes::Errors::UnsupportedScmToolError
171
+ puts "Unsupported repository type. Exiting..."
172
+ exit(ExitCodes::UNSUPPORTED_SCM)
173
+ when CodeFumes::Errors::UnknownProjectError
174
+ msg = "Could not find specified project on CodeFumes. "
175
+ msg << "Please verify the key and try again. Exiting..."
176
+ puts msg
177
+ exit(ExitCodes::PROJECT_NOT_FOUND)
178
+ when CodeFumes::Errors::NoUserApiKeyError
179
+ msg = "Unable to load an account API key from "
180
+ msg << "your CodeFumes config file.\n"
181
+ msg << "Log into your CodeFumes account, grab your API key, and run:\n"
182
+ msg << "\tfumes setup YOUR-API-KEY-HERE\n\n"
183
+ msg << "Exiting."
184
+ puts msg
185
+ exit(ExitCodes::NO_USER_CREDENTIALS)
186
+ when CodeFumes::Errors::InsufficientCredentials
187
+ msg = "The API key in your CodeFumes config file is not "
188
+ msg << "associated with the specified project. Please verify "
189
+ msg << "your API key is identical to what is listed on your "
190
+ msg << "CodeFumes.com account page"
191
+ msg << "Exiting."
192
+ puts msg
193
+ exit(ExitCodes::INCORRECT_USER_CREDENTIALS)
194
+ when Errors::NoApiKeySpecified
195
+ puts "No API key specified. To clear your api-key, use the '-c/--clear' flag.\nExiting."
196
+ exit(ExitCodes::NO_API_KEY_SPECIFIED)
197
+ when Errors::MissingLaunchyGem
198
+ puts ""
199
+ puts ""
200
+ puts "Sorry, you need to install launchy: `gem install launchy`"
201
+ puts "Exiting."
202
+ exit(ExitCodes::MISSING_DEPENDENCY)
203
+ when RuntimeError
204
+ # allow default handler to take over when invalid arguments are passed in
205
+ else
206
+ puts "An unknown exception occurred ('#{exception.class.to_s}--#{exception}')."
207
+ puts "Backtrace:\n#{exception.backtrace}')."
208
+ puts "Exiting..."
209
+ exit(ExitCodes::UNKNOWN)
210
+ end
211
+ true
212
+ end
213
+
214
+ GLI.run(ARGV)